Skip to article frontmatterSkip to article content

Advance Meteorological Imager (AMI) 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

Advance Meteorological Imager (AMI) 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/GK2A_AMI_L1B_LA/*")
sat_files
['input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_vi004_la010ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_vi008_la010ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_ir105_la020ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_ir123_la020ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_nr016_la020ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_ir133_la020ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_sw038_la020ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_ir112_la020ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_wv069_la020ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_wv063_la020ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_nr013_la020ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_vi005_la010ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_ir087_la020ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_ir096_la020ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_vi006_la005ge_202308090034.nc', 'input/GK2A_AMI_L1B_LA/gk2a_ami_le1b_wv073_la020ge_202308090034.nc']
scn = Scene(filenames = sat_files, reader='ami_l1b')

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='ami_l1b')
      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['IR133'].area

area_info
scn.load(["natural_color"])
rs = scn['IR133'].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')