:py:mod:`opendrift.models.basemodel.environment` ================================================ .. py:module:: opendrift.models.basemodel.environment Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: opendrift.models.basemodel.environment.Environment Attributes ~~~~~~~~~~ .. autoapisummary:: opendrift.models.basemodel.environment.logger .. py:data:: logger .. py:class:: Environment(required_variables, _config) Bases: :py:obj:`opendrift.timer.Timeable`, :py:obj:`opendrift.config.Configurable` Utility class for measuring total time spent in various steps in a class throughout program execution. .. py:attribute:: readers :type: OrderedDict .. py:attribute:: priority_list :type: OrderedDict .. py:attribute:: required_variables :type: Dict .. py:attribute:: discarded_readers :type: Dict .. py:attribute:: proj_latlon .. py:attribute:: __finalized__ :value: False .. py:method:: finalize(simulation_extent=None, start=None, end=None) 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. .. py:method:: prepare_readers(extent, start_time, end_time) .. py:method:: __generate_constant_readers__() .. py:method:: __add_auto_landmask__() .. py:method:: __assert_no_missing_variables__() .. py:method:: add_readers_from_file(filename, timeout=10, lazy=True) .. py:method:: add_readers_from_list(urls, timeout=10, lazy=True, variables=None) Make readers from a list of URLs or paths to netCDF datasets .. py:method:: add_reader(readers, variables=None, first=False) 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 .. py:method:: list_environment_variables() Return list of all variables provided by the added readers. .. py:method:: get_reader_groups(variables=None) 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. .. py:method:: _lazy_readers() .. py:method:: _unlazy_readers() .. py:method:: _initialise_next_lazy_reader() Returns reader if successful and None if no more readers .. py:method:: discard_reader_if_not_relevant(reader, time) .. py:method:: discard_reader(reader, reason) .. py:method:: missing_variables() Return list of all variables for which no reader has been added. .. py:method:: get_environment(variables, time, lon, lat, z, profiles=None, profiles_depth=None) 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. .. py:method:: get_variables_along_trajectory(variables, lons, lats, times, z=0)