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

from logging import warning

from .outputs.read_sim import read_sim
from .outputs.endconcs import fetch_end

[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 """ ddi = min(di, df) ddf = max(di, df) # If no data to extract, pass if data2dump == {}: return data2dump # If the model is not run, pass if self.dont_run: warning(f"Skipping iconart.outputs2native because self.dont_run = {self.dont_run}") return {} # Read simulations if input_type is in outcomp outcomp = ["concs", "pressure", "dpressure", "airm", "hlay"] if input_type in outcomp and not onlyinit: return read_sim(self, data2dump, runsubdir, mode, ddi, ddf) # Fetch end concentrations if input_type is "endconcs" elif input_type == "endconcs": return fetch_end(self, data2dump, runsubdir, mode, ddi, ddf) else: return data2dump