Skip to content

Commit

Permalink
per #1910, fix bug that sets {level?fmt=%2H} to 00 in the forecast in…
Browse files Browse the repository at this point in the history
…put template for EnsembleStat
  • Loading branch information
georgemccabe committed Nov 2, 2022
1 parent 9daac01 commit 82c25ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
11 changes: 8 additions & 3 deletions metplus/wrappers/command_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,8 @@ def find_file_in_window(self, level, data_type, time_info, mandatory=True,

return out

def find_input_files_ensemble(self, time_info, fill_missing=True):
def find_input_files_ensemble(self, time_info, fill_missing=True,
var_info=None):
"""! Get a list of all input files and optional control file.
Warn and remove control file if found in ensemble list. Ensure that
if defined, the number of ensemble members (N_MEMBERS) corresponds to
Expand All @@ -836,12 +837,15 @@ def find_input_files_ensemble(self, time_info, fill_missing=True):
@param fill_missing If True, fill list of files with MISSING so
that number of files matches number of expected members. Defaults
to True.
@param var_info optional dictionary with field information used to
set level
@returns True on success
"""

# get control file if requested
if self.c_dict.get('CTRL_INPUT_TEMPLATE'):
ctrl_file = self.find_data(time_info, data_type='CTRL')
ctrl_file = self.find_data(time_info, data_type='CTRL',
var_info=var_info)

# return if requested control file was not found
if not ctrl_file:
Expand All @@ -863,7 +867,8 @@ def find_input_files_ensemble(self, time_info, fill_missing=True):
return True

# get list of ensemble files to process
input_files = self.find_model(time_info, return_list=True)
input_files = self.find_model(time_info, return_list=True,
var_info=var_info)
if not input_files:
self.log_error("Could not find any input files")
return False
Expand Down
22 changes: 11 additions & 11 deletions metplus/wrappers/ensemble_stat_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,27 +415,27 @@ def run_at_time_all_fields(self, time_info):
Args:
@param time_info dictionary containing timing information
"""
# parse optional var list for FCST and/or OBS fields
var_list = util.sub_var_list(self.c_dict['VAR_LIST_TEMP'],
time_info)

# if empty var list for FCST/OBS, use None as first var, else use first var in list
first_var_info = None
if var_list:
first_var_info = var_list[0]

# get ensemble model files
# do not fill file list with missing if ens_member_ids is used
fill_missing = not self.env_var_dict.get('METPLUS_ENS_MEMBER_IDS')
if not self.find_input_files_ensemble(time_info,
fill_missing=fill_missing):
fill_missing=fill_missing,
var_info=first_var_info):
return

# parse var list for ENS fields
ensemble_var_list = util.sub_var_list(self.c_dict['ENS_VAR_LIST_TEMP'],
time_info)

# parse optional var list for FCST and/or OBS fields
var_list = util.sub_var_list(self.c_dict['VAR_LIST_TEMP'],
time_info)

# if empty var list for FCST/OBS, use None as first var, else use first var in list
if not var_list:
first_var_info = None
else:
first_var_info = var_list[0]

# get point observation file if requested
if self.c_dict['OBS_POINT_INPUT_TEMPLATE']:
point_obs_path = self.find_data(time_info, first_var_info, 'OBS_POINT')
Expand Down

0 comments on commit 82c25ae

Please sign in to comment.