Skip to content

Commit 8346359

Browse files
authored
Add flexibility for model component names (#6)
* Make the rmse writer function more general The CIME SystemTest pgn.py will write the `init_model` variable so that the initial condition file template can be adjusted as needed. This is used in `rmse_writer` to send output to comp_cld.nc * Add model component to arguments This will add the command line / config argument for the model component so that the input file template can be adjusted from the json config or command line args, so this is adaptable to E3SM and CESM * Bump version number * Pin LIVVkit version number
1 parent fa71523 commit 8346359

File tree

5 files changed

+20
-16
lines changed

5 files changed

+20
-16
lines changed

evv4esm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
from __future__ import absolute_import, division, print_function, unicode_literals
3131

32-
__version_info__ = (0, 2, 3)
32+
__version_info__ = (0, 2, 4)
3333
__version__ = '.'.join(str(vi) for vi in __version_info__)
3434

3535
PASS_COLOR = '#389933'

evv4esm/extensions/ks.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ def parse_args(args=None):
123123
default=os.getcwd(),
124124
help='Image output location.')
125125

126+
parser.add_argument('--component',
127+
default='eam',
128+
help='Model component name (e.g. eam, cam, ...)')
129+
126130
args, _ = parser.parse_known_args(args)
127131

128132
# use config file arguments, but override with command line arguments
@@ -199,8 +203,8 @@ def case_files(args):
199203
key1 += '1'
200204
key2 += '2'
201205

202-
f_sets = {key1: e3sm.component_monthly_files(args.test_dir, 'eam', args.ninst),
203-
key2: e3sm.component_monthly_files(args.ref_dir, 'eam', args.ninst)}
206+
f_sets = {key1: e3sm.component_monthly_files(args.test_dir, args.component, args.ninst),
207+
key2: e3sm.component_monthly_files(args.ref_dir, args.component, args.ninst)}
204208

205209
for key in f_sets:
206210
# Require case files for at least the last 12 months.

evv4esm/extensions/pg.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def _sub2instance(initial_condition, perturbation_index, total_perturbations):
109109
return instance
110110

111111

112-
def rmse_writer(file_name, rmse, perturbation_names, perturbation_variables, init_file_template):
112+
def rmse_writer(file_name, rmse, perturbation_names, perturbation_variables, init_file_template, model_name):
113113
"""
114114
Opens and writes a netcdf file for PGE curves
115115
This function is here purely to avoid duplicate
@@ -139,7 +139,7 @@ def rmse_writer(file_name, rmse, perturbation_names, perturbation_variables, ini
139139

140140
for icond in range(0, ninit):
141141
# NOTE: Zero vs One based indexing
142-
nc_init_cond[icond] = init_file_template.format('eam', 'i', icond+1)
142+
nc_init_cond[icond] = init_file_template.format(model_name, 'i', icond+1)
143143

144144

145145
def variables_rmse(ifile_test, ifile_cntl, var_list, var_pefix=''):
@@ -214,13 +214,13 @@ def main(args):
214214
continue
215215
iinst_ctrl = _sub2instance(icond, 0, nprt)
216216
ifile_ctrl = os.path.join(args.ref_dir,
217-
args.instance_file_template.format('', iinst_ctrl, '_woprt'))
217+
args.instance_file_template.format('', args.component, iinst_ctrl, '_woprt'))
218218
# logger.debug("PGN_INFO:CNTL_TST:" + ifile_cntl)
219219

220220
iinst_test = _sub2instance(icond, iprt, nprt)
221221
ifile_test = os.path.join(args.test_dir,
222222
args.instance_file_template.format(
223-
args.test_case + '.', iinst_test, '_' + prt_name))
223+
args.test_case + '.', args.component, iinst_test, '_' + prt_name))
224224
# logger.debug("PGN_INFO:TEST_TST:" + ifile_test)
225225

226226
prt_rmse[prt_name] = variables_rmse(ifile_test, ifile_ctrl, args.variables, 't_')
@@ -231,7 +231,7 @@ def main(args):
231231
comp_rmse = np.reshape(rmse.RMSE.values, (args.ninit, nprt-1, nvar))
232232

233233
rmse_writer(os.path.join(args.test_dir, 'comp_cld.nc'),
234-
comp_rmse, args.perturbations.keys(), args.variables, args.init_file_template)
234+
comp_rmse, args.perturbations.keys(), args.variables, args.init_file_template, args.init_model)
235235

236236
details = OrderedDict()
237237
with Dataset(os.path.join(args.ref_dir, args.pge_cld)) as ref_cld:

evv4esm/extensions/tsc.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,18 +163,18 @@ def main(args):
163163
args.test_case += '1'
164164
args.ref_case += '2'
165165

166-
file_search_glob = '{d}/*eam_????.h0.0001-01-01-?????.nc.{s}'
166+
file_search_glob = '{d}/*{c}_????.h0.0001-01-01-?????.nc.{s}'
167167
truth_ens = {instance: list(files) for instance, files in groupby(
168-
sorted(glob.glob(file_search_glob.format(d=args.ref_dir, s='DT0001'))),
169-
key=lambda f: e3sm.component_file_instance('eam', f))}
168+
sorted(glob.glob(file_search_glob.format(d=args.ref_dir, c=args.component, s='DT0001'))),
169+
key=lambda f: e3sm.component_file_instance(args.baseline_component, f))}
170170

171171
ref_ens = {instance: list(files) for instance, files in groupby(
172-
sorted(glob.glob(file_search_glob.format(d=args.ref_dir, s='DT0002'))),
173-
key=lambda f: e3sm.component_file_instance('eam', f))}
172+
sorted(glob.glob(file_search_glob.format(d=args.ref_dir, c=args.component, s='DT0002'))),
173+
key=lambda f: e3sm.component_file_instance(args.baseline_component, f))}
174174

175175
test_ens = {instance: list(files) for instance, files in groupby(
176-
sorted(glob.glob(file_search_glob.format(d=args.test_dir, s='DT0002'))),
177-
key=lambda f: e3sm.component_file_instance('eam', f))}
176+
sorted(glob.glob(file_search_glob.format(d=args.test_dir, c=args.component, s='DT0002'))),
177+
key=lambda f: e3sm.component_file_instance(args.component, f))}
178178

179179
# So, we want a pandas dataframe that will have the columns :
180180
# (test/ref, ensemble, seconds, l2_global, l2_land, l2_ocean)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
'numpy',
8080
'scipy',
8181
'pandas',
82-
'livvkit',
82+
'livvkit==2.1.6',
8383
'netCDF4',
8484
'matplotlib',
8585
'pybtex',

0 commit comments

Comments
 (0)