Source code for pycif.plugins.models.satwetch4.ini_periods

import datetime

import numpy as np
import pandas as pd
import xarray as xr
from netCDF4 import Dataset

from logging import info, debug

from ....utils.dates import date_range
from ....utils.netcdf import readnc


[docs] def ini_periods(self, **kwargs): """ The function :bash:`ini_periods` is optional but very recommended. It is used to define the temporal variables ``subsimu_dates``, ``input_dates``, ``tstep_dates`` and ``tstep_all``. The function is automatically called at the initialization of the :bash:`model` class if available. If not available, the temporal variables should be defined manually in the :bash:`ini_data` function (not recommended). :bash:`ini_periods` is a class method that applies to the :bash:`model` plugin itself. Therefore, the only expected argument is :bash:`self`. .. code-block:: python def ini_periods(self, **kwargs): self.subsimu_dates = XXXX self.tstep_dates = XXXXX self.input_dates = XXXXX self.tstep_all = XXXXX """ datei = self.datei datef = self.datef # List of sub-simulation windows #self.subsimu_dates = [datei, datef] 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.timestep) 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.timestep) 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.timestep) # # # Merged list of time steps if self.timestep == '1MS': self.tstep_all = date_range( datei, datef, period=self.timestep )