Skip to content

Commit 39429c5

Browse files
committed
Create function for putting together METplus call
Refs: NOAA-EMC#1
1 parent e88c3a0 commit 39429c5

File tree

2 files changed

+38
-21
lines changed

2 files changed

+38
-21
lines changed

ush/global_det/global_det_atmos_stats_grid2grid_create_job_scripts.py

+17-21
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,6 @@
4444
[VERIF_CASE_STEP_abbrev+'_precip_var_list'] \
4545
.split(' '))
4646

47-
# Set up METplus job command dictionary
48-
metplus_cmd_prefix = (
49-
os.path.join(METPLUS_PATH, 'ush', 'run_metplus.py')
50-
+' -c '+os.path.join(PARMevs, 'metplus_config', 'machine.conf')
51-
+' -c '+os.path.join(PARMevs, 'metplus_config', COMPONENT,
52-
RUN+'_'+VERIF_CASE, STEP)
53-
+'/'
54-
)
55-
5647
VERIF_CASE_STEP = VERIF_CASE+'_'+STEP
5748
start_date_dt = datetime.datetime.strptime(start_date, '%Y%m%d')
5849
end_date_dt = datetime.datetime.strptime(end_date, '%Y%m%d')
@@ -64,8 +55,9 @@
6455
'means': {},
6556
'ozone': {},
6657
'precip': {'24hrCCPA': {'env': {},
67-
'commands': [metplus_cmd_prefix
68-
+'PCPCombine_obs24hrCCPA.conf']}},
58+
'commands': [gda_util.metplus_command(
59+
'PCPCombine_obs24hrCCPA.conf'
60+
)]}},
6961
'sea_ice': {},
7062
'snow': {},
7163
'sst': {},
@@ -77,21 +69,25 @@
7769
'precip': {'24hrAccum': {'env': {'valid_hr': '12',
7870
'MODEL_template': ('{MODEL}.precip.'
7971
+'{init?fmt=%Y%m%d%H}.'
80-
+'f{lead?fmt=%HHH}')},
81-
'commands': [metplus_cmd_prefix
82-
+'PCPCombine_fcstGLOBAL_DET_'
83-
+'24hrAccum_precip.conf']}},
72+
+'f{lead?fmt=%HHH}')
73+
},
74+
'commands': [gda_util.metplus_command(
75+
'PCPCombine_fcstGLOBAL_DET_'
76+
+'24hrAccum_precip.conf'
77+
)]}},
8478
'sea_ice': {},
8579
'snow': {'24hrAccum_WaterEqv': {'env': {'valid_hr': '12',
8680
'MODEL_var': 'WEASD'},
87-
'commands': [metplus_cmd_prefix
88-
+'PCPCombine_fcstGLOBAL_DET_'
89-
+'24hrAccum_snow.conf']},
81+
'commands': [gda_util.metplus_command(
82+
'PCPCombine_fcstGLOBAL_'
83+
+'DET_24hrAccum_snow.conf'
84+
)]},
9085
'24hrAccum_Depth': {'env': {'valid_hr': '12',
9186
'MODEL_var': 'SNOD'},
92-
'commands': [metplus_cmd_prefix
93-
+'PCPCombine_fcstGLOBAL_DET_'
94-
+'24hrAccum_snow.conf']}},
87+
'commands': [gda_util.metplus_command(
88+
'PCPCombine_fcstGLOBAL_'
89+
+'DET_24hrAccum_snow.conf'
90+
)]}},
9591
'sst': {},
9692
}
9793

ush/global_det/global_det_atmos_util.py

+21
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,27 @@ def run_shell_command(command):
2525
print("ERROR: "+' '.join(run_command.args)+" gave return code "
2626
+str(run_command.returncode))
2727

28+
def metplus_command(conf_file_name):
29+
"""! Write out full call to METplus
30+
31+
Args:
32+
conf_file_name - METplus conf file name (string)
33+
34+
Returns:
35+
metplus_cmd - full call to METplus (string)
36+
37+
"""
38+
run_metplus = os.path.join(os.environ['METPLUS_PATH'], 'ush',
39+
'run_metplus.py')
40+
machine_conf = os.path.join(os.environ['PARMevs'], 'metplus_config',
41+
'machine.conf')
42+
conf_file = os.path.join(os.environ['PARMevs'], 'metplus_config',
43+
os.environ['COMPONENT'],
44+
os.environ['RUN']+'_'+os.environ['VERIF_CASE'],
45+
os.environ['STEP'], conf_file_name)
46+
metplus_cmd = run_metplus+' -c '+machine_conf+' -c '+conf_file
47+
return metplus_cmd
48+
2849
def check_file_exists_size(file_name):
2950
"""! Checks to see if file exists and has size greater than 0
3051

0 commit comments

Comments
 (0)