gcpy.benchmark.modules.oh_metrics

Prints key metrics (e.g. global mean OH, MCF lifetime, and CH4 lifetimes) for a GEOS-Chem full-chemistry simulation or methane simulation.

Functions

combine_dataset([file_list])

Wrapper for xarray.open_mfdataset.

compute_oh_metrics(common_vars)

Computes the mass-weighted mean OH concentration, CH3CCl3 (aka MCF) lifetime w/r/t OH, and CH4 lifetime w/r/t OH.

global_mean_oh(data, airmass_kg, mw_oh_kg)

Computes the global mean OH concentration (1e5 molec cm-3).

init_common_vars(ref, refstr, dev, devstr, ...)

Returns a dictionary containing various quantities that need to be passed between methods.

lifetimes_wrt_oh(data, airmass_m)

Computes the lifetimes (in years) of CH4 and CH3CCl3 (aka MCF) against tropospheric OH.

make_benchmark_oh_metrics(ref, refstr, dev, ...)

Creates a text file containing metrics of global mean OH, MCF lifetime, and CH4 lifetime for benchmarking purposes.

print_metrics(common_vars, dst)

Prints the mass-weighted mean OH (full atmospheric column) from a GEOS-Chem simulation.

read_metrics_collection(files)

Reads data from all "Metrics" collection netCDF files into a single xarray Dataset.

total_airmass(data)

Computes the total airmass (in both kg and molec).

validate_metrics_collection(ds)

Determines if a Dataset contains variables for computing metrics from a CH4 simulation or a fullchem simulation.

write_to_file(f, title, ref, dev, absdiff, ...)

Internal routine used by print_metrics to write a specific quantity (mean OH, MCF lifetime, CH4 lifetime) to a file.

gcpy.benchmark.modules.oh_metrics.combine_dataset(file_list=None)[source]

Wrapper for xarray.open_mfdataset.

Parameters:

file_list (list, optional) – List of files to read.

Returns:

data – Object w/ “Metrics” collection data.

Return type:

xr.Dataset

gcpy.benchmark.modules.oh_metrics.validate_metrics_collection(ds)[source]

Determines if a Dataset contains variables for computing metrics from a CH4 simulation or a fullchem simulation.

Parameters:

ds (xr.Dataset) – Input dataset to validate.

Returns:

is_ch4_sim – True if the dataset contains all required variables.

Return type:

bool

gcpy.benchmark.modules.oh_metrics.read_metrics_collection(files)[source]

Reads data from all “Metrics” collection netCDF files into a single xarray Dataset.

Parameters:

files (list) – List of “Metrics” collection netCDF files.

Returns:

data – Object containing “Metrics” collection data.

Return type:

xr.Dataset

gcpy.benchmark.modules.oh_metrics.total_airmass(data)[source]

Computes the total airmass (in both kg and molec).

Parameters:

data (xr.Dataset) – Object w/ “Metrics” collection data.

Returns:

  • airmass_kg (np.float64) – Total atmospheric air mass [kg].

  • airmass_m (np.float64) – Total atmospheric air mass [molecules].

gcpy.benchmark.modules.oh_metrics.global_mean_oh(data, airmass_kg, mw_oh_kg)[source]

Computes the global mean OH concentration (1e5 molec cm-3).

Parameters:
  • data (xr.Dataset) – Object w/ “Metrics” collection data.

  • airmass_kg (np.float64) – Total atmospheric air mass [kg].

  • mw_oh_kg (np.float64) – Mol. wt. of OH [kg].

Returns:

mean_oh – Mean OH [1e5 molec/cm3].

Return type:

np.float64

gcpy.benchmark.modules.oh_metrics.lifetimes_wrt_oh(data, airmass_m)[source]

Computes the lifetimes (in years) of CH4 and CH3CCl3 (aka MCF) against tropospheric OH.

Parameters:
  • data (xr.Dataset) – Object w/ “Metrics” collection data.

  • airmass_m (np.float64) – Total airmass [molecules].

Returns:

  • ch4_life_wrt_oh (np.float64) – CH4 lifetime w/r/t OH [years].

  • mcf_life_wrt_oh (np.float64) – MCF lifetime w/r/t OH [years].

gcpy.benchmark.modules.oh_metrics.init_common_vars(ref, refstr, dev, devstr, spcdb_files)[source]

Returns a dictionary containing various quantities that need to be passed between methods.

Parameters:
  • ref (str) – Path name of “Ref” (aka “Reference”) data file.

  • refstr (str) – Label to describe Ref.

  • dev (str) – Path name of “Dev” (aka “Development”) data file.

  • devstr (str) – Label to describe Dev.

  • spcdb_files (list) – Paths to Ref & Dev species_database.yml files.

Returns:

common_vars – OH Metrics data.

Return type:

dict

gcpy.benchmark.modules.oh_metrics.compute_oh_metrics(common_vars)[source]

Computes the mass-weighted mean OH concentration, CH3CCl3 (aka MCF) lifetime w/r/t OH, and CH4 lifetime w/r/t OH.

Parameters:

common_vars (dict) – OH Metrics data.

Returns:

common_vars – Updated OH Metrics data.

Return type:

dict

gcpy.benchmark.modules.oh_metrics.write_to_file(f, title, ref, dev, absdiff, pctdiff, is_mean_oh=False)[source]

Internal routine used by print_metrics to write a specific quantity (mean OH, MCF lifetime, CH4 lifetime) to a file.

Parameters:
  • f (file) – File object.

  • title (str) – Title for the data.

  • ref (np.float64) – Ref data value.

  • dev (np.float64) – Dev data value.

  • absdiff (np.float64) – Absolute difference.

  • pctdiff (np.float64) – Percent difference.

  • is_mean_oh (bool, optional) – Denotes if this data is Mean OH or not.

gcpy.benchmark.modules.oh_metrics.print_metrics(common_vars, dst)[source]

Prints the mass-weighted mean OH (full atmospheric column) from a GEOS-Chem simulation.

Parameters:
  • common_vars (dict) – Data containing OH Metrics data.

  • dst (str) – Folder where OH Metrics output will be written.

gcpy.benchmark.modules.oh_metrics.make_benchmark_oh_metrics(ref, refstr, dev, devstr, spcdb_files, dst='./benchmark', overwrite=True)[source]

Creates a text file containing metrics of global mean OH, MCF lifetime, and CH4 lifetime for benchmarking purposes.

Parameters:
  • ref (str) – Path name of “Ref” (aka “Reference”) data file.

  • refstr (str) – Label to describe Ref.

  • dev (str) – Path name of “Dev” (aka “Development”) data file.

  • devstr (str) – Label to describe Dev.

  • spcdb_files (list) – Paths to Ref & Dev species_database.yml files.

  • dst (str, optional) – Folder where OH Metrics output will be written.

  • overwrite (bool, optional) – Overwrite previously-generated files?