From b84d9c185552ed2dfd29e625d6ab944929a822ac Mon Sep 17 00:00:00 2001 From: Patrik Bohlinger Date: Thu, 25 Jan 2024 15:05:02 +0100 Subject: [PATCH] started to move loading satellite_dict to method level --- wavy/satellite_module.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/wavy/satellite_module.py b/wavy/satellite_module.py index 60ae0e4b..d383c5da 100755 --- a/wavy/satellite_module.py +++ b/wavy/satellite_module.py @@ -64,7 +64,7 @@ # read yaml config files: region_dict = load_or_default('region_cfg.yaml') model_dict = load_or_default('model_cfg.yaml') -satellite_dict = load_or_default('satellite_cfg.yaml') +#satellite_dict = load_or_default('satellite_cfg.yaml') variable_def = load_or_default('variable_def.yaml') # --- global functions ------------------------------------------------# @@ -212,10 +212,9 @@ def _get_files(self, dict_for_sub=None, path=None, wavy_path=None): try: # create local path for each time path_template = \ - satellite_dict[self.nID]['wavy_input'].get( - 'src_tmplt') + self.cfg.wavy_input.get('src_tmplt') strsublst = \ - satellite_dict[self.nID]['wavy_input'].get('strsub') + self.cfg.wavy_input.get('strsub') subdict = \ make_subdict(strsublst, class_object_dict=dict_for_sub) @@ -302,7 +301,8 @@ def list_input_files(self, show=False, **kwargs): print(str(int(len(pathlst))) + " valid files found") print('source template:', - satellite_dict[self.nID]['wavy_input']['src_tmplt']) + #satellite_dict[self.nID]['wavy_input']['src_tmplt']) + self.cfg.wavy_input['src_tmplt']) if show is True: print(" ") print(pathlst) @@ -438,9 +438,13 @@ def _enforce_longitude_format(self): def _enforce_meteorologic_convention(self): new = deepcopy(self) ncvars = list(new.vars.variables) + #for ncvar in ncvars: + # if ('convention' in satellite_dict[new.nID].keys() and + # satellite_dict[new.nID]['convention'] == 'oceanographic'): + for ncvar in ncvars: - if ('convention' in satellite_dict[new.nID].keys() and - satellite_dict[new.nID]['convention'] == 'oceanographic'): + if ('convention' in vars(new.cfg)['misc'].keys() and + vars(new.cfg)['misc']['convention'] == 'oceanographic'): print('Convert from oceanographic to meteorologic convention') new.vars[ncvar] =\ convert_meteorologic_oceanographic(new.vars[ncvar]) @@ -453,6 +457,7 @@ def _enforce_meteorologic_convention(self): def _change_varname_to_aliases(self): + satellite_dict = load_or_default('satellite_cfg.yaml') print(' changing variables to aliases') new = deepcopy(self) # variables @@ -501,6 +506,8 @@ def _change_stdvarname_to_cfname(self): def populate(self, **kwargs): print(" ### Read files and populate satellite_class object") + satellite_dict = load_or_default('satellite_cfg.yaml') + lst = self.list_input_files(**kwargs) self.pathlst = kwargs.get('pathlst', lst)