pycif.plugins.models.wrfchem — API reference#
Configuration reference: wrfchem plugin
- pycif.plugins.models.wrfchem.ini_mapper.ini_mapper(model, transform_type, general_mapper={}, backup_comps={}, transforms_order=[], ref_transform='', transform_name='', **kwargs)[source]#
Build the data-flow mapper for the WRF-Chem model.
Defines the input/output streams for WRF-Chem:
Inputs — anthropogenic emissions (
flux), meteorological lateral boundary conditions (lbc), initial concentrations (inicond), WRF namelist (namelist), WRF executable (model).Outputs — simulated concentrations per active species.
Uses
meteo_datesfor the meteorological input date grid (which may differ frominput_dates).- Parameters:
model – WRF-Chem model plugin instance.
transform_type (str) – unused; kept for API compatibility.
general_mapper (dict) – unused.
backup_comps (dict) – unused.
transforms_order (list) – unused.
ref_transform (str) – unused.
transform_name (str) – unused.
**kwargs – unused.
- Returns:
mapper with
inputs,outputs, andoutputs2inputs.- Return type:
dict
- pycif.plugins.models.wrfchem.ini_periods.ini_periods(self, **kwargs)[source]#
Compute temporal discretisation for the WRF-Chem model.
Splits the full simulation window into sub-simulation periods (using
self.periodsif set, otherwise a single window) and derives the output and input date arrays from the WRF namelist output interval.Sets on self:
subsimu_dates— period boundary dates.tstep_dates— per-period time-step arrays (at WRF output frequency).meteo_dates— per-period meteorological input date arrays.input_dates— per-period initial/end-concentration date arrays.tstep_all— sorted unique merge of all time steps.iniobs,reset_obs— per-period observation bookkeeping flags.chain— per-period flag indicating chained restarts.
- Parameters:
self – WRF-Chem model plugin instance with
datei,datef, anddomain(WRF namelist) set.**kwargs – unused.
- pycif.plugins.models.wrfchem.perturb_model.perturb_model(self, nsamples, transf_mapper)[source]#
Extend the WRF-Chem chemistry scheme to accommodate ensemble members.
Creates
nsamplescopies of each active species using the__sample#NNNnaming convention, then removes the original un-suffixed species.Note
This function currently emits debug warnings (
warn) for diagnostic purposes.- Parameters:
self – WRF-Chem model plugin instance.
nsamples (int) – number of ensemble members.
transf_mapper (dict) – unused; kept for API consistency.
- pycif.plugins.models.wrfchem.run.run(self, runsubdir, mode, workdir, ddi, do_simu=True, **kwargs)[source]#
Run WRF
- Parameters:
runsubdir (str) – working directory for the current run
mode (str) – forward or backward
workdir (str) – pycif working directory
do_simu (bool) – if False, considers that the simulation was already run
VERSION HISTORY
- 2021-08-19 Original code from online doc and from
plugins/models/lmdz/run.py
From ctdas-wrf’s wrchem utilities.
- class pycif.plugins.models.wrfchem.utilities.utilities[source]#
Bases:
objectUtilities for wrfchem model
Created on Mon Jul 22 15:03:02 2019
VERSION HISTORY 2021-09-25 freum Adapted from CTDAS-WRF wrfchem_helper.py - Everything not (yet) needed is commented
@author: friedemann
- class pycif.plugins.models.wrfchem.wrfchem_helper.WRFChemHelper(settings)[source]#
Bases:
objectContains helper functions for sampling WRF-Chem
- static get_int_coefs(pb_ret, pb_mod, level_def)[source]#
Computes a coefficients matrix to transfer a model profile onto a retrieval pressure axis.
If level_def==”layer_average”, this assumes that profiles are constant in each layer of the retrieval, bound by the pressure boundaries pb_ret. In this case, the WRF model layer is treated in the same way, and coefficients integrate over the assumed constant model layers. This works with non-staggered WRF variables (on “theta” points). However, this is actually not how WRF is defined, and the implementation should be changed to z-staggered variables. Details for this change are in a comment at the beginning of the code.
If level_def==”pressure_boundary” (IMPLEMENTATION IN PROGRESS), assumes that profiles, kernel and pwf are defined at pressure boundaries that don’t have a thickness (this is how OCO-2 data are defined, for example). In this case, the coefficients linearly interpolate adjacent model level points. This is incompatible with the treatment of WRF in the above-described layer-average assumption, but is closer to how WRF is actually defined. The exception is that pb_mod is still constructed and non-staggered variables are not defined at psurf. This can only be fixed by switching to z-staggered variables.
In cases where retrieval surface pressure is higher than model surface pressure, and in cases where retrieval top pressure is lower than model top pressure, the model profile will be extrapolated with constant tracer mixing ratios. In cases where retrieval surface pressure is lower than model surface pressure, and in cases where retrieval top pressure is higher than model top pressure, only the parts of the model column that fall within the retrieval presure boundaries are sampled.
Arguments#
- pb_ret (
array_like) Pressure boundaries of the retrieval column
- pb_mod (
array_like) Pressure boundaries of the model column
- level_def (
string) “layer_average” or “pressure_boundary” (IMPLEMENTATION IN PROGRESS). Refers to the retrieval profile.
Note 2021-09-13: Inspected code for pressure_boundary. Should be correct. Interpolates linearly between two model levels.
Returns#
- coefs (
array_like) Integration coefficient matrix. Each row sums to 1.
Usage#
import numpy as np pb_ret = np.linspace(900., 50., 5) pb_mod = np.linspace(1013., 50., 7) model_profile = 1. - np.linspace(0., 1., len(pb_mod)-1)**3 coefs = get_int_coefs(pb_ret, pb_mod, "layer_average") retrieval_profile = np.matmul(coefs, model_profile)
- pb_ret (