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

from __future__ import annotations

import datetime
from os import PathLike
from pathlib import Path
from typing import Any

import pandas as pd

from ......utils import path
from ......utils.check.errclass import CifValueError


[docs] def make_meteo( self, datastore: dict[tuple[str, str], dict[str | datetime.datetime, Any]], datei: datetime.datetime, runsubdir: str | PathLike, ) -> None: """Link mass-flux input files into the period run directory""" datei = pd.to_datetime(datei) trid = ("meteo", "") if trid not in datastore: raise CifValueError( "No meteo data found. LMDZ needs the meteo/LMDZ/mass-fluxes plugin to run." ) meteo_dir = Path(datastore[trid]["dirorig"]) if self.grid == "regular": file_basenames = ("fluxstoke", "fluxstokev", "phystoke") elif self.grid == "dynamico": file_basenames = ("fluxstoke", "phystoke") else: raise CifValueError(f"Unknown grid type: '{self.grid}'") for basename in file_basenames: if basename == "phystoke": source = meteo_dir / f"{basename}.an{datei:%Y}.m{datei:%m}_csr.nc" else: source = meteo_dir / f"{basename}.an{datei:%Y}.m{datei:%m}.nc" target = Path(runsubdir, f"{basename}.nc") path.link(source, target)