gnome.array_types¶
Module contains array types that a mover may need based on the data movers needs
- ** NOTE: **
These are global declarations
For instance: If the PointWindMover that uses array_types.PointWindMover updates the properties of ‘windages’ ArrayType, it will change it universally.
The user/mover should not need to change dtype or shape internally. If these need to change, it should be done here.
The initial_value can be changed by movers since that’s only used when elements are released. For most arrays, that is currently 0.
As a convention, when a dict defines these array_types, best to use the name of the array_type as the ‘key’. When other modules, primarily element_type, look for numpy array in data_arrays with associated array_types, it will assume the ‘key’ is the name of the array_types.
todo: For array_types like mass_components and other array_types used by weathering objects, the shape is set at runtime. Since this changes depending on each type of spill that is modeled, need to rethink this global definition for these array_types. Currently, these ArrayTypes are defined with ‘shape’=None. Add optional shape argument to ArrayTypes().initialize() to handle the case where shape attribute is None
Attributes¶
Classes¶
Object used to capture attributes of numpy data array for elements |
|
The 'id' array assigns a unique int for every particle released. |
|
Object used to capture attributes of numpy data array for elements |
Functions¶
|
Returns and instance of an array type appropriate for name, or None if one |
Module Contents¶
- class gnome.array_types.ArrayType(shape, dtype, name, initial_value=0)¶
Bases:
gnome.AddLogger
Object used to capture attributes of numpy data array for elements
An ArrayType specifies how data arrays associated with elements are defined.
constructor for ArrayType
- Parameters:
shape (tuple of integers) – shape of the numpy array
dtype (numpy dtype) – numpy datatype contained in array
- shape¶
- dtype¶
- initial_value = 0¶
- name¶
- initialize_null(shape=None)¶
initialize array with 0 elements. Used so SpillContainer can initializes all arrays with 0 elements. Used when the model is rewound. The purpose is to show all data_arrays even if model is not yet running or no particles have been released
- initialize(num_elements, shape=None, initial_value=None)¶
Initialize a numpy array with the dtype and shape specified. The length of the array is given by num_elements and spill is given as input if the initialize function needs information about the spill to initialize
- Parameters:
num_elements – number of elements so size of array to initialize
Optional parameter
- Parameters:
shape=None – If this is None then use self.shape to determine size of array to create, else use this parameter. This is primarily used for ArrayTypes where either object’s shape attribute is None or we want to override the object’s predefined ‘shape’ during initialization
- split_element(num, value, *args)¶
define how an LE gets split for specified ArrayType
- Parameters:
num (int) – number of elements that current value should get split into
value (this must have shape and dtype equal to self.shape and self.dtype) – the current value that is replicated
*args –
accept more arguments as derived class may divide LE on split and in this case, user can specify a list of fractions for this division.
- class gnome.array_types.IdArrayType(shape, dtype, name, initial_value=0)¶
Bases:
ArrayType
The ‘id’ array assigns a unique int for every particle released.
constructor for ArrayType
- Parameters:
shape (tuple of integers) – shape of the numpy array
dtype (numpy dtype) – numpy datatype contained in array
- initialize(num_elements, *args)¶
overrides base initialize functionality to output a range of values
self.initial_value to num_elements + self.initial_value
This is only used for ‘id’ of particle. shape attribute and initial_value are ignored since you always get an array of shape (num_elements,) Define *args to keep method signature the same
- split_element(num, value, *args)¶
split elements into num and assign ‘value’ to all of them
- class gnome.array_types.ArrayTypeDivideOnSplit(shape, dtype, name, initial_value=0)¶
Bases:
ArrayType
Object used to capture attributes of numpy data array for elements
An ArrayType specifies how data arrays associated with elements are defined.
constructor for ArrayType
- Parameters:
shape (tuple of integers) – shape of the numpy array
dtype (numpy dtype) – numpy datatype contained in array
- split_element(num, value, l_frac=None)¶
define how an LE gets split for specified ArrayType. l_frac if given should sum to 1.0
- Parameters:
num (int) – number of elements that current value should get split into
value (this must have shape and dtype equal to self.shape and self.dtype) – the current value that is replicated
l_frac – user can specify a list of fractions for this division - if None, then evenly divide ‘value’ into ‘num’. sum(l_frac) = 1.0
- gnome.array_types.get_array_type(name)¶
Returns and instance of an array type appropriate for name, or None if one does not exist
- gnome.array_types.gat¶
- gnome.array_types.reset_to_defaults(at)¶
- gnome.array_types.DEFAULT_ARRAY_TYPES = ['positions', 'next_positions', 'last_water_positions', 'status_codes', 'mass', 'init_mass',...¶
- gnome.array_types.default_array_types¶