opendrift.readers.basereader
Submodules
Attributes
Classes
Handles reading and interpolation of variables. |
|
Combining two readers into a third one. You can use usual operators, |
|
Class to store and interpolate the output from a reader with data on a regular (structured) grid. |
|
An abstract reader. Implementors provide a method to read data and specify how it is interpolated. |
Package Contents
- opendrift.readers.basereader.logger
- class opendrift.readers.basereader.Variables[source]
Bases:
ReaderDomainHandles reading and interpolation of variables.
- variables = None
- derived_variables = None
- name = None
- buffer = 0
- environment_mappings
- prepare(extent, start_time, end_time, max_speed)[source]
Prepare reader for given simulation coverage in time and space.
- set_buffer_size(max_speed, time_coverage=None)[source]
Adjust buffer to minimise data block size needed to cover elements.
The buffer size is calculated from the maximum anticpated speed. Seeding over a large area or over longer time can easily cause particles to be located outside the block. This is not critical, but causes interpolation to be one-sided in time for the relevant particles.
Args:
max_speed (m/s): the maximum speed anticipated for particles. time_coverage (timedelta): the time span to cover
- static __check_variable_array__(name, variable)[source]
Ensure arrays are not masked arrays and that values are within valid ranges.
- __check_env_arrays__(env)[source]
Ensure arrays are not masked arrays and that values are within valid ranges.
See also
Disabled in StructuredReader because variables are valided before entered into interpolator:
- abstractmethod _get_variables_interpolated_(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.
- get_variables_interpolated_xy(variables, profiles=None, profiles_depth=None, time=None, x=None, y=None, z=None, rotate_to_proj=None)[source]
Get variables in native projection of reader.
- get_variables_interpolated(variables, profiles=None, profiles_depth=None, time=None, lon=None, lat=None, z=None, rotate_to_proj=None)[source]
get_variables_interpolated is the main interface to
opendrift.basemodel.OpenDriftSimulation, and is responsible for returning variables at the correct positions.Readers should implement
_get_variables_interpolated_().- Arguments:
- variables: string, or list of strings (standard_name) of
requested variables. These must be provided by reader.
profiles: List of variable names that should be returned for the range in profiles_depth.
profiles_depth: Profiles variables will be retrieved from surface and down to this depth. The exact z-depth are given by the reader and returned as z variable in env_profiles.
- time: datetime or None, time at which data are requested.
Can be None (default) if reader/variable has no time dimension (e.g. climatology or landmask).
lon: longitude, 1d array.
lat: latitude, 1d array, same length as lon.
- z: float or ndarray; vertical position (in meters, positive up)
of requested points. either scalar or same length as lon, lat. default: 0 m (unless otherwise documented by reader)
block: bool, see return below
rotate_to_proj: N/A
Returns:
(env, env_profiles)
Interpolated variables at x, y and z. env contains values at a fixed depth (z), while env_profiles contains depth-profiles in the range profile_depth for the variables listed in profiles for each element (in x, y). The exact depth is determined by the reader and specified in env_profiles[‘z’]. Thus variables in env_profiles are not interpolated in z-direction.
See also
- opendrift.readers.basereader.standard_names
- opendrift.readers.basereader.vector_pairs_xy = [['x_wind', 'y_wind', 'wind_speed', 'wind_to_direction', 'wind_from_direction'],...
- class opendrift.readers.basereader.Combine[source]
Combining two readers into a third one. You can use usual operators, but also more complex ones such as gaussian combining.
- class opendrift.readers.basereader.Filter[source]
- property variables: List[str]
- Abstractmethod:
- Return type:
List[str]
- class opendrift.readers.basereader.ReaderBlock(data_dict, interpolation_horizontal='linearNDFast', interpolation_vertical='linear', wrap_x=False)[source]
Class to store and interpolate the output from a reader with data on a regular (structured) grid.
- x
- y
- time
- data_dict
- wrap_x = False
- class opendrift.readers.basereader.BaseReader[source]
Bases:
variables.Variables,opendrift.readers.operators.ops.Combine,opendrift.readers.operators.ops.FilterAn 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).Common constructor for all readers
- __metaclass__
- verticalbuffer = 1
- variable_aliases
- xy2eastnorth_mapping
- number_of_fails = 0
- always_valid = False
- is_lazy = False
- _element_ID = None
- index_of_closest_z(requested_z)[source]
Return (internal) index of z closest to requested z.
Thickness of layers (of ocean model) are not assumed to be constant.
- indices_min_max_z(z)[source]
Return min and max indices of internal vertical dimension, covering the requested vertical positions. Needed when block is requested (True).
- Arguments:
z: ndarray of floats, in meters
- plot(variable=None, vmin=None, vmax=None, time=None, filename=None, title=None, buffer=1, lscale='auto', cmap=None, cbar_label=None)[source]
Plot geographical coverage of reader.