Source code for pycif.plugins.models.dummy.io.outputs2native_adj
import numpy as np
import copy
from .....utils.datastores.empty import init_empty
[docs]
def outputs2native_adj(
self, data2dump, input_type, di, df, runsubdir, mode="fwd", dump=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 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