Skip to content

Rename particle position attributes from "lon" and "lat" to "x" and "y"#2719

Merged
VeckoTheGecko merged 9 commits into
Parcels-code:mainfrom
VeckoTheGecko:push-klyynlpzyoqm
Jul 6, 2026
Merged

Rename particle position attributes from "lon" and "lat" to "x" and "y"#2719
VeckoTheGecko merged 9 commits into
Parcels-code:mainfrom
VeckoTheGecko:push-klyynlpzyoqm

Conversation

@VeckoTheGecko

@VeckoTheGecko VeckoTheGecko commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Description

Kernel variables lon and lat have been renamed to x and y, and dlon and dlat have been renamed to dx and dy. These changes are also reflected on the ParticleSet as well as the particlefile output.

Changes:

  • Update particle definition and all related code
    • particle.py particle variables
    • ParticleSet args
    • all internal mentions of .lon and .lat
    • test suite code
  • See commit history for other changes

This now means that users will need to use x and y when refering to particle positions. This includes in kernels, when defining the particlesets themselves, and when working with output after the face.

Note that I haven't gone about updating local variable names in tests. I don't think it provides any benefit to do so (and for those tests using "lon" might be more informative than using "x" as it hints at the mesh type used).

Checklist

AI Disclosure

None used.

@VeckoTheGecko

Copy link
Copy Markdown
Contributor Author

Also note that I haven't updated the docs as these are currently broken due to the last refactoring. We should fix them in a separate PR.

@erikvansebille erikvansebille left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code changes look good; see below a few minor comments

Two more important ones

  1. Should we also change particles.time to particles.t, for symmetry with the other one-letter attributes?
  2. Would it be helpful to users to provide some informative error message if they create a ParticleSet or Kernel with lon, informing them that this has changed in v4? Or do we expect them to just read the migration guide? I guess that this will be one of the most impactful changes for users wanting to port over their code (along with the vectorization of the particleset).

Comment thread docs/user_guide/examples_v3/example_brownian.py
Comment thread docs/user_guide/v4-migration.md Outdated
Comment thread src/parcels/_core/particle.py Outdated
Comment thread docs/user_guide/v4-migration.md Outdated
- Users need to explicitly use `convert_z_to_sigma_croco` in sampling kernels (such as the `AdvectionRK4_3D_CROCO` or `SampleOMegaCroco` kernels) when working with CROCO data, as the automatic conversion from depth to sigma grids under the hood has been removed.
- We added a new AdvectionRK2 Kernel. The AdvectionRK4 kernel is still available, but RK2 is now the recommended default advection scheme as it is faster while the accuracy is comparable for most applications. See also the Choosing an integration method tutorial.
- Functions shouldn't be converted to Kernels before adding to a pset.execute() call. Instead, simply pass the function(s) as a list to pset.execute().
- Kernel variables `lon` and `lat` have been renamed to `x` and `y`, and `dlon` and `dlat` have been renamed to `dx` and `dy`. These changes are also reflected on the ParticleSet as well as the particlefile output.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also update time to t?

Because a user would now sample by fieldset.field[particles.time, particles.z, particles.y, particles.x]. This could be more 'symmetric' with

fieldset.field[particles.t, particles.z, particles.y, particles.x]

Comment thread tests-v3/tools/test_warnings.py
@VeckoTheGecko

Copy link
Copy Markdown
Contributor Author

2. Would it be helpful to users to provide some informative error message if they create a ParticleSet or Kernel with lon, informing them that this has changed in v4? Or do we expect them to just read the migration guide? I guess that this will be one of the most impactful changes for users wanting to port over their code (along with the vectorization of the particleset).

That's a good idea. Added to #2109

@VeckoTheGecko

Copy link
Copy Markdown
Contributor Author
  1. Should we also change particles.time to particles.t, for symmetry with the other one-letter attributes?

OK, let's do that. Tracking in a separate issue to be done in another PR.

VeckoTheGecko and others added 9 commits July 6, 2026 09:41
Update particle definition and all related code

- particle.py particle variables
- ParticleSet args
- all internal mentions of .lon and .lat
- test suite code
Co-authored-by: Erik van Sebille <e.vansebille@uu.nl>
@VeckoTheGecko VeckoTheGecko merged commit 08a0a26 into Parcels-code:main Jul 6, 2026
15 of 16 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Parcels development Jul 6, 2026
@VeckoTheGecko VeckoTheGecko deleted the push-klyynlpzyoqm branch July 6, 2026 07:49
@VeckoTheGecko

Copy link
Copy Markdown
Contributor Author

@erikvansebille merged now!

@VeckoTheGecko VeckoTheGecko mentioned this pull request Jul 6, 2026
10 tasks
erikvansebille added a commit to erikvansebille/Parcels that referenced this pull request Jul 6, 2026
erikvansebille added a commit to erikvansebille/Parcels that referenced this pull request Jul 6, 2026
erikvansebille added a commit to erikvansebille/Parcels that referenced this pull request Jul 6, 2026
erikvansebille added a commit to erikvansebille/Parcels that referenced this pull request Jul 6, 2026
erikvansebille added a commit to erikvansebille/Parcels that referenced this pull request Jul 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Rename particle position attributes from (lon, lat, depth) to (x,y,z)

2 participants