ParticleSet Empty at Beginning When Using Custom Kernel #1557
-
|
Hello! The Kernel loop example shows how Parcels v3.0 allows for vectorized summing from multiple fields. I've created a custom kernel that is slightly modified from the pre-built AdvectionRK4. Only the variable names have been changed. The problem I'm experiencing has been recreated in the following script. Everything above What I want to happen is to bring in multiple fields from multiple NetCDFs, add them to the first fieldset, and have different kernels operate on these fields (via VectorField objects). What am I doing wrong to have no particles at the beginning of the simulation in my broken example below Here is a reproducible example below: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
|
Hi @jamespolly, thanks for using It's hard to be sure without having access to the hydrodynamic data, but one thing we've seen before is that particles get deleted if the longitude definitions between the fields don't align. For example when the longitudes of your ocean flow fields are defined between 0 and 360 degrees, and for the wind fields between -180 and 180 degrees. Particles could then get an out-of-bounds in one field, but not the other. I assume that if you don't add |
Beta Was this translation helpful? Give feedback.
-
|
Ah, in that case what's probably happening is that the unitconverters are not properly set on the 'wind'-fields. If you're on a spherical mesh (i.e. in lon/lat), It does so based on the These unitconverters are probably not set for your Your particles hence immediately fly off the grid (with a So the solution is (likely) to add these unitconverters from parcels.tools.converters import GeographicPolar
fieldset.Uwind.units = GeographicPolar()
fieldset.Vwind.units = Geographic()See for much more details the Spherical grids and UnitConversion tutorial. |
Beta Was this translation helpful? Give feedback.
-
|
This was indeed the problem @erikvansebille, thank you so much! As I was investigating, and as you pointed out, the computation of the I created two fieldsets using I could see that However, when I would test some lines from the kernel, differences started to appear. Would not agree with the output of: Despite Just adding this extra info here in case it is useful to anyone down the line. Thank you again @erikvansebille for your help! |
Beta Was this translation helpful? Give feedback.
Ah, in that case what's probably happening is that the unitconverters are not properly set on the 'wind'-fields.
If you're on a spherical mesh (i.e. in lon/lat),
parcelsautomatically converts velocities in m/s to degrees/m using these so-called unitconverters.It does so based on the
Field-names, whereUandV(and alsKh_zonalandKh_meridional) are 'special', see the list here.These unitconverters are probably not set for your
UWindandVWindfields, meaning that the velocities (in m/s) are interpreted as in degrees/s by the advection kernel.Your particles hence immediately fly off the grid (with a
dtof 1 hour, they could move 3600 degrees in one time step!)So the solution is (lik…