pycif.plugins.datastreams.meteos.chimere_meteo — API reference#
Configuration reference: chimere_meteo plugin
- pycif.plugins.datastreams.meteos.chimere_meteo.fetch.fetch(ref_dir, ref_file, input_interval, target_dir, tracer=None, **kwargs)[source]#
Locate CHIMERE METEO.nc files and link them to the working directory.
Iterates over period-start dates covering
input_intervalattracer.file_freq, formatsref_dir/ref_filefor each period, and for each file that exists on disk records the hourly sub-periods it covers and symlinks it intotarget_dir. Periods whose file does not exist are silently skipped (absent from the returned dicts).- Parameters:
ref_dir – directory holding the CHIMERE METEO.nc files.
ref_file – strftime-style file name pattern (relative to
ref_dir), formatted once per period.input_interval – 2-element sequence
(datei, datef)giving the requested date range.target_dir – directory where matching files are symlinked.
tracer – the meteo datastream Plugin, used for
tracer.file_freq.
- Returns:
(list_files, list_dates), dicts keyed by each period’s start date.list_filesmaps each key to the (repeated) linked file path, one entry per hour in the period;list_datesmaps each key to the corresponding list of[hour, hour + 1h]date pairs.- Return type:
tuple
- pycif.plugins.datastreams.meteos.chimere_meteo.read.read(self, name, varnames, dates, files, interpol_flx=False, comp_type=None, ddi=None, **kwargs)[source]#
Read requested variables from CHIMERE METEO.nc files.
For each
[period, file]pair, readsvarnames(falling back tonameifvarnamesis empty) and theTimesvariable from the file, parsesTimesto locate the array index matching the requested period start (optionally offset fromddiinstead of the file’s own first time stamp), and extracts that hourly slice.- Parameters:
self – the meteo Plugin (uses
self.model.periodswhen raising the interpolation-misconfiguration error).name – name of the component/variable to read, used as a fallback when
varnamesis empty.varnames – name of the NetCDF variable to extract; must not be an empty string.
dates – list of
[start, end]date pairs, aligned withfiles.files – list of CHIMERE METEO.nc files to read from, aligned with
dates.interpol_flx (bool) – unused here (kept for interface consistency).
comp_type – unused here (kept for interface consistency).
ddi – optional reference date used instead of the file’s first
Timesentry to compute the hourly index to extract.
- Returns:
extracted data stacked over
dates, with dims(time, lev, lat, lon).- Return type:
xarray.DataArray
- Raises:
CifValueError – if
varnamesis an empty string, which happens when the meteo needs interpolating to another domain or temporal resolution but the input datavect does not list all required variables explicitly.
- pycif.plugins.datastreams.meteos.chimere_meteo.write.write(self, name, meteo_file, meteo_data, mode='a', **kwargs)[source]#
Write meteo/flux data to a CHIMERE-compatible METEO.nc file.
Switches to write mode if
meteo_filedoes not already exist, drops a singletonlevdimension, renames dimensions to CHIMERE conventions (Time,bottom_top,south_north,west_east), builds the CHIMERETimescharacter-string variable, injects the domain’s lon/lat and sigma vertical coordinates, duplicates the time axis when writingnphourm(to accelerate its reading), and, whenself.ncformatis"NETCDF4", applies zlib/float32 compression and chunks the data before dumping to disk.- Parameters:
self (Fluxes) – the meteo datastream Plugin (uses
self.domainfor coordinates andself.ncformatfor the output format).name (str) – name of the variable/component being written; special handling applies when equal to
"nphourm".meteo_file (str) – the file where to write the meteo/flux data.
meteo_data (xarray.Dataset) – meteo/flux data to write.
mode (str) –
"w"to overwrite,"a"to append; forced to"w"whenmeteo_filedoes not already exist.