gcpy.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. Requires Python3.
Calling sequence: ./oh_metrics.py
Module Contents
Functions
|
Wrapper for xarray.open_mfdataset, taking into account the |
Determines if a Dataset contains variables for computing |
|
|
Reads data from all "Metrics" collection netCDF files |
|
Computes the total airmass (in both kg and molec). |
|
Computes the global mean OH concentration (1e5 molec cm-3) |
|
Computes the lifetimes (in years) of CH4 and CH3CCl3 (aka MCF) |
|
Returns a dictionary containing various quantities that |
|
Computes the mass-weighted mean OH concentration, CH3CCl3 (aka MCF) |
|
Internal routine used by print_metrics to write a specific |
|
Prints the mass-weighted mean OH (full atmospheric column) |
|
Creates a text file containing metrics of global mean OH, MCF lifetime, |
- gcpy.oh_metrics.combine_dataset(file_list=None)
Wrapper for xarray.open_mfdataset, taking into account the extra arguments needed in xarray 0.15 and later.
- Args:
file_list: list of str
- Returns:
ds: xarray Dataset
- gcpy.oh_metrics.validate_metrics_collection(ds)
Determines if a Dataset contains variables for computing metrics from a CH4 simulation or a fullchem simulation.
- Args:
ds: xarray Dataset
- Returns:
is_ch4_sim: bool
- gcpy.oh_metrics.read_metrics_collection(files)
Reads data from all “Metrics” collection netCDF files into a single xarray Dataset.
- Args:
- data_dir: str
Directory containing data files. Default: “./OutputDir”.
- Returns:
ds: xarray Dataset
- gcpy.oh_metrics.total_airmass(ds)
Computes the total airmass (in both kg and molec).
- Args:
ds: xarray Dataset
- Returns:
- airmass_kg, airmass_m: numpy float64
Total atmospheric air mass in [kg] and [molec]
- gcpy.oh_metrics.global_mean_oh(ds, airmass_kg, mw_oh_kg)
Computes the global mean OH concentration (1e5 molec cm-3)
- Args:
sum_airmass_kg: numpy float64 ds: xarray Dataset
- Returns:
sum_mean_oh: numpy float64
- gcpy.oh_metrics.lifetimes_wrt_oh(ds, airmass_m)
Computes the lifetimes (in years) of CH4 and CH3CCl3 (aka MCF) against tropospheric OH.
- Args:
ds: xarray Dataset
- airmass_m: numpy float64
Total airmass [molecules]
- s_per_yr: numpy float64
Conversion factor: seconds to year.
- Returns:
ch4_life_wrt_oh, mcf_life_wrt_oh: numpy float64
- gcpy.oh_metrics.init_common_vars(ref, refstr, dev, devstr, spcdb_dir)
Returns a dictionary containing various quantities that need to be passed between methods.
- Args:
- ref: str
Path name of “Ref” (aka “Reference”) data set file.
- refstr: str
A string to describe ref (e.g. version number)
- dev: str
Path name of “Dev” (aka “Development”) data set file. The “Dev” data set will be compared against the “Ref” data set.
- devstr: str
A string to describe dev (e.g. version number)
- spcdb_dir: str
Directory of species_datbase.yml file Default value: Directory of GCPy code repository
- Returns:
common_vars: dict
- gcpy.oh_metrics.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.
- Args:
common_vars: dict
- Returns:
common_vars: dict
- gcpy.oh_metrics.write_to_file(f, title, ref, dev, absdiff, pctdiff, is_mean_oh=False)
Internal routine used by print_metrics to write a specific quantity (mean OH, MCF lifetime, CH4 lifetime) to a file.
- Args:
f: file
title: str
ref, dev, absdiff, pctdiff: numpy float64
is_mean_oh: bool
- gcpy.oh_metrics.print_metrics(common_vars, dst)
Prints the mass-weighted mean OH (full atmospheric column) from a GEOS-Chem simulation.
- Args:
ds: xarray Dataset is_ch4_sim: bool
- gcpy.oh_metrics.make_benchmark_oh_metrics(ref, refstr, dev, devstr, dst='./benchmark', overwrite=True, spcdb_dir=os.path.dirname(__file__))
Creates a text file containing metrics of global mean OH, MCF lifetime, and CH4 lifetime for benchmarking purposes.
- Args:
- ref: str
Path name of “Ref” (aka “Reference”) data set file.
- refstr: str
A string to describe ref (e.g. version number)
- dev: str
Path name of “Dev” (aka “Development”) data set file. The “Dev” data set will be compared against the “Ref” data set.
- devstr: str
A string to describe dev (e.g. version number)
- Keyword Args (optional):
- dst: str
A string denoting the destination folder where the file containing emissions totals will be written. Default value: ./benchmark
- overwrite: bool
Set this flag to True to overwrite files in the destination folder (specified by the dst argument). Default value: False
- spcdb_dir: str
Directory of species_datbase.yml file Default value: Directory of GCPy code repository