Source code for pycif.plugins.models.template.io.outputs2native

from logging import debug
import numpy as np


[docs]def outputs2native( self, data2dump, input_type, di, df, runsubdir, mode="fwd", onlyinit=False, check_transforms=False, **kwargs ): """Reads outputs to pyCIF objects. Args: 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 vector do_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 Return: dict: a dictionary with structure the components/tracers to be extracted Note: The input data ``data2dump`` has a dictionary structure with two levels: component/tracer and date. This reads as: .. code-block:: python data2dump = { (comp1, tracer1): { dd0: pd.DataFrame dd1: pd.DataFrame [...] } } In the output, the date level should be removed and only the outputs corresponding to the present simulation (``di``) should be included """ debug("Filling output concentrations for the template model") debug("One has to fill the following data structure (data2dump):") debug(data2dump) dataout = {} if mode in ["tl", "fwd"]: # Loop over species in data2dump for trid in data2dump: dataout[trid] = data2dump[trid][di] dataout[trid].loc[:, ("maindata", "spec")] = \ np.random.uniform(400, 410, len(dataout[trid])) if mode == "tl": dataout[trid].loc[:, ("maindata", "incr")] = \ np.random.uniform(0, 10, len(dataout[trid])) return dataout