Replies: 2 comments
-
(A possible hack could be to add a 2d temperature field directly at the surface? But I didn't try that yet.) |
Beta Was this translation helpful? Give feedback.
-
Thanks for reporting, @willirath. I think that the new #1402 provides a nice, clean solution to this problem. In #1402 (which will become the basis of Parcels v3, to be launched this autumn), we do away with the RecoveryKernels system, allowing a much more fine-grained control of what to do when interpolation throws an error. In this new code, you have access to the particle.state in the Kernels, so you can write a small Kernel that interpolates the right velocity if the particle throws a ThroughSurfaceError. For example (not tested): def InterpolateNearSurfaceTemperature(particle, fieldset, time):
if particle.state == StatusCode.ErrorThroughSurface:
if particle.depth > 0: # location still in the ocean
particle.temperature = fieldset.temperature[particle.time, mindepth, particle.lat, particle.lon]
particle.state = StatusCode.Success
else:
particle.delete() # assuming you want to delete particles in the air where This of course has a slight overhead because it requires one more interpolation, but it is done in the main kernel loop itself so should be fast. For more info, see also the new tutorial at https://github.com/OceanParcels/parcels/blob/vectorial_summing_zarr_approach/docs/examples/tutorial_kernelloop.ipynb that I wrote today I'd be very keen to hear if this indeed works for you; as we're developing Parcels v3.0, we need these kinds of real world tests! |
Beta Was this translation helpful? Give feedback.
-
I try to sample tracer field on the NEMO grid all the way to the surface. For adding the tracer variable, I largely follow the NEMO 3D tutorial and add the tracer fields (temperature in my case) as an additional fieldset.
Fully reproducible "minimal" example: https://nbviewer.org/gist/willirath/88689100f3ce573d50c551cf9c4e116f#Parcels-Experiment
The essential bits are
and
This works as expected and picks the correct temperature values using nearest-neighbor interpolation if the vertical position of the particles is below the center of the uppermost tracer grid cell but fails with a
ThroughSurfaceError
if the particles go into the upper half of the uppermost grid box.Is there a way to extend the tracer field to the surface?
Beta Was this translation helpful? Give feedback.
All reactions