Skip to content

Commit

Permalink
Update Develop-ref after #1422 (#1423)
Browse files Browse the repository at this point in the history
Co-authored-by: George McCabe <23407799+georgemccabe@users.noreply.github.com>
Co-authored-by: Julie Prestopnik <jpresto@seneca.rap.ucar.edu>
Co-authored-by: TaraJensen <jensen@ucar.edu>
Co-authored-by: Mrinal Biswas <biswas@ucar.edu>
Co-authored-by: Hank Fisher <fisherh@kiowa.rap.ucar.edu>
Co-authored-by: Minna Win <minnawin@kiowa.rap.ucar.edu>
Co-authored-by: bikegeek <3753118+bikegeek@users.noreply.github.com>
Co-authored-by: Christina Kalb <kalb@kiowa.rap.ucar.edu>
Co-authored-by: johnhg <johnhg@ucar.edu>
Co-authored-by: bikegeek <minnawin@ucar.edu>
Co-authored-by: Christina Kalb <kalb@ucar.edu>
Co-authored-by: lisagoodrich <33230218+lisagoodrich@users.noreply.github.com>
Co-authored-by: jprestop <jpresto@ucar.edu>
Co-authored-by: j-opatz <59586397+j-opatz@users.noreply.github.com>
Co-authored-by: j-opatz <jopatz@ucar.edu>
Co-authored-by: Hank Fisher <fisherh@ucar.edu>
  • Loading branch information
