Version 4 of Parcels is unreleased at the moment. The information in this migration guide is a work in progress, and is subject to change. If you would like to provide feedback on this migration guide (or generally on the development of v4) please [submit an issue](https://github.com/Parcels-code/Parcels/issues/new/choose).
- The Kernel loop has been 'vectorized', so that the input of a Kernel is not one particle anymore, but a collection of particles. This means that
if-statements in Kernels don't work anymore. Replaceif-statements withnumpy.wherestatements. particle.delete()is no longer valid. Instead, useparticle.state = StatusCode.Delete.- Sharing state between kernels must be done via the particle data (as the kernels are not combined under the hood anymore).
particl_dlon,particle_dlatetc have been renamed toparticle.dlonandparticle.dlat.- The
timeargument in the Kernel signature has been removed in the Kernel API, so can't be used. Useparticle.timeinstead. - The
particleargument in the Kernel signature has been renamed toparticles. mathfunctions should be replaced with array compatible equivalents (e.g.,math.sin->np.sin). Instead ofParcelsRandomyou should use numpy's random functions.particle.depthhas been changed toparticles.zto be consistent with the CF conventions for trajectory data, and to make Parcels also generalizable to atmospheric contexts.- The
InteractionKernelclass has been removed. Since normal Kernels now have access to all particles, particle-particle interaction can be performed within normal Kernels. - Users need to explicitly use
convert_z_to_sigma_crocoin sampling kernels such as theAdvectionRK4_3D_CROCOkernel for CROCO fields, as the automatic conversion from depth to sigma grids under the hood has been removed.
interp_methodhas to be an Interpolation function, instead of a string.
Particle.add_variables()has been replaced byParticle.add_variable(), which now also takes a list ofVariables.
repeatdtandlonlatdepth_dtypehave been removed from the ParticleSet.- ParticleSet.execute() expects
numpy.datetime64/numpy.timedelta.64forendtime. While floats are supported forruntimeanddt, usingnumpy.datetime64/numpy.timedelta.64for these arguments too is encouraged. ParticleSet.from_field(),ParticleSet.from_line(),ParticleSet.from_list()have been removed.
- Particlefiles should be created by
ParticleFile(...)instead ofpset.ParticleFile(...) - The
nameargument inParticleFilehas been replaced bystoreand can now be a string, a Path or a zarr store.
Field.eval()returns an array of floats instead of a single float (related to the vectorization)Field.eval()does not throw OutOfBounds or other errors
GridSetis now a list, so changefieldset.gridset.grids[0]tofieldset.gridset[0].
- The default
UnitConverteris now calledUnity()