opendrift.readers.basereader.structured ======================================= .. py:module:: opendrift.readers.basereader.structured Attributes ---------- .. autoapisummary:: opendrift.readers.basereader.structured.logger Classes ------- .. autoapisummary:: opendrift.readers.basereader.structured.StructuredReader Module Contents --------------- .. py:data:: logger .. py:class:: StructuredReader Bases: :py:obj:`opendrift.readers.basereader.variables.Variables` A structured reader. Data is gridded on a regular grid. Used by e.g.: :class:`opendrift.readers.reader_netCDF_CF_generic.Reader`. Attributes: projected: is `True` if :class:`.fakeproj.fakeproj` is used because of missing projection information. The data points are assumed to be approximately equidistant on the surface (i.e. in meters). clipped: pixels to to remove along boundary (e.g. in case of bad data). .. seealso:: :py:mod:`opendrift.readers` .. py:attribute:: clipped :value: 0 .. py:attribute:: x :value: None .. py:attribute:: y :value: None .. py:attribute:: interpolation :value: 'linearNDFast' .. py:attribute:: convolve :value: None .. py:attribute:: save_interpolator :value: None .. py:attribute:: interpolator_filename :value: None .. py:attribute:: __lonlat2xy_parallel__ :value: None .. py:attribute:: __disable_parallel__ :value: False .. py:attribute:: var_block_before .. py:attribute:: var_block_after .. py:method:: get_variables(variables, time=None, x=None, y=None, z=None) :abstractmethod: 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. .. py:method:: prepare(extent, start_time, end_time, max_speed) Prepare reader for given simulation coverage in time and space. .. py:method:: set_convolution_kernel(convolve) Set a convolution kernel or kernel size (of array of ones) used by `get_variables` on read variables. .. py:method:: __convolve_block__(env) Convolve arrays with a kernel, if reader.convolve is set .. py:method:: lon_range() .. py:method:: _get_variables_interpolated_(variables, profiles, profiles_depth, time, reader_x, reader_y, z) This method _must_ be implemented by every reader. Usually by subclassing one of the reader types (e.g. :class:`structured.StructuredReader`). Arguments are in _native projection_ of reader. .. seealso: * :meth:`get_variables_interpolated_xy`. * :meth:`get_variables_interpolated`. .. py:method:: __check_env_arrays__(env) For the StructuredReader the variables are checked before entered into the ReaderBlock interpolator. This methods makes the second check a no-op. .. seealso:: :meth:`.variables.Variables.__check_env_arrays__`. .. py:method:: xy2lonlat(x, y) Calculate x,y in own projection from given lon,lat (scalars/arrays). .. py:method:: lonlat2xy(lon, lat) Calculate lon,lat from given x,y (scalars/arrays) in own projection. .. py:method:: pixel_size() .. py:method:: get_ocean_depth_area_volume(lonmin, lonmax, latmin, latmax) Get depth, area and volume of ocean basin within given coordinates .. py:method:: _coverage_unit_() .. py:method:: _bbox_(x, y) Find bounding box on grid containing points (x, y) .. py:method:: _make_projected_grid_(lon, lat, eq_eps=0.1) Make the projected grid in cases where `lon` and `lat` are present as 2D variables, but not `x` and `y` and assert that it is approximately equidistant. Args: eq_eps: tolerance for equidistance checks. .. py:method:: __validate_projected_grid__(eq_eps=0.1) Validate that the projected grid is approximately equidistant. Args: eq_eps: tolerance for equidistance checks. Raises: AssertionError if not equidistant within `eq_eps`. .. py:method:: _slice_variable_(var, indxTime=None, indy=None, indx=None, indz=None, indrealization=None) Slice variable depending on number of dimensions available. Args: All arguments can be `slice` objects or index. Returns: `var` sliced using the slices or indexes necessary to use depending on number of dimensions available. Raises: Unsupported number of dimensions (outside 2..5) raises an exception.