Source code for pycif.plugins.transforms.system.loadfromoutputs.forward

import pandas as pd


[docs] def forward( transform, inout_datastore, controlvect, obsvect, mapper, di, df, mode, runsubdir, workdir, do_simu=True, onlyinit=False, check_transforms=False, **kwargs ): """Load model output files into CIF-internal arrays via ``outputs2native``. Iterates over the input tracers in the mapper, collects the data already present in the datastore, and passes it to the model's ``outputs2native`` function (bound on the transform instance by :func:`ini_mapper`). The returned arrays are stored in both the ``'inputs'`` and ``'outputs'`` sub-dicts of the datastore so they are available to both the current and succeeding transforms. When the tracer parameter is ``''``, all parameters of the matching component are loaded together. Args: transform (Plugin): loadfromoutputs instance (carries ``outputs2native``). inout_datastore (dict): mutable datastore. controlvect: unused. obsvect: unused. mapper (dict): transform mapper. di (datetime): sub-simulation start date. df (datetime): sub-simulation end date. mode (str): ``'fwd'`` or ``'tl'``. runsubdir (str): sub-simulation run directory passed to ``outputs2native``. workdir (str): root working directory. do_simu (bool): forwarded to ``outputs2native``. onlyinit (bool): forwarded to ``outputs2native``. check_transforms (bool): forwarded to ``outputs2native``. **kwargs: forwarded to ``outputs2native``. """ datastore = inout_datastore["inputs"] ds = {} for trid in mapper["inputs"]: input_type = trid[0] # If input parameter is '', # load all available parameters of this component if trid[1] == "": toload = [t for t in datastore if t[0] == input_type] # Otherwise simply loads the parameter else: toload = [trid] # Create new data to dump data2load = {t: datastore.get(t, {}) for t in toload} data2load = transform.outputs2native( data2load, input_type, di, df, runsubdir, mode, onlyinit=onlyinit, check_transforms=check_transforms, ) # De-aggregate if data were coming from several transforms for tr in data2load: ds[tr] = {} for di in datastore[tr]: ds[tr][di] = data2load[tr] # Update outputs and inputs as well inout_datastore["outputs"].update(ds) inout_datastore["inputs"].update(ds)