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

from ....utils.dates import date_range


[docs] def ini_periods(self, **kwargs): """Compute temporal discretisation for the LMDZ-ACC model. Splits the full simulation window into sub-simulation periods and builds time-step arrays at the resolution dictated by the LMDZ domain's dynamical (``dsplit``) and physical (``psplit``) sub-steps and the meteorological offset time step (``meteo.offtstep``). Sets on *self*: * ``subsimu_dates`` — period boundary dates. * ``tstep_dates`` — per-period time-step arrays. * ``input_dates`` — per-period initial/end-concentration date arrays. * ``flx_input_dates`` — per-period flux/meteo input date arrays. * ``tstep_all`` — sorted unique merge of all time steps. * ``iniobs``, ``reset_obs`` — per-period observation bookkeeping flags. * ``chain`` — per-period flag indicating whether the period is chained from the previous one. Args: self: LMDZ-ACC 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