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

import os
from logging import debug

from .....utils import path


[docs] def fetch(ref_dir, ref_file, input_interval, target_dir, tracer=None, component=None): """ Retrieves the required files according to the simulation and the data files available Args: - ref_dir: directory where the original files are found - ref_file: (template) name of the original files - input_interval: list of two dates: the beginning and end of the simulation - target_dir: directory where the links to the orginal files are created Returns: - list_dates: a dictionary in which each key leads to a list of intervals [date_beginning, date_end] so that each interval is covered by one value taken fom the matching file stored in list_files. - list_files: dictionary in which each key leads to a list of files so that the list of intervals are covered by the values provided in these files. """ initial_date = input_interval[0] file_path = initial_date.strftime(os.path.join(ref_dir, ref_file)) if not os.path.isfile(file_path): return {}, {} target_file_path = os.path.join(target_dir, os.path.basename(file_path)) path.link(file_path, target_file_path) list_dates = {initial_date: [[initial_date, initial_date]]} list_files = {initial_date: [target_file_path]} return list_files, list_dates