Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 36 additions & 11 deletions gcpy/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -713,20 +713,31 @@ def make_benchmark_conc_plots(
refds = reader(ref, drop_variables=gcon.skip_these_vars).load()
devds = reader(dev, drop_variables=gcon.skip_these_vars).load()

# Rename SpeciesConc_ to SpeciesConcVV_ for consistency with new
# naming introduced in GEOS-Chem 14.1.0
for v in refds.data_vars.keys():
if v.startswith('SpeciesConc_'):
spc = v.replace('SpeciesConc_', '')
refds = refds.rename({v: 'SpeciesConcVV_' + spc})
for v in devds.data_vars.keys():
if v.startswith('SpeciesConc_'):
spc = v.replace('SpeciesConc_', '')
devds = devds.rename({v: 'SpeciesConcVV_' + spc})

# -----------------------------------------------------------------
# Kludge, rename wrong variable name
if "SpeciesConcVV_PFE" in refds.data_vars.keys():
refds = refds.rename({"SpeciesConcVV_PFE": "SpeciesConcVV_pFe"})
if "SpeciesConcVV_PFE" in devds.data_vars.keys():
devds = devds.rename({"SpeciesConcVV_PFE": "SpeciesConcVV_pFe"})
# -----------------------------------------------------------------

if verbose:
print('\nPrinting refds (comparison ref)\n')
print(refds)
print('\nPrinting devds (comparison dev)\n')
print(devds)

# -----------------------------------------------------------------
# Kludge, rename wrong variable name
if "SpeciesConc_PFE" in refds.data_vars.keys():
refds = refds.rename({"SpeciesConc_PFE": "SpeciesConc_pFe"})
if "SpeciesConc_PFE" in devds.data_vars.keys():
devds = devds.rename({"SpeciesConc_PFE": "SpeciesConc_pFe"})
# -----------------------------------------------------------------

# Open met datasets if passed as arguments
refmetds = None
devmetds = None
Expand Down Expand Up @@ -835,7 +846,7 @@ def make_benchmark_conc_plots(
# ==================================================================
if not plot_by_spc_cat:
[refds, devds] = util.add_missing_variables(refds, devds)
var_prefix = 'SpeciesConc_'
var_prefix = 'SpeciesConcVV_'
varlist = [k for k in refds.data_vars.keys() if var_prefix in k]
varlist.sort()

Expand Down Expand Up @@ -900,14 +911,18 @@ def make_benchmark_conc_plots(
# FullChemBenchmark has lumped species (TransportTracers does not)
if "FullChem" in benchmark_type:
print("\nComputing lumped species for full chemistry benchmark")

print("-->Adding lumped species to ref dataset")
refds = util.add_lumped_species_to_dataset(refds)

print("-->Adding lumped species to dev dataset")
devds = util.add_lumped_species_to_dataset(devds)

if diff_of_diffs:
print("-->Adding lumped species to dev datasets")
second_refds = util.add_lumped_species_to_dataset(second_refds)
second_devds = util.add_lumped_species_to_dataset(second_devds)

util.archive_lumped_species_definitions(dst)
print("Lumped species computation complete.\n")

Expand All @@ -925,7 +940,10 @@ def make_benchmark_conc_plots(
[devds, second_devds] = util.add_missing_variables(devds, second_devds)

# Collection prefix
coll_prefix = collection.strip() + "_"
if "SpeciesConc" in collection:
coll_prefix = "SpeciesConcVV_"
else:
coll_prefix = collection.strip() + "_"

# ==================================================================
# Create the plots!
Expand Down Expand Up @@ -3402,6 +3420,13 @@ def make_benchmark_aerosol_tables(
drop_variables=gcon.skip_these_vars) # ,
# combine="nested", concat_dim="time")

# Rename SpeciesConc_ to SpeciesConcVV_ for consistency with new
# naming introduced in GEOS-Chem 14.1.0
for v in ds_spc.data_vars.keys():
if v.startswith('SpeciesConc_'):
spc = v.replace('SpeciesConc_', '')
ds_spc = ds_spc.rename({v: 'SpeciesConcVV_' + spc})

# Get troposphere mask
tropmask = get_troposphere_mask(ds_met)

Expand Down Expand Up @@ -3501,7 +3526,7 @@ def print_aerosol_metrics(data, species_list, filename, title, label):

# Whole-atmosphere and trop-only quantities [g]
# NOTE: DryDep is by nature trop-only
varname = "SpeciesConc_" + spc
varname = "SpeciesConcVV_" + spc
q[spc + "_f"] = ds_spc[varname].values * vv_to_Tg[spc]
q[spc + "_t"] = np.ma.masked_array(q[spc + "_f"], tropmask)

Expand Down
8 changes: 4 additions & 4 deletions gcpy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,8 @@ def add_bookmarks_to_pdf(
remove_prefix: str
Specifies a prefix to remove from each entry in varlist
when creating bookmarks. For example, if varlist has
a variable name "SpeciesConc_NO", and you specify
remove_prefix="SpeciesConc_", then the bookmark for
a variable name "SpeciesConcVV_NO", and you specify
remove_prefix="SpeciesConcVV_", then the bookmark for
that variable will be just "NO", etc.
verbose: bool
Set this flag to True to print extra informational output.
Expand Down Expand Up @@ -1168,7 +1168,7 @@ def add_lumped_species_to_dataset(
lspc_yaml="",
verbose=False,
overwrite=False,
prefix="SpeciesConc_",
prefix="SpeciesConcVV_",
):
"""
Function to calculate lumped species concentrations and add
Expand Down Expand Up @@ -1204,7 +1204,7 @@ def add_lumped_species_to_dataset(
also used to extract an existing dataarray in the dataset with
the correct size and dimensions to use during initialization of
new lumped species dataarrays.
Default value: "SpeciesConc_"
Default value: "SpeciesConcVV_"

Returns:
ds: xarray Dataset
Expand Down