pycif.plugins.datastreams.fluxes.VPRM1km_nc — API reference

pycif.plugins.datastreams.fluxes.VPRM1km_nc — API reference#

Configuration reference: VPRM1km_nc plugin

pycif.plugins.datastreams.fluxes.VPRM1km_nc.fetch.fetch(ref_dir, ref_file, input_interval, target_dir, tracer=None, **kwargs)[source]#

Fetch VPRM1km daily flux files and build the hourly date intervals they cover.

Lists candidate daily files at tracer.file_freq, builds 24 hourly [start, end] intervals per day, and links each existing file into target_dir.

Parameters:
  • ref_dir (str) – Directory containing the reference input files.

  • ref_file (str) – Filename pattern of the input files (a strftime format string).

  • input_interval (list[datetime.datetime]) – [date_i, date_f] simulation interval to cover.

  • target_dir (str) – Directory where the resolved files are linked.

  • tracer – The flux tracer plugin, providing file_freq.

Returns:

(list_files, list_dates), each keyed by the candidate file date, mapping to a single-element list with the resolved file path and the list of hourly [start, end] date-interval pairs within that day.

Return type:

tuple[dict, dict]

pycif.plugins.datastreams.fluxes.VPRM1km_nc.get_domain.get_domain(ref_dir, ref_file, input_interval, target_dir, tracer=None)[source]#

Build the VPRM1km domain from the corners file (and, if irregular, a data file).

Reads tracer.corners_file; if tracer.regular, derives sorted unique latitude/longitude corner vectors and cell centers via numpy.meshgrid. Otherwise (irregular grid), reads the XLONG_C/ XLAT_C corner arrays from the corners file, and locates a matching data file (by exact name, or by pattern-matching ref_file against filenames in ref_dir) to read the lon/lat cell centers. Builds a surface-only (nlev=1) Domain in both cases.

Parameters:
  • ref_dir (str) – Directory containing the corners file and, for the irregular case, the reference data file.

  • ref_file (str) – Filename (or strftime pattern) of the reference data file, used only for the irregular grid case.

  • input_interval (list) – Unused directly, kept for interface consistency.

  • target_dir (str) – Unused directly, kept for interface consistency.

  • tracer – The flux tracer plugin, providing corners_file and regular.

Returns:

a surface-only Domain built from the corners (and, if irregular, data) file.

Return type:

Domain

Raises:

CifError – If no matching reference data file is found for the irregular grid case.

pycif.plugins.datastreams.fluxes.VPRM1km_nc.read.read(self, name, varnames, dates, files, interpol_flx=False, comp_type=None, tracer=None, **kwargs)[source]#

Get fluxes from VPRM1km daily files and load them into a pyCIF variable.

For each date/file pair (re-opening only when the file path changes), reads the full requested variable field for the day and extends it across all 24 hourly timestamps of that day.

Parameters:
  • name (str) – Unused directly, kept for interface consistency with other flux plugins.

  • varnames (str) – Name of the variable to read in the file.

  • dates (list) – list of [start, end] date intervals to extract; only the start of each interval is used to build the hourly output timestamps.

  • files (list) – list of files matching dates

  • interpol_flx (bool) – Unused, kept for interface consistency.

  • comp_type – Unused, kept for interface consistency.

  • tracer – Unused directly, kept for interface consistency.

Returns:

the flux data with dimensions

(time, lev, lat, lon).

Return type:

xr.DataArray

pycif.plugins.datastreams.fluxes.VPRM1km_nc.utils.find_valid_file(ref_dir, file_format, dd, ref_dir_next, ref_dir_previous=False)[source]#

Find the nearest available files bracketing a given date.

Lists candidate files in ref_dir matching file_format, extending the search to ref_dir_next/ref_dir_previous when dd is close to a month boundary (within 3 hours), sorts them by parsed date, and returns the file/date pair nearest to dd on-or-before and on-or-after it.

Parameters:
  • ref_dir (str) – Directory to search for candidate files.

  • file_format (str) – strftime-style filename pattern used both to match files and parse their embedded date.

  • dd (datetime.datetime) – Reference date to bracket.

  • ref_dir_next (str) – Directory for the following month, searched in addition to ref_dir when dd is near a month boundary.

  • ref_dir_previous (str or bool) – Directory for the previous month, searched in addition to ref_dir when dd is near a month boundary; False to skip.

Returns:

([file1, file2], [dd1, dd2]), the paths and adjusted dates of the nearest file on-or-before and on-or-after dd.

Return type:

tuple[list[str], list[datetime.datetime]]

Raises:

CifError – If no candidate files are found at all.

pycif.plugins.datastreams.fluxes.VPRM1km_nc.write.write(self, name, flx_file, flx, mode='a', **kwargs)[source]#

Not implemented; always raises, since writing VPRM1km fluxes is not supported.