Source code for pycif.plugins.models.lmdz_ico.io.outputs2native_adj
from __future__ import annotations
import datetime
from os import PathLike
from typing import Any, Literal
from .inputs import make_endconcs, make_obs
[docs]
def outputs2native_adj(
self,
data2dump: dict[tuple[str, str], dict[str | datetime.datetime, Any]],
input_type: str,
datei: datetime.datetime,
datef: datetime.datetime,
runsubdir: str | PathLike,
mode: Literal["fwd", "tl", "adj"] = "fwd",
dump: bool = True,
onlyinit: bool = False,
do_simu: bool = True,
check_transforms: bool = False,
**kwargs,
) -> None:
"""Reads outputs to pycif objects.
If the mode is 'fwd' or 'tl', only observation-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
Args:
self (pycif.utils.classes.models.Model): Model object
runsubdir (str): current sub-sumilation directory
mode (str): running mode; one of: 'fwd', 'tl', 'adj'; default is 'fwd'
dump (bool): dumping outputs or not; default is True
Return:
dict
"""
ddi = min(datei, datef)
ddf = max(datei, datef)
data2dump_others = {}
for mod_type, tracer in data2dump:
if mod_type == "endconcs":
make_endconcs(self, data2dump, ddi, ddf, runsubdir, mode, onlyinit)
else:
trid = (mod_type, tracer)
data2dump_others[trid] = data2dump[trid][ddi]
mode = "fwd" if onlyinit else "adj"
make_obs(self, data2dump_others, ddi, mod_type, runsubdir, mode)