Source code for pycif.plugins.models.dummy.ini_periods
from ....utils.dates import date_range
[docs]
def ini_periods(self, **kwargs):
"""Initialise sub-simulation periods and time-step arrays for the dummy model.
Partitions the full simulation window into sub-periods of length
``self.periods``, then divides each sub-period into time steps of length
``self.tstep``. Both periods and time steps may be any pandas
frequency alias (e.g. ``'4D'``, ``'1H'``).
Sets the following attributes on *self*:
* ``subsimu_dates`` — 1-D array of sub-simulation boundary dates.
* ``tstep_dates`` — dict mapping each sub-period start date to its
array of time-step boundary dates.
* ``input_dates`` — same as ``tstep_dates`` (dummy model reads inputs
at each model time step).
* ``tstep_all`` — 1-D array of all time steps across all periods.
Args:
self (Plugin): dummy model plugin instance (carries ``datei``,
``datef``, ``periods``, ``tstep``).
**kwargs: unused; accepted for interface consistency.
"""
datei = self.datei
datef = self.datef
# List of sub-simulation windows
self.subsimu_dates = date_range(datei, datef, period=self.periods)
# Fixed time step (in hours): list of time steps for each sub-simulation
self.tstep_dates = {
ddi: date_range(ddi, ddf, period=self.tstep)
for ddi, ddf in zip(self.subsimu_dates[:-1], self.subsimu_dates[1:])
}
# Fixed time step (in hours): list of required input time steps
self.input_dates = {
ddi: date_range(ddi, ddf, period=self.tstep)
for ddi, ddf in zip(self.subsimu_dates[:-1], self.subsimu_dates[1:])
}
# Merged list of time steps
self.tstep_all = date_range(
datei, datef, period=self.periods, subperiod=self.tstep
)