pylag.particle_cpp_wrapper module
This module provides a Python friendly API for interacting with Particle objects. The code for the latter is implemented in C++. Particle objects include a set of attributes that describe their state and location within a given domain.
- class pylag.particle_cpp_wrapper.ParticleSmartPtr
Bases:
object
Python object for managing the memory associated with Particle objects
This class ties the lifetime of a Particle object allocated on the heap to the lifetime of a ParticleSmartPtr object.
- age
The age of the particle in seconds
- fixed_depth
The fixed depth below the surface that particle’s are restored to
- get_all_boolean_flags(self)
Get all boolean flags
- Returns
boolean_flags – Boolean flags stored in a dictionary.
- Return type
- get_all_diagnostic_variables(self)
Get all diagnostic variables
- Returns
diagnostic_variables – Diagnostic variables stored in a dictionary.
- Return type
- get_all_host_horizontal_elems(self)
Get all host elements for the given grid
- Returns
host_elements – The host elements stored in a dictionary by grid name.
- Return type
- get_all_parameters(self)
Get all parameters
- Returns
parameters – Parameters stored in a dictionary.
- Return type
- get_all_state_variables(self)
Get all state variables
- Returns
state_variables – State variables stored in a dictionary.
- Return type
- get_boolean_flag(self, name)
Get diagnostic variable
- get_diagnostic_variable(self, name)
Get diagnostic variable
- get_host_horizontal_elem(self, grid)
Get host element for the given grid
- get_parameter(self, name)
Get parameter
- get_particle_data(self)
Get particle data
Return data describing the particle’s basic state. Do not return any derived data (e.g. particle local coordinates). The purpose is to return just enough data to make it possible to recreate the particle at some later time (e.g. from a restart file).
- Returns
data – Dictionary containing data that describes the particle’s basic state.
- Return type
- get_phi(self, grid)
Get local coordinates for the given grid
- Parameters
grid (str) – The name of the grid.
- Returns
phi – Particle local coordinates for the given grid.
- Return type
1D NumPy array
- get_state_variable(self, name)
Get state variable
- in_domain
Flag identifying whether or not the particle resides within the model domain (1 - yes; 0 - no)
- in_vertical_boundary_layer
Flag signifying whether or not the particle resides in either the top or bottom boundary layers
- is_alive
Boolean flag indicating whether the particle is alive or dead
- is_beached
Flag identifying whether or not the particle is beached (1 - yes; 0 - no)
- k_layer
Index identifying the k-layer the particle currently resides in
- k_lower_layer
Index identifying the k-level immediately below the particle
- k_upper_layer
Index identifying the k-level immediately above the particle
- land_boundary_encounters
The number of times the particle has crossed a land boundary
- omega_interfaces
Vertical interpolation coefficient for variables defined at the interfaces between k-levels
- omega_layers
Vertical interpolation coefficient for variables defined at the interfaces between k-layers
- restore_to_fixed_depth
Flag signifying whether a particle’s position is restored to a fixed depth
- set_all_boolean_flags(self, boolean_flags)
Set all boolean flags
- Parameters
boolean_flags (dict) – Dictionary of boolean flags {name: value}
- set_all_diagnostic_variables(self, diagnostic_variables)
Set all diagnostic variables
- Parameters
diagnostic_variables (dict) – Dictionary of diagnostic variables {name: value}
- set_all_host_horizontal_elems(self, host_elements)
Set host elements for all grids
- Parameters
host_elements (dict) – Dictionary of host elements {grid_name: host}
- set_all_parameters(self, parameters)
Set all parameters
- Parameters
parameters (dict) – Dictionary of parameters {name: value}
- set_all_phis(self, phis)
Set local coordinates for all grids
- Parameters
phis (dict) – Dictionary of local coords {grid_name: [phi1, phi2, [phi3]}
- set_all_state_variables(self, state_variables)
Set all state variables
- Parameters
state_variables (dict) – Dictionary of state variables {name: value}
- set_boolean_flag(self, name, value)
Set diagnostic variable
- set_diagnostic_variable(self, name, value)
Set diagnostic variable
- set_host_horizontal_elem(self, grid, host)
Set host element for the given grid
- set_parameter(self, name, value)
Set generic parameter
- set_phi(self, grid, phi)
Set local coordinates for the given grid
- Parameters
grid (str) – The name of the grid.
phi (1D NumPy array) – 1D array of particle local coordinates.
- set_state_variable(self, name, value)
Set state variable
- status
The particle’s status (0 - okay; 1 - error)
- x1
The particle’s x1-coordinate
- x2
The particle’s x2-coordinate
- x3
The particle’s x1-coordinate
- pylag.particle_cpp_wrapper.to_string_wrapper(ParticleSmartPtr particle)
Python wrapper for to_string