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
):
"""Fetch Initial condition files and dates for LMDZ.
Args:
ref_dir (str): Path to the data
ref_file (str): File format of the data
input_interval (list[datetime.datetime]): Date range
target_dir (str): Where to link the data
tracer (_type_, optional): _description_. Defaults to None.
Returns:
(list_files, list_dates): tuple of dictionaries describing input dates and corresponding files
"""
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