opendrift.readers.reader_grib2
Attributes
Classes
An abstract reader. Implementors provide a method to read data and specify how it is interpolated. |
Module Contents
- opendrift.readers.reader_grib2.logger
- class opendrift.readers.reader_grib2.Reader(filename, proj4=None, engine='cfgrib')[source]
Bases:
opendrift.readers.basereader.BaseReader,opendrift.readers.basereader.structured.StructuredReaderAn abstract reader. Implementors provide a method to read data and specify how it is interpolated.
This class inherits
variables.Variableswhich inheritsvariables.ReaderDomain. ReaderDomain is responsible for the extent and domain of the reader, including checking for out-of-bounds and projection conversion. Variables is responsible for returning interpolated data at the requests positions or profiles. Apart from coercing the returned data into the right type foropendrift.models.basemodel, it defines the abstract interface tovariables.Variables._get_variables_interpolated_()which reader-implementations must provide (_usually_ through one of the main reader-types, see:opendrift.readers).Grib file reader
Args:
filename: path to grib or grib2 file.
proj4: Optional projection override.
engine: grib engine used by xarray, default is cfgrib.
Returns: Grib-file reader.
- dataset = None
- variables = None
- name
- times
Setting this to True overrides temporal and spatial bounds checks. Also useful for readers that are constant and do not have a temporal dimension.
- start_time
- end_time
- proj4 = None
- variable_mapping
- lon
- lat
- get_variables(requested_variables, time=None, x=None, y=None, z=None)[source]
Obtain a _block_ of values of the requested variables at all positions (x, y, z) closest to given time. These will be stored in
opendrift.readers.interpolation.structured.ReaderBlockand accessed from there.- Arguments:
variables: list of variables.
time: datetime or None, time at which data are requested.
x, y: float or ndarrays; coordinates of requested points.
z: float or ndarray; vertical position (in meters, positive up)
- Returns:
Dictionary
keywords: variables (string) values: 2D ndarray bounding x and y.