pylag.model module

Model objects are used to calculate changes in particle states during the course of a typical simulation. They hold and manage all particle data.

Note

model is implemented in Cython. Only a small portion of the API is exposed in Python with accompanying documentation.

class pylag.model.OPTModel(config, data_reader)

Bases: object

Offline Particle Tracking Model

This class provides a generic interface for setting up and running a particle tracking simulation. This includes:

  1. Creating a particle seed

  2. Reading input data

  3. Updating particle positions

  4. Returning diagnostic data

Parameters
get_diagnostics(self, time)

Get particle diagnostics

Parameters

time (float) – The current time.

Returns

diags – Dictionary holding particle diagnostic data.

Return type

dict

get_grid_names(self)

Return a list of grid names

get_particle_data(self)

Get particle data

Pool, sort and return data describing the basic state of each particle. The main purpose of this function is to assist with the creation of restart files.

Returns

all_particle_data – Dictionary holding particle data.

Return type

dict

read_input_data(self, time)

Update reading frames for FVCOM data fields.

Parameters

time (float) – The current time.

seed(self, time)

Set particle positions equal to those of the particle seed.

Create the particle seed if it has not been created already. Make an active copy of the particle seed.

Parameters

time (float) – The current time.

set_particle_data(self, group_ids, x1_positions, x2_positions, x3_positions)

Initialise memory views for data describing the particle seed.

Parameters
  • group_ids (ndarray, int) – Particle groups IDs.

  • x1_positions (ndarray, float) – Particle x-positions.

  • x2_positions (ndarray, float) – Particle y-positions.

  • x3_positions (ndarray, float) – Particle z-positions.

setup_input_data_access(self, start_datetime, end_datetime)

Setup access to FVCOM time dependent variables.

Parameters
  • start_datime (Datetime) – The simulation start date and time.

  • end_datime (Datetime) – The simulation end date and time.

update(self, DTYPE_FLOAT_t time)

Compute and update each particle’s position.

Cycle over the particle set, updating the position of only those particles that remain in the model domain. If a particle has beached update its status.

Parameters

time (float) – The current time.