pycif.plugins.models.satwetch4 — API reference#
Configuration reference: satwetch4 plugin
- pycif.plugins.models.satwetch4.ini_mapper.ini_mapper(model, general_mapper={}, backup_comps={}, transforms_order=[], ref_transform='', transform_name='', all_transforms=None, **kwargs)[source]#
Build the data-flow mapper for the SatWetCH4 bottom-up emission model.
Declares:
Inputs — soil temperature, inundated fraction, labile carbon, and model parameters (
k,Q10) at the model’s configured input resolution.Outputs — CH₄ wetland flux per time step.
- Parameters:
model – SatWetCH4 plugin instance with all date arrays set.
general_mapper (dict) – unused.
backup_comps (dict) – unused.
transforms_order (list) – unused.
ref_transform (str) – unused.
transform_name (str) – unused.
all_transforms – unused.
**kwargs – unused.
- Returns:
mapper with
inputs,outputs, andoutputs2inputs.- Return type:
dict
- pycif.plugins.models.satwetch4.ini_periods.ini_periods(self, **kwargs)[source]#
The function
ini_periodsis optional but very recommended. It is used to define the temporal variablessubsimu_dates,input_dates,tstep_datesandtstep_all. The function is automatically called at the initialization of themodelclass if available. If not available, the temporal variables should be defined manually in theini_datafunction (not recommended).ini_periodsis a class method that applies to themodelplugin itself. Therefore, the only expected argument isself.def ini_periods(self, **kwargs): self.subsimu_dates = XXXX self.tstep_dates = XXXXX self.input_dates = XXXXX self.tstep_all = XXXXX
- pycif.plugins.models.satwetch4.run.run(self, runsubdir, mode, workdir, ddi, nbproc=1, do_simu=True, approx_transf=False, ref_fwd_dir='', overlap=False, datastore=None, **kwargs)[source]#
Run the model in forward, tangent-linear or adjoint mode. This includes:
executing the model external executable
updating
adj_refdirmoving files needed for chained simulations to f”{}/../”
Note
For model for which the adjoint is not coded, make sure to return a clear error if the
runfunction is called inadjmode and withdo_simu = True- Parameters:
self – the model Plugin
runsubdir (str) – working directory for the current run
mode (str) – forward or backward
workdir (str) – pyCIF working directory
do_simu (bool) – re-run or not existing simulation
- pycif.plugins.models.satwetch4.io.native2inputs.native2inputs(self, datastore, input_type, datei, datef, runsubdir, mode='fwd', onlyinit=False, do_simu=True, check_transforms=False, **kwargs)[source]#
Converts data at the model data resolution stored in
datastoreto model compatible input files.Native2inputs will be called for every couple
component/traceras defined in themapper- Parameters:
self – the model Plugin
input_type (str) – the
componentname to be treated; please note that this information is redundant with the keys indatastoredatastore – data to convert
datei – date interval of the sub-simulation
datef – date interval of the sub-simulation
mode (str) – running mode: one of ‘fwd’, ‘adj’ and ‘tl’
runsubdir (str) – sub-directory for the current simulation
workdir (str) – the directory of the whole pyCIF simulation
Note
The format of
datastoreis a mixture of the modelmapperand of the data format as defined hereFor each component/tracer, the data itself is stored in the key
data, and all the other keys come from themapper, in case they are useful to dump inputs at the correct formatNote
If the input data was fully consistent with what the model expects, the data itself is not read by pyCIF. Instead, it is possible to directly link files defined by the key
input_files(and defined in thefetchfunction of the correspondingfluxplugin).
- pycif.plugins.models.satwetch4.io.native2inputs_adj.native2inputs_adj(self, datastore, input_type, datei, datef, runsubdir, mode='fwd', check_transforms=False, **kwargs)[source]#
Read adjoint sensitivity and format them to pyCIF data format.
Warning
This function is used only when the adjoint of the model is available.
- Parameters:
self – the model Plugin
input_type (str) – one of ‘flux’
datastore – data to convert if input_type == ‘flux’,
datei – date interval of the sub-simulation
datef – date interval of the sub-simulation
mode (str) – running mode: one of ‘fwd’, ‘adj’ and ‘tl’
runsubdir (str) – sub-directory for the current simulation
workdir (str) – the directory of the whole pyCIF simulation
- pycif.plugins.models.satwetch4.io.outputs2native.outputs2native(self, data2dump, input_type, di, df, runsubdir, mode='fwd', onlyinit=False, check_transforms=False, **kwargs)[source]#
Reads outputs to pyCIF objects.
- Parameters:
self – the model itself
data2dump (dict) – a dictionary with output data structure to be filled with correct data for every component/tracer
input_type (str) – the type of model outputs to be processed; this information is redundant with the components of the data2dump dictionary
di (datetime.datetime) – starting date of the present sub-simulation
df (datetime.datetime) – ending date of the present sub-simulation
runsubdir (str) – path to the present sub-simulation work directory
mode (str) – running mode; one of “fwd”, “tl” and “adj”
onlyinit (bool) – if
True, means that the function is called during the initialization process of the observation vectordo_simu (bool) – if
False, means that the observation vector is retrieving information from a previous existing run; in that case, it may not be necessary to dump files
- Returns:
a dictionary with structure the components/tracers to be extracted
- Return type:
dict
- pycif.plugins.models.satwetch4.io.outputs2native_adj.outputs2native_adj(self, data2dump, input_type, di, df, runsubdir, mode='fwd', onlyinit=False, do_simu=True, check_transforms=False, **kwargs)[source]#
Dumps and/or save information about outputs, so the model knows where to extract information.
In the present template, observations are simply saved for later use by
outputs2native. If the model needs information to extract concentration on-the-fly, the information indata2dumpshould be used. In particular, the columnsiandjare the row and columns of each observation in the domain. The columntstepindicates on which time stamp the observation spans, relative to what is indicated in the variableoutput_intervalsinini_mapper.The function is called by
loadfromoutputs.adjoint.- Parameters:
self – the model itself
data2dump (dict) – a dictionary with concentration data for each component/tracer
input_type (str) – the type of model outputs to be processed; this information is redundant with the components of the data2dump dictionary
di (datetime.datetime) – starting date of the present sub-simulation
df (datetime.datetime) – ending date of the present sub-simulation
runsubdir (str) – path to the present sub-simulation work directory
mode (str) – running mode; one of “fwd”, “tl” and “adj”
onlyinit (bool) – if
True, means that the function is called during the initialization process of the observation vectordo_simu (bool) – if
False, means that the observation vector is retrieving information from a previous existing run; in that case, it may not be necessary to dump files
- pycif.plugins.models.satwetch4.io.inputs.make_auxiliary.make_auxiliary(self, ddi, runsubdir, do_simu=True, mode='fwd', **kwargs)[source]#
Initialize every file or information needed by the model to run, excluding data that are initialized through the function
native2inputs.This includes name lists for Fortran, configuration files, etc.
Every basic files related to the model should be first initialized in
self.workdir/modelat the initialization step in the functioncompile.Hereafter, files are link/copied to
runsubdirfrom the reference ones inself.workdir/modelNote
For configuration files, one should follow the following basic rules:
paths expected by the model should always point to the current
runsubdir; thus the executable should be linked or copied inrunsubdir; in addition, every extra file should be link with a fixed name and the corresponding name should be given in the name-list or configuration file.as many model parameters should be easily modified through the yaml configuration file; however, for some reasons, it may be preferable to limit the possibilities for pyCIF by keeping some parameters fixed; this question is up to the developer implementing one model
- Parameters:
self – the model plugin
ddi (datetime.datetime) – the start data identifying the present simulation period
runsubdir (str) – path to the current sub-simulation work directory
do_simu (bool) – if False, the simulation does not need to be run, hence, in principle, no auxiliary data needs to be initialized
mode (str) – the running mode to compute