:py:mod:`opendrift.readers.reader_grib2` ======================================== .. py:module:: opendrift.readers.reader_grib2 Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: opendrift.readers.reader_grib2.Reader Attributes ~~~~~~~~~~ .. autoapisummary:: opendrift.readers.reader_grib2.logger .. py:data:: logger .. py:class:: Reader(filename, proj4=None, engine='cfgrib') Bases: :py:obj:`opendrift.readers.basereader.BaseReader`, :py:obj:`opendrift.readers.basereader.structured.StructuredReader` An abstract reader. Implementors provide a method to read data and specify how it is interpolated. This class inherits :class:`.variables.Variables` which inherits :class:`.variables.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 for :py:mod:`opendrift.models.basemodel`, it defines the abstract interface to :meth:`.variables.Variables._get_variables_interpolated_` which reader-implementations must provide (_usually_ through one of the main reader-types, see: :py:mod:`opendrift.readers`). .. seealso:: :py:mod:`opendrift.readers`. :py:mod:`.variables`. 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. .. py:attribute:: dataset .. py:attribute:: variables .. py:method:: get_variables(requested_variables, time=None, x=None, y=None, z=None) Obtain a _block_ of values of the requested variables at all positions (x, y, z) closest to given time. These will be stored in :class:`opendrift.readers.interpolation.structured.ReaderBlock` and 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.