particle_tracking_manager.models.opendrift.opendrift

Uses OpenDrift for particle tracking model.

Classes

OpenDriftModel(**kwargs)

OpenDrift particle tracking model.

class particle_tracking_manager.models.opendrift.opendrift.OpenDriftModel(**kwargs)[source]

Bases: ParticleTrackingManager

OpenDrift particle tracking model.

Parameters:
  • drift_model (str) – Options: “OceanDrift”, “LarvalFish”, “Phytoplankton”, “OpenOil”, “Leeway”. Default is “OceanDrift”.

  • export_variables (list) – List of variables to export, by default None. See PTM docs for options.

  • radius (int) – Radius around each lon-lat pair, within which particles will be randomly seeded. This is used by function seed_elements.

  • radius_type (str) – If ‘gaussian’ (default), the radius is the standard deviation in x-y-directions. If ‘uniform’, elements are spread evenly and always inside a circle with the given radius. This is used by function seed_elements.

  • current_uncertainty (float) – Add gaussian perturbation with this standard deviation to current components at each time step.

  • wind_uncertainty (float) – Add gaussian perturbation with this standard deviation to wind components at each time step.

  • use_auto_landmask (bool) – Set as True to use general landmask instead of that from ocean_model. Use for testing primarily. Default is False.

  • diffusivitymodel (str) – Algorithm/source used for profile of vertical diffusivity. Environment means that diffusivity is acquired from readers or environment constants/fallback. Turned on if vertical_mixing==True.

  • stokes_drift (bool) –

    Set to True to turn on Stokes drift, by default True. This enables 3 settings in OpenDrift:

    • o.set_config(‘drift:use_tabularised_stokes_drift’, True)

    • o.set_config(‘drift:tabularised_stokes_drift_fetch’, ‘25000’) # default

    • o.set_config(‘drift:stokes_drift_profile’, ‘Phillips’) # default

    The latter two configurations are not additionally set in OpenDriftModel since they are already the default once stokes_drift is True.

  • mixed_layer_depth (float) – Fallback value for ocean_mixed_layer_thickness if not available from any reader. This is used in the calculation of vertical diffusivity.

  • coastline_action (str, optional) – Action to perform if a drifter hits the coastline, by default “previous”. Options are ‘stranding’, ‘previous’.

  • seafloor_action (str, optional) – Action to perform if a drifter hits the seafloor, by default “deactivate”. Options are ‘deactivate’, ‘previous’, ‘lift_to_seafloor’.

  • max_speed (int) – Typical maximum speed of elements, used to estimate reader buffer size.

  • wind_drift_depth (float) – The direct wind drift (windage) is linearly decreasing from the surface value (wind_drift_factor) until 0 at this depth.

  • vertical_mixing_timestep (float) – Time step used for inner loop of vertical mixing.

  • interpolator_filename (Optional[Union[pathlib.Path,str]], optional) – Filename to save interpolators to, by default None. The full path should be given, but no suffix. Use this to either read from an existing file at a non-default location or to save to a non-default location. If None and use_cache==True, the filename is set to a built-in name to an appdirs cache directory.

  • plots (dict, optional) – Dictionary of plot names, their filetypes, and any kwargs to pass along, by default None. Available plot names are “spaghetti”, “animation”, “oil”, “all”.

object_type: str = config_model[“object_type”][“default”],

Leeway object category for this simulation.

diameterfloat

Seeding value of diameter. For LarvalFish simulation.

neutral_buoyancy_salinityfloat

Seeding value of neutral_buoyancy_salinity. For LarvalFish simulation.

stage_fractionfloat

Seeding value of stage_fraction. For LarvalFish simulation.

hatchedfloat

Seeding value of hatched. For LarvalFish simulation.

lengthfloat

Seeding value of length. For LarvalFish simulation.

weightfloat

Seeding value of weight. For LarvalFish simulation.

oil_typestr

Oil type to be used for the simulation, from the NOAA ADIOS database. For OpenOil simulation.

m3_per_hourfloat

The amount (volume) of oil released per hour (or total amount if release is instantaneous). For OpenOil simulation.

oil_film_thicknessfloat

Seeding value of oil_film_thickness. For OpenOil simulation.

droplet_size_distributionstr

Droplet size distribution used for subsea release. For OpenOil simulation.

droplet_diameter_mufloat

The mean diameter of oil droplet for a subsea release, used in normal/lognormal distributions. For OpenOil simulation.

droplet_diameter_sigmafloat

The standard deviation in diameter of oil droplet for a subsea release, used in normal/lognormal distributions. For OpenOil simulation.

droplet_diameter_min_subseafloat

The minimum diameter of oil droplet for a subsea release, used in uniform distribution. For OpenOil simulation.

droplet_diameter_max_subseafloat

The maximum diameter of oil droplet for a subsea release, used in uniform distribution. For OpenOil simulation.

emulsificationbool

Surface oil is emulsified, i.e. water droplets are mixed into oil due to wave mixing, with resulting increase of viscosity. For OpenOil simulation.

dispersionbool

Oil is removed from simulation (dispersed), if entrained as very small droplets. For OpenOil simulation.

evaporationbool

Surface oil is evaporated. For OpenOil simulation.

update_oilfilm_thicknessbool

Oil film thickness is calculated at each time step. The alternative is that oil film thickness is kept constant with value provided at seeding. For OpenOil simulation.

biodegradationbool

Oil mass is biodegraded (eaten by bacteria). For OpenOil simulation.

Attributes:
seed_kws

Gather seed input kwargs.

Methods

add_reader(**kwargs)

Add reader to model class.

all_export_variables()

Output list of all possible export variables.

export_variables()

Output list of all actual export variables.

from_config(config)

Create an OpenDriftModel from a config.

reader_metadata(key)

allow manager to query reader metadata.

run()

Call model run_drifters function.

run_all()

Run all steps.

seed()

Seed drifters.

setup_for_simulation()

Set up the simulation.

_abc_impl = <_abc._abc_data object>
_add_reader(**kwargs)[source]

Add a reader to the OpenDrift model.

Parameters:
  • ds (xr.Dataset, optional) – Previously-opened Dataset containing ocean model output, if user wants to input unknown reader information.

  • name (str, optional) – If ds is input, user can also input name of ocean model, otherwise will be called “user_input”.

_create_opendrift_model_object()[source]

Create the OpenDrift model object.

_modify_opendrift_model_object()[source]

Modify the OpenDrift model object.

_run()[source]

Run the drifters!

_seed()[source]

Actually seed drifters for model.

_setup_for_simulation()[source]

Set up the simulation. This is run before the simulation starts.

_update_od_config_from_this_config()[source]

Update OpenDrift’s config values with OpenDriftConfig and TheManagerConfig.

Update the default value in OpenDrift’s config dict with the config value from OpenDriftConfig, TheManagerConfig, OceanModelConfig, and SetupOutputFiles.

This uses the metadata key “od_mapping” to map from the PTM parameter name to the OpenDrift parameter name.

add_reader(**kwargs)

Add reader to model class.

all_export_variables()[source]

Output list of all possible export variables.

config
export_variables()[source]

Output list of all actual export variables.

classmethod from_config(config)

Create an OpenDriftModel from a config.

Not currently working.

reader_metadata(key)[source]

allow manager to query reader metadata.

run()

Call model run_drifters function.

Also run some other items.

run_all()

Run all steps.

seed()

Seed drifters.

property seed_kws

Gather seed input kwargs.

This could be run more than once.

setup_for_simulation()

Set up the simulation.

This may not be necessary to separate out but is sometimes necessary.