Skip to content

Conversation

@erikvansebille
Copy link
Member

This PR supersedes #2450 by creating a convert.croco_to_sgrid() function, and using that to support croco

@erikvansebille erikvansebille marked this pull request as ready for review January 16, 2026 12:22
- `math` functions should be replaced with array compatible equivalents (e.g., `math.sin` -> `np.sin`). Instead of `ParcelsRandom` you should use numpy's random functions.
- `particle.depth` has been changed to `particles.z` to be consistent with the [CF conventions for trajectory data](https://cfconventions.org/cf-conventions/cf-conventions.html#trajectory-data), and to make Parcels also generalizable to atmospheric contexts.
- The `InteractionKernel` class 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_croco` in sampling kernels such as the `AdvectionRK4_3D_CROCO` kernel for CROCO fields, as the automatic conversion from depth to sigma grids under the hood has been removed.
Copy link
Contributor

@VeckoTheGecko VeckoTheGecko Jan 20, 2026

Choose a reason for hiding this comment

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

Suggested change
- Users need to explicitly use `convert_z_to_sigma_croco` in sampling kernels such as the `AdvectionRK4_3D_CROCO` kernel for CROCO fields, as the automatic conversion from depth to sigma grids under the hood has been removed.
- Users need to explicitly use the `convert_z_to_sigma_croco` kernel within sampling kernels (such as the `AdvectionRK4_3D_CROCO` kernel) when working with CROCO fields, as the automatic conversion from depth to sigma grids under the hood has been removed.

This using of a kernel inside a kernel seems quite novel to me - I assume this wasn't possible in version 3? Are there any other usecases where we can highlight this (i.e., stuff that users can now do that wasn't possible with sequential kernels?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed in 74a95ca
Note that the convert_z_to_sigma_croco is not a kernel, but a helper function, so we shouldn't call it a Kernel. And yes, this was not possible in JIT, but is now possible in v4 (was always possible in Scipy/v3). We have other helper functions like _constrain_dt_to_within_time_interval() too

Copy link
Contributor

Choose a reason for hiding this comment

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

Note that the convert_z_to_sigma_croco is not a kernel, but a helper function

Gotcha, I misread the function signature (I saw "fieldset" in it and assumed the rest was the same)

For these sort of functions, should we vendor them out of parcels.kernels? Perhaps we can for this one - but if we know we are going to have more then maybe a different namespace would be better

@erikvansebille erikvansebille merged commit 6538f49 into v4-dev Jan 20, 2026
10 of 11 checks passed
@erikvansebille erikvansebille deleted the convert_croco branch January 20, 2026 14:03
@github-project-automation github-project-automation bot moved this from Backlog to Done in Parcels development Jan 20, 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.

3 participants