Module Contents



Extending LagrangianArray for elements moving in 3 dimensions


Open source buoyant particle trajectory model based on OpenDrift.



class opendrift.models.oceandrift.Lagrangian3DArray(**kwargs)[source]

Bases: opendrift.elements.LagrangianArray

Extending LagrangianArray for elements moving in 3 dimensions The Particle may be buoyant and/or subject to vertical mixing buoyant bahaviour is described by terminal velocity

Initialises a LagrangianArray with given properties.


Keyword arguments (kwargs) with names corresponding to the OrderedDict ‘variables’ of the class, and corresponding values. The values must be ndarrays of equal length, or scalars. All (or none) variables must be given, unless a default value is specified in the OrderedDict ‘variables’ An empty object may be created by giving no input.

class opendrift.models.oceandrift.OceanDrift(*args, **kwargs)[source]

Bases: opendrift.models.basemodel.OpenDriftSimulation

Open source buoyant particle trajectory model based on OpenDrift.

Developed at MET Norway

Generic module for particles that move in 3 dimensions and may be to vertical turbulent mixing with the possibility for positive or negative buoyancy

Particles could be e.g. oil droplets, plankton, nutrients or sediments, Model may be subclassed for more specific behaviour.

Initialise OpenDriftSimulation

seed: integer or None. A given integer will yield identical

random numbers drawn each simulation. Random numbers are e.g. used to distribute particles spatially when seeding, and may be used by modules (subclasses) for e.g. diffusion. Specifying a fixed value (default: 0) is useful for sensitivity tests. With seed = None, different random numbers will be drawn for subsequent runs, even with identical configuration/input.

iomodule: name of module used to export data

default: netcdf, see for more alternatives. iomodule is module/filename without preceeding io_

loglevel: set to 0 (default) to retrieve all debug information.

Provide a higher value (e.g. 20) to receive less output. Use the string ‘custom’ to configure logging from outside.

logtime: if True, a time stamp is given for each logging line.

logtime can also be given as a python time specifier (e.g. ‘%H:%M:%S’)


Update positions and properties of elements.

simulate_trajectories(outfile, trajectories, number=1, wind_drift_factors=None, current_drift_factors=None, time_step=None, time_step_output=None, simulation_duration=None, simulation_interval=None)[source]
wind_drift_factor_from_trajectory_lw(drifters, wind_drift_factors, simulation_length, simulation_interval)[source]

Perform simulations and use skillscore to optimize wind_drift_factor

drifters: list of dictionaries with numpy arrays of ‘lon’ and ‘lat’

and list of datetimes

wind_drift_factors: the wind_drift_factors to use for simulations/optimalizations


Deactivate any vertical processes/advection

update_terminal_velocity(Tprofiles=None, Sprofiles=None, z_index=None)[source]

Calculate terminal velocity due to bouyancy from own properties and environmental variables. Sub-modules should overload this method for particle-specific behaviour


Move particles vertically according to vertical ocean current

Vertical advection by ocean currents is normally small compared to termical velocity


Move particles vertically according to their buoyancy


To be overloaded by subclasses, e.g. downward mixing of oil


To be overloaded by subclasses, e.g. radionuclides in sediments


To be overloaded by subclasses, e.g. downward mixing of oil

get_diffusivity_profile(model, depths)[source]

Mix particles vertically according to eddy diffusivity and buoyancy

Buoyancy is expressed as terminal velocity, which is the steady-state vertical velocity due to positive or negative buoyant behaviour. It is usually a function of particle density, diameter, and shape.

Vertical particle displacemend du to turbulent mixing is calculated using a random walk scheme” (Visser et al. 1996)

animate_vertical_distribution(depths=None, maxdepth=None, bins=50, filename=None, subsamplingstep=1)[source]

Function to animate vertical distribution of particles bins: number of bins in the histogram maxdepth: maximum depth subsamplingstep: speed-up the generation of the animation reducing the number of output frames fasterwriter: speed-up the writing to outpute file

plot_vertical_distribution(maxdepth=None, bins=None, maxnum=None)[source]

Function to plot vertical distribution of particles

maxdepth: maximum depth considered for the profile bins: number of bins between surface and maxdepth maxnum: range of bars in histogram is [0,maxnum]

plotter_vertical_distribution_time(ax=None, mask=None, dz=1.0, maxrange=-100, bins=None, step=1)[source]

Function to plot vertical distribution of particles.

Use mask to plot any selection of particles.