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

from ....utils.dates import date_range


[docs] def ini_periods(self, **kwargs): """Compute temporal discretisation for the LMDZ-old model. Identical in structure to the LMDZ-ACC ``ini_periods``: splits the simulation window into monthly (or ``self.periods``-based) sub-periods and derives time-step arrays from the domain's dynamical/physical split and the meteorological offset time step. Sets on *self*: ``subsimu_dates``, ``tstep_dates``, ``input_dates``, ``flx_input_dates``, ``tstep_all``, ``iniobs``, ``reset_obs``, ``chain``. Args: self: LMDZ-old model plugin instance with ``datei``, ``datef``, ``periods``, ``domain``, and ``meteo`` set. **kwargs: unused. """ datei = self.datei datef = self.datef # List of sub-simulation windows self.subsimu_dates = date_range(datei, datef, period=self.periods) # Dynamical and physical time step for LMDZ dstep = self.domain.dsplit pstep = self.domain.psplit # Initializes offtstep from meteo if not hasattr(self.meteo, "offtstep"): self.meteo.read("", "", self.subsimu_dates, self.meteo.dir, "") offtstep = self.meteo.offtstep # Time steps per day freq = f"{offtstep // min([dstep, pstep]):.0f}s" # List of time steps self.tstep_dates = { ddi: date_range(ddi, ddf, period=freq) for ddi, ddf in zip(self.subsimu_dates[:-1], self.subsimu_dates[1:]) } # List of input dates # TODO: make the date inputs flexible (daily so far) self.input_dates = { ddi: date_range(ddi, ddf, period="1D") for ddi, ddf in zip(self.subsimu_dates[:-1], self.subsimu_dates[1:]) } self.flx_input_dates = { ddi: date_range(ddi, ddf, period=self.flx_tresol) for ddi, ddf in zip(self.subsimu_dates[:-1], self.subsimu_dates[1:]) } self.meteo_dates = { ddi: date_range(ddi, ddf, period="3h") 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=freq) # Initializes dictionary to keep in memory whether observations were # already dumped for a given period self.iniobs = {ddi: False for ddi in self.subsimu_dates} self.reset_obs = {ddi: True for ddi in self.subsimu_dates} self.nbobs_prior = {ddi: 0 for ddi in self.subsimu_dates} self.nbdatatot_prior = {ddi: 0 for ddi in self.subsimu_dates} # Run model or approximation with fake_end self.runsimu = {ddi: True for ddi in self.subsimu_dates} # Keep in memory whether a given period has a successor period # The info is used by the adjoint to fetch or not the restart file self.chain = {ddi: True for ddi in self.subsimu_dates[:-1]} self.chain[self.subsimu_dates[-2]] = False