Source code for pycif.plugins.datastreams.fields.lmdz_ic.fetch

import os

from .....utils import path


[docs] def fetch( ref_dir, ref_file, input_interval, target_dir, tracer=None, component=None ): """Link the single LMDz restart file for the simulation start date. Args: ref_dir (str): Path to the data. ref_file (str): File name format of the data. input_interval (list[datetime.datetime]): Date range; only the start date is used. target_dir (str): Where to link the data. tracer: Unused. component: Unused. Returns: (list_files, list_dates): tuple of single-entry dictionaries keyed by the simulation start date, describing the linked file and the (single-point) date interval it covers. Empty dicts if the original file is not found. """ date = input_interval[0] input_file = os.path.join(ref_dir, date.strftime(ref_file)) if not os.path.isfile(input_file): return {}, {} # Fetching target_file = os.path.join(target_dir, os.path.basename(input_file)) path.link(input_file, target_file) list_files = {date: [input_file]} list_dates = {date: [[date, date]]} return list_files, list_dates