Seeking advice on "ParticleSet is empty" warning during 3D simulation #1715
-
QuestionQuestionHi, @erikvansebille. The version of Parcels I used is 3.0.2. I have also tried reducing the output time (e.g., changing it to 300 seconds), but the issue still persists. The warning continues to appear at all output times. Could you kindly provide guidance on how I can further debug this issue? Thank you very much in advance. Best regards, Supporting code/error messages# My partial code is as follows.
# fieldset
uvfiles = sorted(glob(dataUV_path + '*_uvcur.nc'))
wfiles = sorted(glob(dataW_path + '*_wcur.nc'))
mesh_mask = mesh_path + 'coordinate_lonup.nc'
filenames = {"U": {"lon": mesh_mask, "lat": mesh_mask, "depth": wfiles[0], "data": uvfiles},
"V": {"lon": mesh_mask, "lat": mesh_mask, "depth": wfiles[0], "data": uvfiles},
"W": {"lon": mesh_mask, "lat": mesh_mask, "depth": wfiles[0], "data": wfiles}, }
variables = {"U": "uo", "V": "vo", "W": "wo",}
grid_dimensions = {"lon": "longitude", "lat": "latitude", "depth": "depth", }
dimensions = {'U': grid_dimensions, 'V': grid_dimensions,'W': grid_dimensions, }
fieldset = FieldSet.from_netcdf(filenames, variables, dimensions,
allow_time_extrapolation = True, mesh='spherical', timestamps = timestamps)
# kernel
def CheckOutOfBounds(particle, fieldset, time):
if particle.state == StatusCode.ErrorOutOfBounds:
particle.delete()
# ParticleSet
part_lons = np.array(lons)
part_lats = np.array(lats)
rls_depth = np.ones(part_lons.shape)*0.5
pset = ParticleSet.from_list(fieldset = fieldset, pclass = MyParticle, lon = part_lons, lat = part_lats, depth = rls_depth, )
# Kernels and execution
kernels = [AdvectionRK4_3D, CheckOutOfBounds] #,
outputdt = timedelta(hours = 1)
runtime = timedelta(days = 6) # the total length of the run
pset.execute(kernels, runtime = runtime, dt = 300, output_file = output_file)
# Some other information:
![field_units](https://github.com/user-attachments/assets/77a8e4db-df2c-467a-9b50-e162a06c68cd)
![plot_code](https://github.com/user-attachments/assets/f694ae94-2fad-4519-b16c-f09bd6ae3509)
![plot_result](https://github.com/user-attachments/assets/0091d1e8-0fb3-40ff-abf0-fb76208f950e)
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 20 replies
-
Hi @Cyuan-hub, likely what is happening is that all your particles are going out of bounds, and are hence deleted due to your import xarray as xr
import matplotlib.pyplot as plt
# Load the ParticleFile
ds = xr.open_zarr(output_file)
plt.plot(ds['lon'].T, ds['lat'].T)
plt.show() If you see the trajectories move to the boundaries of your domain (also check through bathymetry!) then it's simply that all of your particles are being deleted! |
Beta Was this translation helpful? Give feedback.
@Cyuan-hub no problem at all! Yep, I think in your coordinate data you have your lons and lats flipped.
Parcels 'sees' the data like it is in the unflipped cases, so it's very likely that you have just got the order of your lons and lats wrong in the mesh_mask file you created!