Particlefile#

parcels.particlefile module#

Module controlling the writing of ParticleSets to Zarr file.

class parcels.particlefile.ParticleFile(name, particleset, outputdt=inf, chunks=None, create_new_zarrfile=True)[source]#

Bases: ABC

Initialise trajectory output.

Parameters
  • name (str) – Basename of the output file. This can also be a Zarr store object.

  • particleset – ParticleSet to output

  • outputdt – Interval which dictates the update frequency of file output while ParticleFile is given as an argument of ParticleSet.execute() It is either a timedelta object or a positive double.

  • chunks – Tuple (trajs, obs) to control the size of chunks in the zarr output.

  • create_new_zarrfile (bool) – Whether to create a new file. Default is True

Returns

ParticleFile object that can be used to write particle data to file

Return type

ParticleFile

Attributes
lonlatdepth_dtype
outputdt
parcels_mesh
particleset
time_origin

Methods

add_metadata(name, message)

Add metadata to parcels.particleset.ParticleSet.

write(pset, time[, indices])

Write all data from one time step to the zarr file, before the particle locations are updated.

write_latest_locations(pset, time)

Write the current (latest) particle locations to zarr file.

write_once

add_metadata(name, message)[source]#

Add metadata to parcels.particleset.ParticleSet.

Parameters
  • name (str) – Name of the metadata variable

  • message (str) – message to be written

write(pset, time, indices=None)[source]#

Write all data from one time step to the zarr file, before the particle locations are updated.

Parameters
  • pset – ParticleSet object to write

  • time – Time at which to write ParticleSet

write_latest_locations(pset, time)[source]#

Write the current (latest) particle locations to zarr file. This can be useful at the end of a pset.execute(), when the last locations are not written yet. Note that this only updates the locations, not any of the other Variables. Therefore, use with care.

Parameters
  • pset – ParticleSet object to write

  • time – Time at which to write ParticleSet. Note that typically this would be pset.time_nextloop