Source code for pycif.plugins.models.TM5.ini_periods
import datetime
import numpy as np
import pandas as pd
from ....utils.dates import date_range
from ....utils.netcdf import readnc
[docs]
def ini_periods(self, **kwargs):
"""Compute temporal discretisation for TM5.
TM5 runs as a single sub-simulation (no period chaining), so
``subsimu_dates`` contains only ``[datei, datef]``. Time steps are
hourly; flux inputs are at monthly resolution.
Sets on *self*:
* ``subsimu_dates`` — ``[datei, datef]``.
* ``tstep_dates`` — 1-hourly time-step array for the full window.
* ``tstep_all`` — same array (no chaining).
* ``input_dates`` — monthly flux/meteo input dates.
Args:
self: TM5 model plugin instance with ``datei`` and ``datef`` set.
**kwargs: unused.
"""
datei = self.datei
datef = self.datef
# List of sub-simulation windows
# Only one for TM5
self.subsimu_dates = [datei, datef]
# simulation time steps (used to extract concentrations
# To test every hours
self.tstep_dates = {datei: date_range(datei, datef, period="1h")}
self.tstep_all = np.array(self.tstep_dates[datei][:])
# when inputs are needed; 12H frequency for test
#
# JvP 20210527: the 12H frequency for input to the TM5 model is too high,
# the fluxes are only required on a basis. So try to change the frequency
# to "1MS", where MS = month start frequency according to the pandas
# documentation
#
# self.input_dates = {datei: pd.date_range(datei, datef, freq="12h")}
self.input_dates = {datei: date_range(datei, datef, period="1MS")}