opendrift.models.basemodel.environment
Attributes
Classes
Utility class for measuring total time spent in various steps in a class |
Module Contents
- opendrift.models.basemodel.environment.logger
- class opendrift.models.basemodel.environment.Environment(required_variables, _config)[source]
Bases:
opendrift.timer.Timeable
,opendrift.config.Configurable
Utility class for measuring total time spent in various steps in a class throughout program execution.
- readers: OrderedDict
- priority_list: OrderedDict
- required_variables: Dict
- discarded_readers: Dict
- proj_latlon
- __finalized__ = False
- _config
- required_profiles
- desired_variables
- finalize(simulation_extent=None, start=None, end=None)[source]
Prepare environment for simulation.
Args:
simulation_extent: The expected extent of the simulation.
start: Expected start time of simulation.
end: Expected end time of simulation.
- add_readers_from_list(urls, timeout=10, lazy=True, variables=None)[source]
Make readers from a list of URLs or paths to netCDF datasets
- add_reader(readers, variables=None, first=False)[source]
Add one or more readers providing variables used by this model.
Method may be called subsequently to add more readers for other variables.
- Args:
readers: one or more (list) Reader objects.
variables (optional): list of strings of standard_name of variables to be provided by this/these reader(s). first: Set to True if this reader should be set as first option
- get_reader_groups(variables=None)[source]
Find which groups of variables are provided by the same readers.
This function loops through ‘priority_list’ (see above) and groups all variables returned by the same readers in the same order. This allows asking readers for several variables simultaneously, improving performance. Used by method ‘get_environment’.
- Returns:
variable_groups: list of lists of (environment) variables. reader_groups: list of list of reader names, corresponding to each of the variable_groups.
- get_environment(variables, time, lon, lat, z, profiles=None, profiles_depth=None)[source]
Retrieve environmental variables at requested positions.
Args:
variables: list of variable names
time: time to get environment for
lon: array of longitudes
lat: array of latitudes
z: depth to get value for
profiles: list of variables for which profiles are needed
profiles_depth: depth of profiles in meters, as a positive number
- Updates:
- Buffer (raw data blocks) for each reader stored for performance:
[readers].var_block_before (last before requested time) [readers].var_block_after (first after requested time) - lists of one ReaderBlock per variable group: time, x, y, [vars]
- Returns:
- environment: recarray with variables as named attributes,
interpolated to requested positions/time.