opendrift.readers.basereader.variables
Attributes
Classes
Projection, spatial and temporal domain of reader. |
|
Handles reading and interpolation of variables. |
Functions
|
|
|
|
|
|
|
|
|
Module Contents
- opendrift.readers.basereader.variables.logger
- class opendrift.readers.basereader.variables.ReaderDomain[source]
Bases:
opendrift.timer.Timeable
Projection, spatial and temporal domain of reader.
- name = None
- proj4 = None
- proj = None
- lon = None
- lat = None
- xmin = None
- xmax = None
- ymin = None
- ymax = None
- zmin
- zmax
- delta_x = None
- delta_y = None
- shape = None
- start_time = None
- end_time = None
- time_step = None
- times = None
Setting this to True overrides temporal and spatial bounds checks. Also useful for readers that are constant and do not have a temporal dimension.
- always_valid = False
- covers_positions_xy(x, y, z=0)[source]
Return indices of input points covered by reader.
Arguments in native projection of reader.
- modulate_longitude(lons)[source]
Modulate the input longitude to the domain supported by the reader.
- domain_grid(npoints=1000)[source]
Return arrays of lon,lat points spread evenly over reader domain.
- check_arguments(variables, time, x, y, z)[source]
Check validity of arguments input to method get_variables.
Checks that requested positions and time are within coverage of this reader, and that it can provide the requested variable(s). Returns the input arguments, possibly modified/corrected (below)
- Arguments:
See function get_variables for definition.
- Returns:
variables: same as input, but converted to list if given as string.
time: same as input, or start_time of reader if given as None.
x, y, z: same as input, but converted to ndarrays if given as scalars.
- outside: boolean array which is True for any particles outside
the spatial domain covered by this reader.
Raises:
ValueError:
if requested time is outside coverage of reader.
if all requested positions are outside coverage of reader.
- opendrift.readers.basereader.variables.land_binary_mask_from_ocean_depth(env, in_name=None, out_name=None)[source]
- opendrift.readers.basereader.variables.wind_from_speed_and_direction(env, in_name, out_name)[source]
- opendrift.readers.basereader.variables.vector_from_speed_and_direction(env, in_name, out_name)[source]
- class opendrift.readers.basereader.variables.Variables[source]
Bases:
ReaderDomain
Handles 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:
- abstract _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