gnome.environment.environment

Environment objects

Classes

EnvironmentMeta

Environment

A base class for all classes in environment module.

Water

Define the environmental conditions for a spill, like water_temperature,

Functions

env_from_netCDF([filename, dataset, grid_file, ...])

Returns a list of instances of environment objects that can be produced

ice_env_from_netCDF([filename])

A short function to generate a list of all the 'ice_aware' classes

get_file_analysis(filename)

grid_detection_report(filename)

Module Contents

class gnome.environment.environment.EnvironmentMeta(_name, _bases, _dct)

Bases: gnome.gnomeobject.GnomeObjMeta

class gnome.environment.environment.Environment(make_default_refs=True, *, timezone_offset=TZOffset(), **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

make_default_refs = True
array_types
property timezone_offset
abstract at(points, time, *, units=None, extrapolate=None, **kwargs)

Find the value of the property at positions P and 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

abstract property data_start
abstract property data_stop
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 step

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 its 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”

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)
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.

temperature = 300.0
salinity = 35.0
sediment = 0.005
wave_height = None
fetch = None
kinematic_viscosity = 1e-06
name = 'Water'

define as property in base class so all objects will have a name by default

property units
get(attr, unit=None)

return value in desired unit. If None, then return the value in SI units. The user_units 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

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.