Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to chgres_cube from integration with SRW #610

Merged
merged 13 commits into from
Oct 14, 2024
25 changes: 13 additions & 12 deletions docs/shared/chgres_cube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@ chgres_cube:
namelist:
update_values:
config:
fix_dir_target_grid: /path/to/fix_lam
WeirAE marked this conversation as resolved.
Show resolved Hide resolved
mosaic_file_target_grid: C432.mosaic.halo4.nc
orog_dir_target_grid: /path/to/fix_lam
orog_files_target_grid: C432.oro_data.tile7.halo4.nc
vcoord_file_target_grid: /path/to/global_hyblev.l65.txt
varmap_file: /path/to/varmap_table
data_dir_input_grid: /path/to/data/{{ cycle.strftime('%Y%M%d%H') }}
grib2_file_input_grid: a.file.gb2
atm_files_input_grid: atm.t{{cycle.strftime('%H') }}z.nc
convert_atm: true
convert_nst: true
convert_sfc: true
sfc_files_input_grid: sfc.t{{cycle.strftime('%H') }}z.nc
cycle_day: !int "{{ cycle.strftime('%d') }}"
cycle_hour: !int "{{ cycle.strftime('%H') }}"
cycle_mon: !int "{{ cycle.strftime('%m') }}"
data_dir_input_grid: /path/to/data/{{ cycle.strftime('%Y%M%d%H') }}
fix_dir_target_grid: /path/to/fixdir
grib2_file_input_grid: a.file.gb2
mosaic_file_target_grid: /path/to/mosaic/C432.mosaic.halo4.nc
WeirAE marked this conversation as resolved.
Show resolved Hide resolved
orog_files_target_grid: /path/to/orog/C432.oro_data.tile7.halo4.nc
sfc_files_input_grid: sfc.t{{cycle.strftime('%H') }}z.nc
varmap_file: /path/to/varmap_table
vcoord_file_target_grid: /path/to/global_hyblev.l65.txt
validate: true
WeirAE marked this conversation as resolved.
Show resolved Hide resolved
convert_atm: true
convert_nst: false
convert_sfc: true
validate: true
rundir: /path/to/dir
platform:
account: me
Expand Down
18 changes: 13 additions & 5 deletions src/uwtools/drivers/chgres_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,26 @@ def namelist_file(self):
input_files.append(base_file)
if update_values := namelist.get(STR.updatevalues):
WeirAE marked this conversation as resolved.
Show resolved Hide resolved
config_files = update_values["config"]
for k in ["mosaic_file_target_grid", "vcoord_file_target_grid"]:
input_files.append(config_files[k])
file_keys = ["mosaic_file_target_grid", "orog_files_target_grid"]
dir_keys = ["fix_dir_target_grid", "orog_dir_target_grid"]
for file_key, dir_key in zip(file_keys, dir_keys):
WeirAE marked this conversation as resolved.
Show resolved Hide resolved
full_path = Path(config_files[dir_key]) / config_files[file_key]
input_files.append(full_path)
for k in [
"atm_core_files_input_grid",
"atm_files_input_grid",
christinaholtNOAA marked this conversation as resolved.
Show resolved Hide resolved
"atm_tracer_files_input_grid",
"grib2_file_input_grid",
"sfc_files_input_grid",
]:
full_path = Path(config_files[k]) / config_files["data_dir_input_grid"]
WeirAE marked this conversation as resolved.
Show resolved Hide resolved
input_files.append(full_path)
for k in [
"atm_core_files_input_grid",
"atm_tracer_files_input_grid",
"nst_files_input_grid",
"orog_files_input_grid",
WeirAE marked this conversation as resolved.
Show resolved Hide resolved
"orog_files_target_grid",
"sfc_files_input_grid",
"varmap_file",
"vcoord_file_target_grid",
]:
if k in config_files:
v = config_files[k]
Expand Down
10 changes: 2 additions & 8 deletions src/uwtools/resources/jsonschema/chgres-cube.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@
"update_values": {
"properties": {
"config": {
"additionalProperties": {
"type": [
"array",
"boolean",
"number",
"string"
]
},
"additionalProperties": false,
"properties": {
"atm_core_files_input_grid": {
"items": {
Expand Down Expand Up @@ -92,6 +85,7 @@
},
"external_model": {
"enum": [
"FV3GFS",
WeirAE marked this conversation as resolved.
Show resolved Hide resolved
"GFS",
"HRRR",
"NAM",
Expand Down
23 changes: 12 additions & 11 deletions src/uwtools/tests/drivers/test_chgres_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,22 @@ def config(tmp_path):
"namelist": {
"update_values": {
"config": {
"atm_core_files_input_grid": [str(afile), str(afile)],
"fix_dir_target_grid": "/path/to/dir",
"mosaic_file_target_grid": str(afile),
"orog_dir_target_grid": "/path/to/dir",
"orog_files_target_grid": str(afile),
"vcoord_file_target_grid": str(afile),
"varmap_file": str(afile),
"data_dir_input_grid": str(afile),
"atm_files_input_grid": str(afile),
"atm_tracer_files_input_grid": str(afile),
"atm_weight_file": str(afile),
"sfc_files_input_grid": str(afile),
"grib2_file_input_grid": str(afile),
"tracers_input": [str(afile), str(afile)],
"tracers": [str(afile), str(afile)],
"convert_atm": True,
"data_dir_input_grid": str(afile),
"input_type": "gaussian_nemsio",
"external_model": "GFS",
"fix_dir_target_grid": "/path/to/dir",
"geogrid_file_input_grid": str(afile),
"grib2_file_input_grid": str(afile),
"mosaic_file_input_grid": str(afile),
"mosaic_file_target_grid": str(afile),
"sfc_files_input_grid": str(afile),
"varmap_file": str(afile),
"vcoord_file_target_grid": str(afile),
WeirAE marked this conversation as resolved.
Show resolved Hide resolved
}
},
"validate": True,
Expand Down
6 changes: 3 additions & 3 deletions src/uwtools/tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,8 @@ def test_schema_chgres_cube_namelist_update_values(chgres_cube_config, chgres_cu
# Some entries are required:
for key in ["mosaic_file_target_grid", "vcoord_file_target_grid"]:
assert "is a required property" in errors(with_del(config, key))
# Additional entries of namelist-compatible types are permitted:
for val in [[1, 2, 3], True, 42, 3.14, "bar"]:
assert not errors(with_set(config, val, "foo"))
# Additional top-level keys are not allowed:
assert "Additional properties are not allowed" in errors({**config, "foo": "bar"})
# Namelist values must be of the correct type:
# boolean:
for key in [
Expand Down Expand Up @@ -590,6 +589,7 @@ def test_schema_chgres_cube_namelist_update_values(chgres_cube_config, chgres_cu
]:
assert "is not of type 'array', 'string'\n" in errors(with_set(config, None, key))
assert "is not of type 'string'\n" in errors(with_set(config, [1, 2, 3], key))
assert not errors(with_set(config, ["foo", "bar", "baz"], key))


# esg-grid
Expand Down
Loading