pycif.plugins.datastreams.fields.oldlmdz_prescrconcs — API reference#
Configuration reference: oldlmdz_prescrconcs plugin
- pycif.plugins.datastreams.fields.oldlmdz_prescrconcs.fetch.fetch(ref_dir, ref_file, input_interval, target_dir, tracer=None, **kwargs)[source]#
Fetch legacy LMDZ4 prescribed-concentration files.
input_intervalis a mapping of key dates to lists of sub-dates; for each sub-date, callsfind_valid_file()to locate the two straddling files, links them intotarget_dir, and deduplicates the resulting file/date pairs.- Parameters:
ref_dir – directory where the original files are found.
ref_file – (template) name of the original files.
input_interval – mapping of key dates to the list of sub-dates covered under each key.
target_dir – directory where links to the original files are created.
tracer – unused, accepted for interface compatibility.
- Returns:
- for each key date, the deduplicated array of file
paths matching
list_dates.- list_dates: for each key date, the deduplicated, sorted array of
dates found by
find_valid_file().
- Return type:
list_files
- pycif.plugins.datastreams.fields.oldlmdz_prescrconcs.get_domain.get_domain(ref_dir, ref_file, input_interval, target_dir, tracer=None)[source]#
Build the legacy LMDZ4 72x96x19 Domain from a reference concentration file.
Looks for a reference NetCDF file in
ref_dir, either an exact match forref_fileor the first file whose name matchesref_fileused as a date-format pattern, readslat/lon(flipping latitude to increasing order if needed), computes grid-cell corners manually (with an ad hoc pole adjustment), and hardcodes the 19-level hybrid-sigma coefficients (sigma_a/sigma_b) when the file’spresnivsdimension has size 19, since they are not available in the input files.Warning
If
presnivssize differs from 19,sigma_a/sigma_bare never assigned in this function, which raises an unbound-variable error rather than a domain-specific one.- Parameters:
ref_dir – directory to search for a reference file.
ref_file – exact file name, or a date-format pattern used to match one of the files in
ref_dir.input_interval – unused, accepted for interface compatibility.
target_dir – unused, accepted for interface compatibility.
tracer – unused, accepted for interface compatibility.
- Returns:
the legacy LMDZ4 grid domain.
- Return type:
- Raises:
CifError – if no reference file can be found in
ref_dir.
- pycif.plugins.datastreams.fields.oldlmdz_prescrconcs.read.read(self, name, tracdir, tracfile, varnames, dates, comp_type=None, model=None, **kwargs)[source]#
Get prescribed concentrations from pre-computed fields and load them into a pyCIF variable.
Reconstructs the in-file timestamps manually from
time_counter(expressed in seconds since the first day of the month), because the 360-day calendar used in these files is not handled by xarray’sdecode_times, then selects the matching time index; the result is flipped along latitude if the file’s latitude axis is decreasing. Unlike photolysis rates, the concentration variable name is taken directly fromvarnamesrather than resolved via the chemical scheme.- Parameters:
self – the prescribed concentrations Plugin
name – the name of the component
tracdir – raw data directory and file format
tracfile – raw data directory and file format
varnames – name of the concentration variable to read from the file
dates – list of dates to extract
comp_type – unused, accepted for interface compatibility
model – unused, accepted for interface compatibility
- Returns:
xarray.DataArray with dims
(time, lev, lat, lon).
- pycif.plugins.datastreams.fields.oldlmdz_prescrconcs.utils.find_valid_file(ref_dir, file_format, dd)[source]#
Find the two files/dates straddling date
ddinref_dir.Lists files in
ref_dirmatchingfile_formatfor the same year/month asdd(plus the previous month ifddfalls on hour 0), expands each matching file into the list of hourly dates it covers, then returns the closest file/date at or beforeddand the closest at or afterdd.- Parameters:
ref_dir – directory to search for files.
file_format – date-format pattern used to parse file names and match them against
dd.dd – the date to find files around.
- Returns:
A tuple
([file_ref1, file_ref2], [date_ref1, date_ref2])with the file paths and dates immediately before and after (or equal to)dd.- Raises:
CifError – if no file in
ref_dirmatchesfile_format.