Skip to article frontmatterSkip to article content

Advanced Himawari Imager (AHI) data with Satpy

pythia ncar

This notebook is developed during the pythia cook-off at NCAR Mesa-Lab Boulder Colorado, June 12-14, 2024

Participants in the workshop event have the chance to practice collaborative problem-solving and hands-on learning in the field of Python programming.

This notebook is part of the Breakout Topic: Geostationary on AWS, lead by Jorge Humberto Bravo Mendez jbravo2@stevens.edu, from Stevens Institute of Technology

Advanced Himawari Imager (AHI) data with Satpy

Using Satpy to read and Advanced Baseline Imager (ABI) data from GOES-R satellites. Here’s a step-by-step guide:


Imports

import warnings
warnings.filterwarnings('ignore')
warnings.simplefilter('ignore', SyntaxWarning)

from satpy.scene import Scene
from satpy.utils import debug_on

from datetime import datetime

from glob import glob

Starting to create satpy scenes

sat_files = glob("input/HI9_AHI_L1b_JP/*")
sat_files
['input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B10_JP02_R20_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B06_JP02_R20_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B08_JP02_R20_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B13_JP02_R20_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B14_JP02_R20_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B03_JP02_R05_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B09_JP02_R20_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B07_JP02_R20_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B04_JP02_R10_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B05_JP02_R20_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B02_JP02_R10_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B15_JP02_R20_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B12_JP02_R20_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B11_JP02_R20_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B01_JP02_R10_S0101.DAT.bz2', 'input/HI9_AHI_L1b_JP/HS_H09_20230815_0430_B16_JP02_R20_S0101.DAT.bz2']
scn = Scene(filenames = sat_files, reader='ahi_hsd')

dataset_names = scn.all_dataset_names()

print(dataset_names)
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[3], line 1
----> 1 scn = Scene(filenames = sat_files, reader='ahi_hsd')
      3 dataset_names = scn.all_dataset_names()
      5 print(dataset_names)

File ~/micromamba/envs/geostationary-cookbook/lib/python3.14/site-packages/satpy/scene.py:153, in Scene.__init__(self, filenames, reader, filter_parameters, reader_kwargs)
    150     raise ValueError("'filenames' must be a list of files: Scene(filenames=[filename])")
    152 if filenames:
--> 153     filenames = convert_remote_files_to_fsspec(filenames, storage_options)
    155 self._readers = self._create_reader_instances(filenames=filenames,
    156                                               reader=reader,
    157                                               reader_kwargs=cleaned_reader_kwargs)
    158 self._datasets = DatasetDict()

File ~/micromamba/envs/geostationary-cookbook/lib/python3.14/site-packages/satpy/utils.py:790, in convert_remote_files_to_fsspec(filenames, storage_options)
    788 if isinstance(filenames, dict):
    789     return _check_file_protocols_for_dicts(filenames, storage_options)
--> 790 return _check_file_protocols(filenames, storage_options)

File ~/micromamba/envs/geostationary-cookbook/lib/python3.14/site-packages/satpy/utils.py:802, in _check_file_protocols(filenames, storage_options)
    801 def _check_file_protocols(filenames, storage_options):
--> 802     local_files, remote_files, fs_files = _sort_files_to_local_remote_and_fsfiles(filenames)
    804     if remote_files:
    805         return local_files + fs_files + _filenames_to_fsfile(remote_files, storage_options)

File ~/micromamba/envs/geostationary-cookbook/lib/python3.14/site-packages/satpy/utils.py:811, in _sort_files_to_local_remote_and_fsfiles(filenames)
    810 def _sort_files_to_local_remote_and_fsfiles(filenames):
--> 811     from satpy.readers.core.remote import FSFile
    813     local_files = []
    814     remote_files = []

File ~/micromamba/envs/geostationary-cookbook/lib/python3.14/site-packages/satpy/readers/core/remote.py:25
     22 from functools import total_ordering
     24 import fsspec
---> 25 from upath import UPath
     28 @total_ordering
     29 class FSFile(os.PathLike):
     30     """Implementation of a PathLike file object, that can be opened.
     31 
     32     Giving the filenames to :class:`Scene <satpy.scene.Scene>` with valid transfer protocols will automatically
   (...)     49 
     50     """

ModuleNotFoundError: No module named 'upath'
scn.load(dataset_names)
print(scn.available_composite_names())
rgb_im = 'airmass'

scn.load([rgb_im])
### Uncomment to show it
#scn.show(rgb_im)
result = scn[rgb_im]

result
keys = scn.keys()

keys
area_info = scn["B13"].area

area_info
scn.load(["natural_color"])
rs = scn["B13"].area

lscn = scn.resample(rs)
lscn.load(["natural_color"])

### Uncomment to show it
#lscn.show("natural_color")
lscn.load(['true_color'])

### Uncomment to show it
#lscn.show('true_color')