Welcome to Parcels¶
Parcels (Probably A Really Computationally Efficient Lagrangian Simulator) is an experimental prototype code aimed at exploring novel approaches for Lagrangian tracking of virtual ocean particles in the petascale age.
Parcels development status¶
Parcels is currently close to what we will release at version 0.9. This v0.9 will be a fully-functional, feature-complete code for offline Lagrangian ocean analysis. See below for a list of features, or keep an eye on the Github Development Timeline page
- Advection of particles in 2D using inbuilt kernels for Runge-Kutta4, Runge-Kutta45 and Euler Forward and in 3D using the inbuilt kernel for Runge-Kutta4_3D (see
- Ability to define and execute custom kernels (see this part of the Tutorial)
- Ability to add custom Variables to Particles (see this part of the Tutorial)
- Ability to add and remove Particles (see
- Ability to run in both Scipy and JIT (Just-In-Time compilation) mode. The former is easier to debug, but the latter can be a factor 1,000 faster (see the JIT-vs-Scipy tutorial)
- Ability to read in any type of hydrodynamic field in NetCDF format, as long as the grid is rectangular (i.e. grid axes are aligned with longitude and latitude; see
parcels.fieldset.FieldSet.from_netcdfand this part of the Tutorial)
- Output particles in NetCDF format (see
- Basic plotting of particles, both on the fly and from netcdf output files (see the plotting tutorial)
Major developed goals beyond v0.9
- Diffusion of particles using suite of inbuilt kernels
- Support for non-rectangular grids, including unstructured meshes
- Implementation of parallel execution using tiling of the domain
- Faster and more efficient code
- Advanced control of particles near land boundaries
The best way to get started with Parcels is to have a look at the Jupyter notebooks below:
- Parcels tutorial for a general introduction and overview into the main features of Parcels
- Periodic boundaries tutorial for a tutorial on how to implement periodic boundary conditions
- FieldSet.advancetime() tutorial for a tutorial on how to use Parcels with datasets that have a large number of time snapshots.
- Delayed start of particles tutorial for a tutorial on how to add particles to a ParticleSet during runtime, so that not all particles are released on the start of the run.
- JIT-vs-Scipy tutorial for a tutorial showing how JIT and Scipy mode compare.
- Animated Gif tutorial for a tutorial on how to created the Agulhas region animated gif on the top of this page. This tutorial also features a brief explanation of how to handle OutOfBounds errors.
- Plotting tutorial for further explanation on the plotting capabilities of Parcels
The latest version of Parcels, including tests and examples, can be obtained directly from github via:
git clone https://github.com/OceanParcels/parcels.git cd parcels; pip install -r requirements.txt python scripts/pull_data.py export PYTHONPATH="$PYTHONPATH:$PWD"
In order for Parcels to work from any directory, add the following line to your ~/.bash_profile:
Note that a functional NetCDF install is required.
Parcels development is supported by Imperial College London, with contributions from the people listed on the Contributors page.
If you want to help out with developing, testing or get involved in another way, please join the mailing list.
Python design overview¶
See below for links to the full documentation of the python code for Parcels
Writing Parcels Kernels¶
One of the most powerful features of Parcels is the ability to write custom Kernels (see e.g. this part of the Tutorial). These Kernels are little snippets of code that get executed by Parcels, giving the ability to add ‘behaviour’ to particles.
However, there are some key limitations to the Kernels that everyone who wants to write their own should be aware of:
Every Kernel must be a function with the following (and only those) arguments:
(particle, fieldset, time, dt)
In order to run successfully in JIT mode, Kernel definitions can only contain the following types of commands:
Basic arithmetical operators (
/) and assignments (
Basic logical operators (
whileloops, as well as
breakstatements. Note that
for-loops are not supported in JIT mode
Interpolation of a
fieldsetat a (time, lon, lat, depth) point, using using square brackets notation. For example, to interpolate the zonal velocity (U) field at the particle location, use the following statement:
value = fieldset.U[time, particle.lon, particle.lat, particle.depth]
Functions from the
mathsstandard library and from the custom
All other functions and methods are not supported yet in Parcels Kernels. If there is a functionality that can not be programmed with this limited set of commands, please create an Issue ticket.
Parcels funding and support¶
Parcels development has been supported by the following organisations:
- The European Research Council under the H2020 Starting Grant TOPIOS (grant agreement No 715386).
- Imperial College London and specifically the Grantham Institute.
- Utrecht University and specifically the Institute for Marine and Atmospheric Research.
- The EPSRC through an Institutional Sponsorship grant to Erik van Sebille under reference number EP/N50869X/1.
See below for the technical documentation on the different Parcels modules
- Parcels documentation
- parcels.particleset module
- parcels.fieldset module
- parcels.field module
- parcels.particle module
- parcels.kernels.advection module
- parcels.kernels.error module
- parcels.codegenerator module
- parcels.compiler module
- parcels.kernel module
- parcels.particlefile module
- parcels.rng module
- parcels.loggers module
- scripts.plotParticles module
- scripts.pull_data module