Source code for pycif.plugins.models.dummy.io.native2inputs
import numpy as np
from .inputs.fluxes import make_fluxes
from .inputs.meteo import make_meteo
[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 to model compatible input
files.
Args:
self: the model Plugin
input_type (str): one of 'flux', 'obs'
datastore: data to convert
if input_type == 'flux', a dictionary with flux maps
if input_type == 'obs', a pandas dataframe with the observations
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
Notes:
- LMDZ expects daily inputs; if the periods in the control vector are
longer than one day, period values are uniformly de-aggregated to the
daily scale; this is done with pandas function 'asfreq' and the option
'ffill' as 'forward-filling'
See Pandas page for details:
https://pandas.pydata.org/pandas-docs/stable/generated/pandas
.DataFrame.asfreq.html
"""
if datastore is None:
datastore = {}
# Switching datei and datef if adj
ddi = min(datei, datef)
ddf = max(datei, datef)
# Deals with fluxes
if input_type == "flux":
make_fluxes(self, datastore, ddi, ddf)
elif input_type == "meteo":
make_meteo(self, datastore, ddi, ddf)