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

from .....utils.datastores.empty import init_empty


[docs] def outputs2native( self, data2dump, input_type, di, df, runsubdir, mode="fwd", dump=True, onlyinit=False, do_simu=True, check_transforms=False, **kwargs ): """Reads outputs to pycif objects. If the mode is 'fwd' or 'tl', only onservation-like outputs are extracted. For the 'adj' mode, all outputs relative to model sensitivity are extracted. Dumps to a NetCDF file with output concentrations if needed""" if onlyinit: return data2dump ddi = min(di, df) dataout = {} if mode in ["tl", "fwd"]: if not hasattr(self, "dataobs"): self.dataobs = {} if ddi not in self.dataobs: self.dataobs[ddi] = {spec: init_empty() for spec in self.chemistry.acspecies.attributes} # Read simulated concentrations # In classical model, this should correspond to reading output files # Here the observations are already stored in the model object datastore = self.dataobs # Loop over species in data2dump for trid in data2dump: if trid[1] not in datastore[ddi]: continue dataout[trid] = data2dump[trid][ddi] dataout[trid].loc[:, ("maindata", "spec")] = \ datastore[ddi][trid[1]][("maindata", "spec")][:] dataout[trid].loc[:, ("maindata", "incr")] = \ datastore[ddi][trid[1]][("maindata", "incr")][:] return dataout