opendrift.readers.basereader.structured

Module Contents

Classes

StructuredReader

A structured reader. Data is gridded on a regular grid. Used by e.g.:

opendrift.readers.basereader.structured.logger
class opendrift.readers.basereader.structured.StructuredReader[source]

Bases: opendrift.readers.basereader.variables.Variables

A structured reader. Data is gridded on a regular grid. Used by e.g.: opendrift.readers.reader_netCDF_CF_generic.Reader.

Attributes:

projected: is True if 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).

Initialize self. See help(type(self)) for accurate signature.

projected
shape
clipped = 0
x
y
var_block_before
var_block_after
interpolation = linearNDFast
convolve
__lonlat2xy_parallel__
__disable_parallel__ = False
abstract get_variables(self, 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.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.

set_convolution_kernel(self, convolve)[source]

Set a convolution kernel or kernel size (of array of ones) used by get_variables on read variables.

__convolve_block__(self, env)[source]

Convolve arrays with a kernel, if reader.convolve is set

lon_range(self)[source]
_get_variables_interpolated_(self, variables, profiles, profiles_depth, time, reader_x, reader_y, z)[source]

This method _must_ be implemented by every reader. Usually by subclassing one of the reader types (e.g. structured.StructuredReader).

Arguments are in _native projection_ of reader.

__check_env_arrays__(self, env)[source]

For the StructuredReader the variables are checked before entered into the ReaderBlock interpolator. This methods makes the second check a no-op.

xy2lonlat(self, x, y)[source]

Calculate x,y in own projection from given lon,lat (scalars/arrays).

lonlat2xy(self, lon, lat)[source]

Calculate lon,lat from given x,y (scalars/arrays) in own projection.

pixel_size(self)[source]
_coverage_unit_(self)[source]
_bbox_(self, x, y)[source]

Find bounding box on grid containing points (x, y)

_make_projected_grid_(self, lon, lat, eq_eps=0.1)[source]

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.

__validate_projected_grid__(self, eq_eps=0.1)[source]

Validate that the projected grid is approximately equidistant.

Args:

eq_eps: tolerance for equidistance checks.

Raises:

AssertionError if not equidistant within eq_eps.

_slice_variable_(self, var, indxTime=None, indy=None, indx=None, indz=None, indrealization=None)[source]

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.