Skip to content

Commit

Permalink
started to move loading satellite_dict to method level
Browse files Browse the repository at this point in the history
  • Loading branch information
bohlinger committed Jan 25, 2024
1 parent 6e52582 commit b84d9c1
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions wavy/satellite_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------#
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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])
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit b84d9c1

Please sign in to comment.