From 1fe3489ef419a39c7b6329b032cd6a398f453feb Mon Sep 17 00:00:00 2001 From: Knut-Frode Dagestad Date: Wed, 25 Jun 2025 10:57:30 +0200 Subject: [PATCH] Added density plot also to Parcels example --- examples/example_parcels.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/example_parcels.py b/examples/example_parcels.py index 82ed81a..8b5a8fb 100644 --- a/examples/example_parcels.py +++ b/examples/example_parcels.py @@ -23,11 +23,23 @@ # TODO: we must allow no time dimension for the below to work #ds.mean('trajectory', skipna=True).traj.plot(color='r', label='Mean trajectory') # In the meantime, we regrid to a regular 1D dataset to allow plotting a mean trajectory -ds = ds.traj.gridtime('1h') +ds = ds.traj.gridtime('4h') ds.mean('trajectory').traj.plot(color='r', label='Mean trajectory') plt.legend() plt.show() +#%% +# Calculating and plotting the concentration of elements, after 6 and 24 hours +grid = ds.traj.make_grid(dx=3000) +ds_conc = ds.traj.concentration(grid) +plt.subplot(1,2,1) +ds_conc.number.isel(time=6).plot(vmin=0, vmax=20) +plt.scatter(ds.isel(time=6).lon, ds.isel(time=6).lat, s=1, color='black') +plt.subplot(1,2,2) +ds_conc.number.isel(time=24).plot(vmin=0, vmax=20) +plt.scatter(ds.isel(time=24).lon, ds.isel(time=24).lat, s=1, color='black') +plt.show() + #%% # Calculating skillscore # Defining the first trajectory to be the "true"