ThroughSurfaceError #1266
-
Dear Ocean Parcels team, I am new to Ocean Parcels and Python. I have been trying to use parcels on 3D velocity data following the example notebook using NEMO data (https://nbviewer.org/github/OceanParcels/parcels/blob/master/parcels/examples/tutorial_nemo_3D.ipynb). When I try to execute pset, I keep getting the same error, 'ThroughSurfaceError'. The code that I use is as follows: from parcels import FieldSet, ParticleSet, JITParticle, AdvectionRK4_3D filenames = {'U':'BRAN_3Dcurrents_2015.nc', I am getting the following error while I run the above codes: ThroughSurfaceError Traceback (most recent call last) File ~\Anaconda3\envs\py3_parcels\lib\site-packages\parcels\particleset\baseparticleset.py:450, in BaseParticleSet.execute(self, pyfunc, pyfunc_inter, endtime, runtime, dt, moviedt, recovery, output_file, movie_background_field, verbose_progress, postIterationCallbacks, callbackdt) File ~\Anaconda3\envs\py3_parcels\lib\site-packages\parcels\kernel\kernelsoa.py:227, in KernelSOA.execute(self, pset, endtime, dt, recovery, output_file, execute_once) File ~\Anaconda3\envs\py3_parcels\lib\site-packages\parcels\tools\statuscodes.py:207, in recovery_kernel_through_surface(particle, fieldset, time) ThroughSurfaceError: 0 I would be very thankful if you could help me with it. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
Dear @ajithacyriac, could it be that the top layer in your velocity fields is not at 0m, but slightly deeper? If so, a simple solution would be not to specify the |
Beta Was this translation helpful? Give feedback.
-
Hmm, could it be that BRAN is a B-grid? Then you might want to use `FieldSet.from_b_grid_dataset instead? Also note that in some B-grids the upper layer is on the bottom of the cell; see also #573 and #578. |
Beta Was this translation helpful? Give feedback.
-
I checked your files, and think I know what's going on. You are using the What you need to do is 'capture' these particles that go through the surface and e.g. push them back. Something like from parcels import ErrorCode
def pushback(particle, fieldset, time):
particle.depth = 10.
pset.execute(kernels, runtime=delta(days=4), dt=delta(hours=1), output_file=output_file,
recovery={ErrorCode.ErrorThroughSurface: pushback}) |
Beta Was this translation helpful? Give feedback.
I checked your files, and think I know what's going on. You are using the
AdvectionRK4_3D
kernel, and your vertical velocities are so high that your particles actually move throughfieldset.U.grid.depth[0]
at 5m. So this is because of the velocity fields themselves, not because of Parcels. If you useAdvectionRK4
(so not the 3D-version) and don't specify adepth
in your ParticleSet, then the particles move correctlyWhat you need to do is 'capture' these particles that go through the surface and e.g. push them back. Something like