diff --git a/examples/process_swath_data/control_modis_l2.yaml b/examples/process_swath_data/control_modis_l2.yaml index 100cd940..c1bde6e3 100644 --- a/examples/process_swath_data/control_modis_l2.yaml +++ b/examples/process_swath_data/control_modis_l2.yaml @@ -7,13 +7,16 @@ analysis: debug: True obs_grid: + start_time: '2020-09-09' + end_time: '2020-09-11' + ntime: 72 nlat: 180 nlon: 360 obs: Terra_MODIS: # MOD04_L2.AYYYYDDD.HHMM.0XX.timestamp.hdf - debug: True + debug: False obs_type: 'sat_swath_clm' sat_type: 'modis_l2' filename: $HOME/Data/MODIS/Terra/C61/2020/*/MOD04_L2.*.hdf @@ -25,7 +28,7 @@ obs: Aqua_MODIS: # MYD04_L2.AYYYYDDD.HHMM.0XX.timestamp.hdf - debug: True + debug: False obs_type: 'sat_swath_clm' sat_type: 'modis_l2' filename: $HOME/Data/MODIS/Aqua/C61/2020/*/MYD04_L2.*.hdf diff --git a/examples/process_swath_data/process_modis_l2.py b/examples/process_swath_data/process_modis_l2.py index 1daf2e56..7c22cfaa 100644 --- a/examples/process_swath_data/process_modis_l2.py +++ b/examples/process_swath_data/process_modis_l2.py @@ -4,6 +4,8 @@ an.control = 'control_modis_l2.yaml' an.read_control() +an.generate_obs_grid() +print(an.obs_grid) for time_interval in an.time_intervals: @@ -11,5 +13,5 @@ an.open_obs(time_interval=time_interval) - for obs in an.obs: - print(an.obs[obs].obj) + # for obs in an.obs: + # print(an.obs[obs].obj) diff --git a/melodies_monet/driver.py b/melodies_monet/driver.py index 02cb141f..c41d08cc 100644 --- a/melodies_monet/driver.py +++ b/melodies_monet/driver.py @@ -122,8 +122,6 @@ def __init__(self): self.variable_dict = None self.resample = None self.time_var = None - self.obs_grid = None - self.obs_edges = None def __repr__(self): return ( @@ -241,7 +239,7 @@ def rename_vars(self): self.obj = self.obj.rename({v:d['rename']}) self.variable_dict[d['rename']] = self.variable_dict.pop(v) - def open_sat_obs(self,time_interval=None): + def open_sat_obs(self, time_interval=None, control_dict=None): """Methods to opens satellite data observations. Uses in-house python code to open and load observations. Alternatively may use the satpy reader. @@ -302,15 +300,6 @@ def open_sat_obs(self,time_interval=None): print('something happened opening file:', e) return - def generate_obs_grid(self, control_dict=None): - from .util import grid_util - self.obs_grid, self.obs_edges = grid_util.generate_uniform_grid( - control_dict['obs_grid']['start'], - control_dict['obs_grid']['end'], - control_dict['obs_grid']['ntime'], - control_dict['obs_grid']['nlat'], - control_dict['obs_grid']['nlon']) - def filter_obs(self): """Filter observations based on filter_dict. @@ -663,6 +652,8 @@ def __init__(self): self.target_grid = None self.obs_regridders = None self.model_regridders = None + self.obs_grid = None + self.obs_edges = None def __repr__(self): return ( @@ -834,6 +825,15 @@ def setup_regridders(self): self.obs_regridders = regrid_util.setup_regridder(self.control_dict, config_group='obs') self.model_regridders = regrid_util.setup_regridder(self.control_dict, config_group='model') + def generate_obs_grid(self): + from .util import grid_util + self.obs_grid, self.obs_edges = grid_util.generate_uniform_grid( + self.control_dict['obs_grid']['start_time'], + self.control_dict['obs_grid']['end_time'], + self.control_dict['obs_grid']['ntime'], + self.control_dict['obs_grid']['nlat'], + self.control_dict['obs_grid']['nlon']) + def open_models(self, time_interval=None,load_files=True): """Open all models listed in the input yaml file and create a :class:`model` object for each of them, populating the :attr:`models` dict. @@ -969,7 +969,7 @@ def open_obs(self, time_interval=None, load_files=True): if load_files: if o.obs_type in ['sat_swath_sfc', 'sat_swath_clm', 'sat_grid_sfc',\ 'sat_grid_clm', 'sat_swath_prof']: - o.open_sat_obs(time_interval=time_interval) + o.open_sat_obs(time_interval=time_interval, control_dict=self.control_dict) else: o.open_obs(time_interval=time_interval, control_dict=self.control_dict) self.obs[o.label] = o