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

from __future__ import annotations

import datetime
from os import PathLike
from typing import Any, Literal

from .....utils.datastores.empty import init_empty
from .outputs import fetch_end, read_sim

sim_outputs = ("concs", "pressure", "dpressure", "airm", "hlay")


[docs] def outputs2native( 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", onlyinit: bool = False, check_transforms: bool = False, **kwargs, ) -> dict[tuple[str, str], dict[str | datetime.datetime, Any]]: """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 """ # Switching datei and datef if adjoint ddi = min(datei, datef) ddf = max(datei, datef) if not hasattr(self, "dataobs"): self.dataobs = {spec: init_empty() for spec in self.chemistry.active_species} # If no data to extract, pass if not data2dump: return data2dump # Read simulations if input_type is "concs" elif input_type in sim_outputs and not onlyinit: return read_sim(self, data2dump, ddi, runsubdir, mode) # Fetch end concentration if input_type is endconcs elif input_type == "endconcs": return fetch_end( self, data2dump, ddi, runsubdir, mode, onlyinit, check_transforms ) else: return data2dump