Skip to content

Commit c2c7fa1

Browse files
committed
Hotfix: Get Met_AREAM2 from GCHP StateMet for mass tables
gcpy/benchmark/run_benchmark.py - For GCHP vs GCC mass tables: - Define a new variable "area_m2_file", which contains the path to the StateMet collection for GCHP (Dev) - Pass "area_m2_file" to make_benchmark_mass_tables via the "dev_met_extra" keyword - For GCHP vs. GCHP mass tables - Define a new variable "area_m2_file", which contains the path to the StateMet collection for the GCHP Dev output - Pass "area_m2_file" to make_benchmark_mass_tables via the "ref_met_extra" and "dev_met_extra" keywords gcpy/units.py - In convert_units.py - If the area variable is on the GCHP diagnostic grid, but the input data is on the GCHP checkpoint grid, call reshape_MAPL_CS to reshape the area to the GCHP checkpoint grid. This will prevent a broadcast error caused by differently shaped arrays. Signed-off-by: Bob Yantosca <yantosca@seas.harvard.edu>
1 parent b29dbc3 commit c2c7fa1

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5959
- Updated `make_benchmark_mass_tables` and `create_global_mass_table` to allow Ref and Dev to have different dates if so chosen
6060
- Updated `run_benchmark.py` to generate mass tables at start and end of the simulation
6161
- Updated `run_1yr_fullchem_benchmark.py` and `run_1yr_tt_benchmark.py` to generate mass tables at the 1st day of each month from Jan 2019 thru Jan 2020
62+
- Updated `run_benchmark.py` to take the `Met_AREAM2` field from the GCHP `StateMet` collection when computing mass tables for 1hr/1mon benchmarks
63+
- Updated routine `convert_units` to reshape the area variable tomatch input data on the GCHP checkpoint grid
6264

6365
### Fixed
6466
- Fixed grid area calculation scripts of `grid_area` in `gcpy/gcpy/cstools.py`

gcpy/benchmark/run_benchmark.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,15 @@ def run_benchmark_default(config):
12221222
if config["options"]["outputs"]["mass_table"]:
12231223
print("\n%%% Creating GCHP vs. GCC global mass tables %%%")
12241224

1225+
# Kludge, take the Met_AREAM2 variable at the end of the
1226+
# month from the StateMet collection for GCHP (Dev)
1227+
area_m2_file = get_filepath(
1228+
gchp_vs_gchp_devdir,
1229+
"StateMet",
1230+
gchp_end_dev_date,
1231+
is_gchp=True
1232+
)
1233+
12251234
# Filepaths and date strings for start of run
12261235
ref = get_filepath(
12271236
gchp_vs_gcc_refrstdir,
@@ -1257,6 +1266,7 @@ def run_benchmark_default(config):
12571266
ref_hdr_label=f"at {ref_date_str}",
12581267
dev_hdr_label=f"at {dev_date_str}",
12591268
subdst=dev_date_str,
1269+
dev_met_extra=area_m2_file,
12601270
)
12611271

12621272
# Filepaths and date strings for end of run
@@ -1294,6 +1304,7 @@ def run_benchmark_default(config):
12941304
ref_hdr_label=f"at {ref_date_str}",
12951305
dev_hdr_label=f"at {dev_date_str}",
12961306
subdst=dev_date_str,
1307+
dev_met_extra=area_m2_file,
12971308
)
12981309

12991310
# ==================================================================
@@ -1849,6 +1860,15 @@ def run_benchmark_default(config):
18491860
if config["options"]["outputs"]["mass_table"]:
18501861
print("\n%%% Creating GCHP vs. GCHP global mass tables %%%")
18511862

1863+
# Kludge, take the Met_AREAM2 variable at the end of the
1864+
# month from the StateMet collection for Dev
1865+
area_m2_file = get_filepath(
1866+
gchp_vs_gchp_devdir,
1867+
"StateMet",
1868+
gchp_end_dev_date,
1869+
is_gchp=True
1870+
)
1871+
18521872
# Filepaths and date strings for start of run
18531873
ref = get_filepath(
18541874
gchp_vs_gchp_refrstdir,
@@ -1887,6 +1907,8 @@ def run_benchmark_default(config):
18871907
ref_hdr_label=f"at {ref_date_str}",
18881908
dev_hdr_label=f"at {dev_date_str}",
18891909
subdst=dev_date_str,
1910+
ref_met_extra=area_m2_file,
1911+
dev_met_extra=area_m2_file,
18901912
)
18911913

18921914
# Filepaths and date string for end of run
@@ -1927,6 +1949,8 @@ def run_benchmark_default(config):
19271949
ref_hdr_label=f"at {ref_date_str}",
19281950
dev_hdr_label=f"at {dev_date_str}",
19291951
subdst=dev_date_str,
1952+
ref_met_extra=area_m2_file,
1953+
dev_met_extra=area_m2_file,
19301954
)
19311955

19321956
# ==================================================================

gcpy/units.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import numpy as np
88
import xarray as xr
99
import gcpy.constants as physconsts
10-
10+
from gcpy.cstools import is_cubed_sphere_diag_grid, is_cubed_sphere_rst_grid
11+
from gcpy.util import reshape_MAPL_CS
1112

1213
def adjust_units(units):
1314
"""
@@ -197,6 +198,13 @@ def convert_units(
197198
moles_C_per_mole_species = species_properties.get("MolecRatio")
198199
else:
199200
moles_C_per_mole_species = 1.0
201+
202+
# EDGE CASE: For GCHP vs GCHP mass tables, we often need to multiply
203+
# data taken from a GCHP checkpoint file by the surface area taken
204+
# from the StateMet History file. If this is the case, then reshape
205+
# the area array to the GCHP checkpoint grid before multiplication.
206+
if is_cubed_sphere_rst_grid(dr) and is_cubed_sphere_diag_grid(area_m2):
207+
area_m2 = reshape_MAPL_CS(area_m2)
200208

201209
# ==============================
202210
# Compute conversion factors

0 commit comments

Comments
 (0)