Replies: 1 comment 4 replies
-
|
Hi @soizicg, thanks for raising this question. However, I'm not sure I understand the problem. In Parcels, 2D fields don't consider depth at all, so there is no concept of a Of course, you could raise such an error yourself, with a simple if-statement, see the tutorial on Status Codes. Something like if particle.depth < 0:
particle.state = StatusCode.ErrorThroughSurface |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I use a 3D fieldset with time varying vertical coordinates and wanted to develop a kernel called "CheckBoundaries" to handle particle interactions with model boundaries (surface, sea bed, land...), but the status code doesn't seem to be working as expected.
If I sample a 2D field in a kernel, the particle will be able to escape through the surface without raising an error, however if I sample a velocity field, the out of bound at the surface error will be raised when the particle reaches negative vertical coordinates (as expected).
Here is the code to define the fieldset:
Then to define the particle set:
Finally the kernel definition (sampling of the landmask) and execution of the particle simulation:
Now when I run this code, the particle is able to pierce the surface, here is the output of the z variable of the particle:
0
0.600053250789642
1.18962800502777
1.61126649379730
1.75607454776764
1.55384206771851
1.09453940391541
0.509002625942230
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
-0.0293525625020266
However if I change the kernel and sample u instead of the landmask that way:
Oceanparcels now raises a FieldOutOfBoundSurfaceError as the particle go through the surface, then the simulation is stopped.
The particle z variable doesn't become negative due to the status code being raised:
0
0.600053250789642
1.18962800502777
1.61126649379730
1.75607454776764
1.55384206771851
1.09453940391541
0.509002625942230
This problem with the status code seems to occur only when I sample a 2D field (I have also tried with the Kz field that I defined earlier). Should I sample 2D field in a different way?
Thanks for the help.
Beta Was this translation helpful? Give feedback.
All reactions