pycif.plugins.datastreams.fields.grib2_ecmwf — API reference#
Configuration reference: grib2_ecmwf plugin
- pycif.plugins.datastreams.fields.grib2_ecmwf.fetch.fetch(ref_dir, ref_file, input_interval, target_dir, tracer=None, **kwargs)[source]#
- pycif.plugins.datastreams.fields.grib2_ecmwf.get_domain.make_octahedral_grid(lat, lon, file_corner)[source]#
- pycif.plugins.datastreams.fields.grib2_ecmwf.get_domain.get_domain(ref_dir, ref_file, input_interval, target_dir, tracer=None)[source]#
- pycif.plugins.datastreams.fields.grib2_ecmwf.read.read(self, name, varnames, dates, files, interpol_flx=False, comp_type=None, tracer=None, **kwargs)[source]#
- class pycif.plugins.datastreams.fields.grib2_ecmwf.utils.GribDataset(path: str | PathLike[str], read_keys: list[str] | None = None, filter_by_keys: dict[str, Any] | None = None)[source]#
Bases:
objectThis class is a wrapper around cfgrib to read GRIB files and access their variables and attributes.
Parameters#
- pathstr | path-like
Path to the GRIB file
- read_keyslist of str, optional
Additional keys to read, by default None
- filter_by_keysdict of str, optional
passed to cfgrib.open_file function, by default None
Raises#
- FileNotFoundError
If the file does not exist
Examples#
>>> ds = GribDataset( "path/to/file.grib", read_keys=["isOctahedral"], filter_by_keys={"edition": 1} ) >>> ds["latitude"] # get a variable array([...]) >>> ds.get_attr("isOctahedral") # get an attribute 1
- property variables: dict[str, Variable]#
Returns the variables mapping of the GRIB file
- get_var(varname: str) ndarray[source]#
Get one variable from the GRIB file as a Numpy array
Parameters#
- varnamestr
Variable name
Returns#
- np.ndarray
Variable data as Numpy array
Raises#
- KeyError
If the variable is not found in the GRIB file
- get_attr(attr: str, varname: str | None = None) Any[source]#
Get an attribute from the GRIB file. If varname is provided, looks for the attribute in the variable attributes, otherwise looks for it in all variables and returns the first one found.
Parameters#
- attrstr
Attribute name to get (will be prefixed by “GRIB_” to match cfgrib attributes)
- varnamestr, optional
variable name to restrict the search, by default None
Returns#
- Any
Attribute value
Raises#
- KeyError
If the attribute is not found.
- pycif.plugins.datastreams.fields.grib2_ecmwf.utils.find_valid_file(file_format, dd, time_freq, ref_dir, ref_dir_next, ref_dir_previous, delta_tolerance=1, cumul_variable=False, cumul_length=12)[source]#