Skip to content

Frequently Asked Questions on Parcels

Erik van Sebille edited this page Mar 9, 2018 · 2 revisions

Welcome to the Parcels wiki! On this page, we'll provide tips and tricks for running Parcels. See also the OceanParcels.org website for further information, for example on installing the code

Tips on constructing FieldSet objects

Probably the trickiest bit to get right when starting with Parcels on your own model output is how to construct a FieldSet object.

The general method to use is FieldSet.from_netcdf(), which requires filenames, variables and dimensions. Each of these is a dictionary, and variables requires at least U and V, but any other variable can be added too (e.g. temperature, mixedlayerdepth, etc). Note also that filenames can contain wildcards.

For example, the GlobCurrent data that is shipped with Parcels can be read with:

fname = ‘GlobCurrent_example_data/*.nc’
filenames = {'U': fname, 'V': fname}
variables = {'U': 'eastward_eulerian_current_velocity', 'V': 'northward_eulerian_current_velocity'}
dimensions = {'lat': 'lat', 'lon': ‘lon', 'depth': 'depth', 'time': 'time'}
fset = FieldSet.from_netcdf(filenames, variables, dimensions)

Note that dimensions can also be a dictionary-of-dictionaries. For example, if you have wind data on a completely different grid (and without depth dimension), you can do:

fname = 'GlobCurrent_example_data/*.nc'
wname = 'path_to_your_windfiles'
filenames = {'U': fname, 'V': fname, 'wind': wname}
variables = {'U': 'eastward_eulerian_current_velocity', 'V': 'northward_eulerian_current_velocity', 'wind': 'wind'}
dimensions = {}
dimensions['U'] = {'lat': 'lat', 'lon': 'lon', 'depth': ‘depth’, 'time': 'time'}
dimensions['V'] = {'lat': 'lat', 'lon': 'lon', 'depth': ‘depth’, 'time': 'time'}
dimensions['wind'] = {'lat': 'latw', 'lon': 'lonw', 'time': ‘time'}
fset = FieldSet.from_netcdf(filenames, variables, dimensions)

In a similar way, you can add U and V fields that are on different grids (e.g. Arakawa C-grids). Parcels will take care under the hood that the different grids are dealt with properly.

The output format of ParticleFile

The information on particle trajectories is stored in NetCDF format, when using the ParticleFile class. The file contains arrays of at least the time, lon, lat and z (depth) of each particle trajectory, plus any extra custom Variables defined in the pclass. Each row in these arrays corresponds is a particle, and each column is an 'observation'. Note that, when particles are added during runtime, their first position is still stored in the first column, so that not all particles in the same column necessarily share the same time. The time of each observation is stored in the time array.

Clone this wiki locally