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):
"""Link the single initial-condition file for the simulation start date.
Args:
ref_dir: Directory where the original files are found.
ref_file: Date-format pattern for the original file name.
input_interval: List of two dates, the beginning and end of the
simulation; only the start date is used.
target_dir: Directory where the link to the original file is
created.
tracer: Unused.
component: Unused.
Returns:
A tuple ``(list_files, list_dates)``, each a single-entry
dictionary keyed by the simulation start date (empty dicts if the
file is not found).
"""
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