parcels#
Submodules#
Attributes#
The default Particle used in Parcels simulations. |
|
Exceptions#
Utility error class to propagate NaN field interpolation. |
|
Utility error class to propagate out-of-bound field sampling. |
|
Utility error class to propagate field sampling errors. |
|
General particles kernel error with optional custom message. |
|
Utility error class to propagate erroneous time extrapolation sampling. |
|
Warning that is raised when there are issues in the construction of the FieldSet or its Grid. |
|
Warning that is raised when there are issues with input or output files. |
|
Warning that is raised when there are issues with the Kernel. |
|
Warning that is raised when there are issues in the construction of the ParticleSet. |
|
Warning that is raised when there are issues during the evaluation of a Field. |
|
Raised when a kernel function has errors that make it incompatible with Parcels v4. |
Classes#
FieldSet class that holds hydrodynamic data needed to execute particles. |
|
Class for storing particles and executing kernel over them. |
|
Initialise trajectory output. |
|
Descriptor class that delegates data access to particle data. |
|
Define a class of particles. This is used to generate the particle data which is then used in the simulation. |
|
The Field class that holds scalar field data. |
|
VectorField class that holds vector field data needed to execute particles. |
|
Base class for parcels.XGrid and parcels.UxGrid defining common methods and properties |
|
Extension of uxarray's Grid class that supports point-location search |
|
Class to represent a structured grid in Parcels. |
|
Spherical mesh object with configurable planetary radius. |
|
Class defining the status codes for particles.state. |
Functions#
|
Open a Zarr dataset in an Xarray dataset, bypassing Dask. |
|
Read a Parcels particlefile (Parquet format) into a pandas DataFrame. |
|
Convert a v4 particle file (parquet) to v3-style zarr output. |
|
Decorator that validates a Parcels v4 kernel function. |
Package Contents#
- parcels.read_particlefile(path, decode_times=True)[source]#
Read a Parcels particlefile (Parquet format) into a pandas DataFrame.
- Parameters:
path (PathLike) – Path to the
.parquetparticlefile.decode_times (bool, optional) – If
True(default), use Xarray to decode the numerictcolumn from CF conventions intodatetimeorcftime.datetimevalues using the units stored in the column metadata. IfFalse, the raw numeric values are returned unchanged.
- Returns:
DataFrame containing the particle data. When decode_times is
True, thetcolumn contains datetime-like values; otherwise it contains the original numeric representation.- Return type:
pd.DataFrame
Notes
For larger datasets, consider using Polars directly, e.g.
polars.read_parquet(path), which offers better performance and lower memory usage than pandas for large Parquet files.
- parcels.particlefile_to_v3_zarr(from_parquet, to_zarr)[source]#
Convert a v4 particle file (parquet) to v3-style zarr output.
Reads the parquet file, renames columns to v3 conventions (
particle_id->trajectory,t->time,x->lon,y->lat), and reshapes the data into a 2D(trajectory, obs)zarr store.- Parameters:
from_parquet (Path) – Path to the input parquet file.
to_zarr (Path) – Path to the output zarr store. Must have a
.zarrsuffix.
- Raises:
ValueError – If
to_zarrdoes not have a.zarrsuffix.
Notes
This is not a lazy operation — the entire parquet file is read into memory and pivoted before writing to zarr. For large particle files this may require significant memory. Performance improvements are welcome via PRs.
- parcels.Particle#
The default Particle used in Parcels simulations.
- parcels.AllParcelsErrorCodes: dict[type[Exception], int]#
- parcels.validate_kernel(func)[source]#
Decorator that validates a Parcels v4 kernel function.
Errors (raises
KernelValidationError): - Kernel signature is notdef ...(particles, fieldset)-particle.delete()orparticles.delete()callsWarning
References to deprecated
particle.lon,.lat,.depth(use.x,.y,.z)References to deprecated
particle_dlon,particle_dlat,particle_ddepthDirect assignment to particle location attributes (x/y/z/lon/lat/depth)
Sampling
particle.ei(ordering concern)
- parcels.logger#