This file is a template for an ocean trajectory model to be implemented within the OpenDrift framework. To create a new model, make a copy (renamed) of this file, and modify the class names and details below, according to the comments. Alternatively, another existing class can be used as a starting point.

For more help, see For usage of the new model, see example scripts.

First we define an element type to be used by the trajectory model. An element type (class) may also be imported/reused from another module - see examples in the folder “elements”

Module Contents



Extending LagrangianArray with relevant properties.


Open source trajectory model based on the OpenDrift framework.

class opendrift.models.model_template.TemplateElementType(**kwargs)[source]

Bases: opendrift.models.oceandrift.Lagrangian3DArray

Extending LagrangianArray with relevant properties.

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.model_template.ModelTemplate(*args, **kwargs)[source]

Bases: opendrift.models.oceandrift.OceanDrift

Open source trajectory model based on the OpenDrift framework.

This is a template model, to be copied and modified according to need. This class is a subclass of “OceanDrift”, and thus inherits all its functionality. More specialised models may also be subclassed.

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


Code to be run before a simulation loop (update())

bottom_interaction(self, seafloor_depth)[source]

Sub method of vertical_mixing, determines settling