Skip to content

Commit

Permalink
Update reader for MODIS Level 3 files in CMG format.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonrp84 committed Nov 8, 2023
1 parent 9f9e34d commit 7c7d5fc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
16 changes: 16 additions & 0 deletions satpy/etc/readers/modis_l3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
reader:
name: modis_l3
short_name: MODIS l3
long_name: MODIS Level 3 (mcd43) data in HDF-EOS format
description: MODIS HDF-EOS L3 Reader
status: Beta
supports_fsspec: false
reader: !!python/name:satpy.readers.yaml_reader.FileYAMLReader
sensors: [modis]

file_types:
mcd43_cmg_hdf:
file_patterns:
- 'MCD43C{prod_type}.A{start_time:%Y%j}.{collection:03d}.{production_time:%Y%j%H%M%S}.hdf'
- 'M{platform_indicator:1s}D09CMG.A{start_time:%Y%j}.{collection:03d}.{production_time:%Y%j%H%M%S}.hdf'
file_reader: !!python/name:satpy.readers.modis_l3.ModisL3GriddedHDFFileHandler
13 changes: 12 additions & 1 deletion satpy/readers/modis_l3.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,22 @@ def __init__(self, filename, filename_info, filetype_info, **kwargs):
# Get the grid resolution
pos = gridname.rfind("_") + 1
pos2 = gridname.rfind("Deg")
self.resolution = float(gridname[pos:pos2])

# Some products don't have resolution listed.
if pos < 0 or pos2 < 0:
self.resolution = 360. / self.ncols
else:
self.resolution = float(gridname[pos:pos2])

upperleft = self.metadata["GridStructure"]["GRID_1"]["UpperLeftPointMtrs"]
lowerright = self.metadata["GridStructure"]["GRID_1"]["LowerRightMtrs"]

# For some reason, a few of the CMG products multiply their
# decimal degree extents by one million. This fixes it.
if lowerright[0] > 1e6:
upperleft = tuple(val / 1e6 for val in upperleft)
lowerright = tuple(val / 1e6 for val in lowerright)

self.area_extent = (upperleft[0], lowerright[1], lowerright[0], upperleft[1])


Expand Down

0 comments on commit 7c7d5fc

Please sign in to comment.