@@ -110,11 +110,19 @@ def get_grid_coords(dt, scan_mode):
110110 """
111111 attrs = decode_string (dt .attrs ["FileHeader" ])
112112 start_time = attrs ["StartGranuleDateTime" ][:- 1 ] # 2016-03-09T10:30:00.000Z
113- # end_time = attrs["StopGranuleDateTime"][:-1] # 2003-05-01T23:59:59.999Z
114- time_interval = attrs ["TimeInterval" ]
115- time_delta = get_time_delta_from_time_interval (time_interval )
116- start_time = np .array ([start_time ]).astype ("M8[ns]" )
117- end_time = start_time + time_delta
113+ end_time = attrs .get ("StopGranuleDateTime" , "" )[:- 1 ] # 2003-05-01T23:59:59.999Z
114+ time_interval = attrs .get ("TimeInterval" , "" )
115+ if time_interval in {"ORBIT" , "" }:
116+ start_time = np .array ([start_time ]).astype ("M8[ns]" )
117+ end_time = np .array ([end_time ]).astype ("M8[ns]" )
118+ elif time_interval == "MONTH" :
119+ end_time = pd .to_datetime (start_time ) + pd .DateOffset (months = 1 )
120+ start_time = np .array ([start_time ]).astype ("M8[ns]" )
121+ end_time = np .array ([end_time ]).astype ("M8[ns]" )
122+ else :
123+ time_delta = get_time_delta_from_time_interval (time_interval )
124+ start_time = np .array ([start_time ]).astype ("M8[ns]" )
125+ end_time = start_time + time_delta
118126
119127 # Define time coordinate
120128 time = xr .DataArray (end_time , dims = "time" )
@@ -128,18 +136,24 @@ def get_grid_coords(dt, scan_mode):
128136 time_bnds = np .concatenate ((start_time , end_time )).reshape (1 , 2 )
129137 time_bnds = xr .DataArray (time_bnds , dims = ("time" , "nv" ))
130138
139+ # Retrieve coordinates
140+ lon = dt [scan_mode ].get ("lon" )
141+ lat = dt [scan_mode ].get ("lat" )
142+
131143 # Define dictionary with coordinates (DataArray)
132- return {
144+ coords_dict = {
133145 "time" : time ,
134- "lon" : dt [ scan_mode ][ " lon" ] ,
135- "lat" : dt [ scan_mode ][ " lat" ] ,
146+ "lon" : lon ,
147+ "lat" : lat ,
136148 "time_bnds" : time_bnds ,
137149 }
150+ coords_dict = {k : v for k , v in coords_dict .items () if v is not None }
151+ return coords_dict
138152
139153
140154def get_coords (dt , scan_mode ):
141155 """Get coordinates from GPM objects."""
142- return get_grid_coords (dt , scan_mode ) if scan_mode in ["Grid" ] else get_orbit_coords (dt , scan_mode )
156+ return get_grid_coords (dt , scan_mode ) if scan_mode in ["Grid" , "GRID" , "" ] else get_orbit_coords (dt , scan_mode )
143157
144158
145159def _subset_dict_by_dataset (ds , dictionary ):
0 commit comments