Source code for pycif.plugins.models.lmdz_acc.io.inputs.meteo

import os
import shutil

from ......utils import path


[docs] def make_meteo(self, data, ddi, ddf, runsubdir, mode): """Link LMDZ-ACC meteorological input files into the period run directory. Symlinks ``defstoke.nc`` (mass fluxes) and other required meteo files from the original source directory (``data[("meteo","")]["dirorig"]``) into *runsubdir*. Args: self: LMDZ-ACC model plugin instance. data (dict): meteo CIF data-store (carries ``dirorig`` path). ddi (datetime): period start date. ddf (datetime): period end date. runsubdir (str): path to the period run directory. mode (str): ``'fwd'``, ``'tl'``, or ``'adj'``. """ datei = min(ddi, ddf) dir_meteo = data[("meteo", "")]["dirorig"] # Links meteorological mass fluxes source = os.path.join(dir_meteo, "defstoke.nc") target = os.path.join(runsubdir, "defstoke.nc") path.link(source, target) for file_type in ["fluxstoke", "fluxstokev", "phystoke"]: if file_type == "phystoke" and self.compressed_phystoke: filename = datei.strftime(f"{file_type}.an%Y.m%m_csr.nc") else: filename = datei.strftime(f"{file_type}.an%Y.m%m.nc") source = os.path.join(dir_meteo, filename) target = os.path.join(runsubdir, f"{file_type}.nc") if mode == "tl" and os.path.isfile(target): return if 'meteo' in self.copy_inputs: # Follow the symlink for 'source' and copy it to 'target' source = os.path.realpath(source) shutil.copy(source, target) else: # Simply link the file path.link(source, target)