Source code for pycif.plugins.models.iconart.io.native2inputs
from logging import warning
from .inputs.inicond import make_inicond
from .inputs.restart_inicond import make_restart_inicond
from .inputs.lbc import make_lbc
from .inputs.fluxes import make_fluxes
from .inputs.endconcs import make_endconcs
from .....utils.check.errclass import CifError
[docs]
def native2inputs(
self, datastore, input_type, datei, datef, runsubdir, mode="fwd",
onlyinit=False, do_simu=True, check_transforms=False, **kwargs
):
"""Converts data at the model data resolution stored in ``datastore``
to model compatible input files.
Native2inputs will be called for every couple ``component/tracer``
as defined in the ``mapper``
Args:
self: the model Plugin
input_type (str): the ``component`` name to be treated; please note that
this information is redundant with the keys in ``datastore``
datastore: data to convert
datei, datef: date interval of the sub-simulation
mode (str): running mode: one of 'fwd', 'adj' and 'tl'
runsubdir (str): sub-directory for the current simulation
workdir (str): the directory of the whole pyCIF simulation
Note:
The format of ``datastore`` is a mixture of the model ``mapper`` and
of the data format as defined
:doc:`here </documentation/plugins/transforms/index>`
For each component/tracer, the data itself is stored
in the key ``data``, and all the other keys come from the ``mapper``,
in case they are useful to dump inputs at the correct format
Note:
If the input data was fully consistent with what the model expects,
the data itself is not read by pyCIF. Instead, it is possible to
directly link files defined by the key ``input_files`` (and defined
in the ``fetch`` function of the corresponding ``flux`` plugin).
"""
ddi = min(datei, datef)
ddf = max(datei, datef)
if not do_simu:
warning(f"Skipping iconart.native2inputs because do_simu = {do_simu}")
return
# Initial conditions
if input_type == 'inicond':
make_inicond(self, datastore, ddi, ddf, runsubdir, mode)
# Initial conditions from a restart file
elif input_type == 'restart_inicond':
make_restart_inicond(self, datastore, ddi, ddf, runsubdir, mode)
# Lateral boundary conditions
elif input_type == 'lbc':
make_lbc(self, datastore, ddi, ddf, runsubdir, mode)
# Fluxes
elif input_type == 'flux':
make_fluxes(self, datastore, ddi, ddf, runsubdir, mode)
# Restart conditions from previous simulations
elif input_type == "endconcs":
make_endconcs(self, datastore, ddi, ddf, runsubdir, mode)
else:
raise CifError(f"Un-recognized input type {input_type}. Should not happen")