gnome.environment.environment
¶
module contains objects that contain weather related data. For example, the Wind object defines the Wind conditions for the spill
Module Contents¶
Classes¶
A base class for all classes in environment module. |
|
Define the environmental conditions for a spill, like water_temperature, |
Functions¶
|
Returns a list of instances of environment objects that can be produced |
|
A short function to generate a list of all the 'ice_aware' classes |
|
|
|
Attributes¶
- class gnome.environment.environment.EnvironmentMeta(_name, _bases, _dct)¶
- class gnome.environment.environment.Environment(make_default_refs=True, **kwargs)¶
Bases:
gnome.gnomeobject.GnomeId
A base class for all classes in environment module. This is primarily to define a dtype such that the OrderedCollection defined in the Model object requires it.
base class for environment objects
- Parameters:
name=None –
- abstract property data_start¶
- abstract property data_stop¶
- _subclasses = []¶
- _ref_as = 'environment'¶
- __metaclass__¶
- abstract at(points, time, units=None)¶
Find the value of the property at positions P at time T
- Parameters:
points (Nx3 numpy array) – Coordinates to be queried (lon, lat, depth)
time (datetime.datetime object) – The time at which to query these points (T)
units=None – units the values will be returned in (or converted to) if None, the default units for the environment type will be used.
extrapolate=False – if True, extrapolation will be supported
- Returns:
returns a Nx2 or Nx3 array of interpolated values
- Return type:
Nx2 or Nx3 numpy array of values
- prepare_for_model_run(model_time)¶
Override this method if a derived environment class needs to perform any actions prior to a model run
- prepare_for_model_step(model_time)¶
Override this method if a derived environment class needs to perform any actions prior to a model run
- post_model_run()¶
Override this method if a derived environment class needs to perform any actions after a model run is complete (StopIteration triggered)
- gnome.environment.environment.env_from_netCDF(filename=None, dataset=None, grid_file=None, data_file=None, _cls_list=None, **kwargs)¶
Returns a list of instances of environment objects that can be produced from a file or dataset. These instances will be created with a common underlying grid, and will interconnect when possible. For example, if an IceAwareWind can find an existing IceConcentration, it will use it instead of instantiating another. This function tries ALL gridded types by default. This means if a particular subclass of object is possible to be built, it is likely that all it’s parents will be built and included as well.
If you wish to limit the types of environment objects that will be used, pass a list of the types using “_cls_list” kwarg
- gnome.environment.environment.ice_env_from_netCDF(filename=None, **kwargs)¶
A short function to generate a list of all the ‘ice_aware’ classes for use in env_from_netCDF (this excludes GridCurrent, GridWind, GridTemperature, etc.)
- gnome.environment.environment.get_file_analysis(filename)¶
- gnome.environment.environment.grid_detection_report(filename)¶
- gnome.environment.environment._valid_temp_units¶
- gnome.environment.environment._valid_dist_units¶
- gnome.environment.environment._valid_kvis_units¶
- gnome.environment.environment._valid_density_units¶
- gnome.environment.environment._valid_salinity_units = ('psu',)¶
- gnome.environment.environment._valid_sediment_units¶
- class gnome.environment.environment.Water(temperature=300.0, salinity=35.0, sediment=0.005, wave_height=None, fetch=None, units=None, name='Water')¶
Bases:
Environment
Define the environmental conditions for a spill, like water_temperature, atmos_pressure (most likely a constant)
Defined in a Serializable class since user will need to set/get some of these properties through the client
Assume units are SI for all properties. ‘units’ attribute assumes SI by default. This can be changed, but initialization takes SI.
- property density¶
return the density based on water salinity and temperature. The salinity is in ‘psu’; it is not being converted to absolute salinity units - for our purposes, this is sufficient. Using gsw.rho() internally which expects salinity in absolute units.
- property units¶
- _ref_as = 'water'¶
- _schema¶
- _units_type¶
- _si_units¶
- __str__¶
- __repr__()¶
Return repr(self).
- get(attr, unit=None)¶
return value in desired unit. If None, then return the value in SI units. The user_unit are given in ‘units’ attribute and each attribute carries the value in as given in these user_units.
- set(attr, value, unit)¶
provide a corresponding set method that requires value and units The attributes can be directly set. This function just sets the desired property and also updates the units dict
- _get_density(salinity, temp)¶
use lru cache so we don’t recompute if temp is not changing
- _convert_sediment_units(from_, to)¶
used internally to convert to/from sediment units.