Source code for pycif.plugins.datastreams.fields.tm5_ic.fetch
import os
import numpy as np
import pandas as pd
import datetime
from netCDF4 import Dataset
from .....utils import path
[docs]
def fetch(
ref_dir, ref_file, input_interval, target_dir, tracer=None, component=None
):
"""Fetch the single TM5 initial-condition file for the start date.
Args:
ref_dir: directory where the original file is found.
ref_file: (template) name of the original file.
input_interval: list of two dates; only the start date is used.
target_dir: directory where the link to the original file is
created.
tracer: unused, accepted for interface compatibility.
component: unused, accepted for interface compatibility.
Returns:
list_files: single-entry dict mapping the start date to a
one-element list with the file path.
list_dates: single-entry dict mapping the start date to
``[[start date, start date]]``.
"""
datei = input_interval[0]
filei = datei.strftime(f"{ref_dir}/{ref_file}")
list_files = {datei: [filei]}
list_dates = {datei: [[datei, datei]]}
# Fetching
target_file = f"{target_dir}/{os.path.basename(filei)}"
path.link(filei, target_file)
return list_files, list_dates