MOAD Kernel Functions and Particle Classes

Particle Behaviour Kernels and Particle Classes

Coming soon…

Stokes_drift()

moacean_parcels.kernels.Stokes_drift(particle, fieldset, time)[source]

Include the effect of Stokes drift to your particles trajectory using WaveWatch3 data.

This kernel is intended for use as a particle behaviour kernel

Example usage:

from moacean_parcels.kernels import Stokes_drift

# ...

Sd_kernel = pset.Kernel(Stokes_drift)

# ...

pset.execute(kernels ... + Sd_kernel,
    # ...
)

For a more detailed usage example, please see the example notebook for this kernel in the particle_behaviour_kernels section.

Parameters:
  • particle (parcels.particle.JITParticle or parcels.particle.ScipyInteractionParticle) – Particle to add behaviour.

  • fieldset (parcels.fieldset.FieldSet) – Hydrodynamic fields that is moving the particle.

  • time (numpy.float64) – Current time of the particle.

Recovery Kernels

Recovery kernels are used to handle error conditions during particle simulations. In the absence of a recovery kernel for error condition encountered, the simulation ends, likely with no output generated.

Recovery kernels are specified via a dict whose keys are defined in the :py:class`ErrorCode` class in parcels.tools.statuscodes and whose values are recovery kernel functions. Here’s an example of using moacean_parcels.kernels.DeleteParticle() as a recovery kernel for the particle out of bounds conditions:

from moacean_parcels.kernels import DeleteParticle

# ...

pset.execute(
    kernels,
    # ...
    recovery={ErrorCode.ErrorOutOfBounds: DeleteParticle},
    # ...
)

Note

If you specify only a ErrorCode.ErrorOutOfBounds recovery kernel, it will be use at all of the boundaries, including the ocean surface. If you want to handle particles that go through the surface differently to those hitting the bottom, land, or the domain boundary, you should provide a recovery kernel for that condition via the ErrorCode.ErrorThroughSurface key. An example of that might be having particles that reach the surface reflect back down into the water column in contrast to deleting particles that reach other boundaries.

Recovery kernels are not JIT-compiled when the parcels.particle.JITParticle particle class is used. So, they are not subject to the same restrictions on Python standard library modules, print() function style, etc. as Particle Behaviour Kernels and Particle Classes .

DeleteParticle()

moacean_parcels.kernels.DeleteParticle(particle, fieldset, time)[source]

Delete a particle that has been lost during execution of the simulation and print its id number as well as information about where and when it was lost.

This kernel is intended for use as an error recovery kernel, most likely for the parcels.tools.statuscodes.OutOfBoundsError or parcels.tools.statuscodes.ThroughSurfaceError error conditions.

Example usage:

from moacean_parcels.kernels import DeleteParticle

# ...

pset.execute(
    kernels,
    # ...
    recovery={ErrorCode.ErrorOutOfBounds: DeleteParticle},
    # ...
)

For a more detailed usage example, please see the example notebook for this kernel in the Recovery Kernel Example Notebooks section.

Parameters:
  • particle (parcels.particle.JITParticle or parcels.particle.ScipyInteractionParticle) – Particle that has gone out of bounds.

  • fieldset (parcels.fieldset.FieldSet) – Hydrodynamic fields that is moving the particle.

  • time (numpy.float64) – Current time of the particle.