16 people authored Feb 8, 2022
1 parent 4509636 commit 9fdb765
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Grid-Stat: 6hr PQPF Probability Verification
==========================================================================
model_applications/precipitation/GridStat_fcstHRRR
model_applications/precipitation/GridStat_fcstHRRR-TLE
_obsStgIV_GRIB.conf
"""
Expand Down
86 changes: 79 additions & 7 deletions internal_tests/pytests/ensemble_stat/test_ensemble_stat_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
time_fmt = '%Y%m%d%H'
run_times = ['2005080700', '2005080712']

def set_minimum_config_settings(config):
def set_minimum_config_settings(config, set_fields=True):
# set config variables to prevent command from running and bypass check
# if input files actually exist
config.set('config', 'DO_NOT_RUN_EXE', True)
Expand Down Expand Up @@ -59,12 +59,84 @@ def set_minimum_config_settings(config):
'{OUTPUT_BASE}/EnsembleStat/output')
config.set('config', 'ENSEMBLE_STAT_OUTPUT_TEMPLATE', '{valid?fmt=%Y%m%d%H}')

config.set('config', 'FCST_VAR1_NAME', fcst_name)
config.set('config', 'FCST_VAR1_LEVELS', fcst_level)
config.set('config', 'OBS_VAR1_NAME', obs_name)
config.set('config', 'OBS_VAR1_LEVELS', obs_level)
config.set('config', 'ENS_VAR1_NAME', ens_name)
config.set('config', 'ENS_VAR1_LEVELS', ens_level)
if set_fields:
config.set('config', 'FCST_VAR1_NAME', fcst_name)
config.set('config', 'FCST_VAR1_LEVELS', fcst_level)
config.set('config', 'OBS_VAR1_NAME', obs_name)
config.set('config', 'OBS_VAR1_LEVELS', obs_level)
config.set('config', 'ENS_VAR1_NAME', ens_name)
config.set('config', 'ENS_VAR1_LEVELS', ens_level)

@pytest.mark.parametrize(
'config_overrides, env_var_values', [
# 0 : 3 ens, 1 fcst, 1 obs
({'ENS_VAR1_NAME': 'ens_name_1',
'ENS_VAR1_LEVELS': 'ENS_LEVEL_1',
'ENS_VAR2_NAME': 'ens_name_2',
'ENS_VAR2_LEVELS': 'ENS_LEVEL_2A, ENS_LEVEL_2B',
'FCST_VAR1_NAME': 'fcst_name_1',
'FCST_VAR1_LEVELS': 'FCST_LEVEL_1',
'OBS_VAR1_NAME': 'obs_name_1',
'OBS_VAR1_LEVELS': 'OBS_LEVEL_1',
},
{'METPLUS_ENS_FIELD': ('field = ['
'{ name="ens_name_1"; level="ENS_LEVEL_1"; },'
'{ name="ens_name_2"; level="ENS_LEVEL_2A"; },'
'{ name="ens_name_2"; level="ENS_LEVEL_2B"; }'
'];'),
'METPLUS_FCST_FIELD': ('field = ['
'{ name="fcst_name_1"; level="FCST_LEVEL_1"; }'
'];'),
'METPLUS_OBS_FIELD': ('field = ['
'{ name="obs_name_1"; level="OBS_LEVEL_1"; }'
'];'),
}),
# 1 : no ens, 1 fcst, 1 obs -- use fcst for ens
({'FCST_VAR1_NAME': 'fcst_name_1',
'FCST_VAR1_LEVELS': 'FCST_LEVEL_1',
'OBS_VAR1_NAME': 'obs_name_1',
'OBS_VAR1_LEVELS': 'OBS_LEVEL_1',
},
{'METPLUS_ENS_FIELD': ('field = ['
'{ name="fcst_name_1"; level="FCST_LEVEL_1"; }'
'];'),
'METPLUS_FCST_FIELD': ('field = ['
'{ name="fcst_name_1"; level="FCST_LEVEL_1"; }'
'];'),
'METPLUS_OBS_FIELD': ('field = ['
'{ name="obs_name_1"; level="OBS_LEVEL_1"; }'
'];'),
}),
]
)
def test_ensemble_stat_field_info(metplus_config, config_overrides,
env_var_values):

config = metplus_config()

set_minimum_config_settings(config, set_fields=False)

# set config variable overrides
for key, value in config_overrides.items():
config.set('config', key, value)

wrapper = EnsembleStatWrapper(config)
assert wrapper.isOK

all_cmds = wrapper.run_all_times()

assert len(all_cmds) == 2

actual_env_vars = all_cmds[0][1]
for key, expected_value in env_var_values.items():
match = next((item for item in actual_env_vars if
item.startswith(key)), None)
assert match is not None
actual_value = match.split('=', 1)[1]
assert actual_value == expected_value
print(f"ACTUAL : {actual_value}")
print(f"EXPECTED: {expected_value}")


@pytest.mark.parametrize(
'config_overrides, env_var_values', [
Expand Down
2 changes: 1 addition & 1 deletion internal_tests/use_cases/all_use_cases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Category: precipitation
4::GridStat_fcstHRRR-TLE_obsStgIV_GRIB:: model_applications/precipitation/GridStat_fcstHRRR-TLE_obsStgIV_GRIB.conf
5::MTD_fcstHRRR-TLE_FcstOnly_RevisionSeries_GRIB:: model_applications/precipitation/MTD_fcstHRRR-TLE_FcstOnly_RevisionSeries_GRIB.conf
6::MTD_fcstHRRR-TLE_obsMRMS:: model_applications/precipitation/MTD_fcstHRRR-TLE_obsMRMS.conf

7::EnsembleStat_fcstWOFS_obsWOFS:: model_applications/precipitation/EnsembleStat_fcstWOFS_obsWOFS.conf::

Category: s2s
0::GridStat_SeriesAnalysis_fcstNMME_obsCPC_seasonal_forecast:: model_applications/s2s/GridStat_SeriesAnalysis_fcstNMME_obsCPC_seasonal_forecast.conf:: netcdf4_env
Expand Down
4 changes: 4 additions & 0 deletions metplus/wrappers/ensemble_stat_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ def run_at_time_all_fields(self, time_info):
self.log_error("Could not build field info for fcst, obs, or ens")
return

# if ens is not set, use fcst
if not ens_field:
ens_field = fcst_field

self.format_field('FCST', fcst_field)
self.format_field('OBS', obs_field)
self.format_field('ENS', ens_field)
Expand Down

0 comments on commit 9fdb765

Please sign in to comment.