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

import copy
from logging import debug
from .....utils.datastores.empty import init_empty


[docs]def outputs2native_adj( self, data2dump, input_type, di, df, runsubdir, mode="fwd", onlyinit=False, do_simu=True, **kwargs ): """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 in ``data2dump`` should be used. In particular, the columns ``i`` and ``j`` are the row and columns of each observation in the domain. The column ``tstep`` indicates on which time stamp the observation spans, relative to what is indicated in the variable ``output_intervals`` in ``ini_mapper``. The function is called by ``loadfromoutputs.adjoint``. Args: 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 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 """ if not (mode == "adj" and input_type == "concs"): return # Initializes data obs if not already available ddi = min(di, df) if not hasattr(self, "dataobs"): self.dataobs = {ddi: {spec: init_empty() for spec in self.chemistry.acspecies.attributes}} if ddi not in self.dataobs: self.dataobs[ddi] = {} for trid in data2dump: ds = copy.deepcopy(data2dump[trid][ddi]) # Saves the data to the model # Other models might need an input file # to be writen here to get info on observations self.dataobs[ddi][trid[1]] = ds debug("The following data has been save for later use:") debug(self.dataobs)