@@ -71,7 +71,7 @@ pset = parcels.ParticleSet(
7171temperature = ds_fields.isel(time=0, depth=0).thetao.plot(cmap="magma")
7272velocity = ds_fields.isel(time=0, depth=0).plot.quiver(x="longitude", y="latitude", u="uo", v="vo")
7373ax = temperature.axes
74- ax.scatter(lon,lat,s=40,c='w',edgecolors='r')
74+ ax.scatter(lon,lat,s=40,c='w',edgecolors='r');
7575```
7676
7777## Compute: ` Kernel `
@@ -134,7 +134,8 @@ Let's verify that Parcels has computed the advection of the virtual particles!
134134import matplotlib.pyplot as plt
135135
136136# plot positions and color particles by number of observation
137- scatter = plt.scatter(ds_particles.lon.T, ds_particles.lat.T, c=np.repeat(ds_particles.obs.values,npart), cmap="Greys", edgecolors='r')
137+ scatter = plt.scatter(ds_particles.lon.T, ds_particles.lat.T, c=np.repeat(ds_particles.obs.values,npart))
138+ plt.scatter(lon,lat,facecolors="none",edgecolors='r') # starting positions
138139plt.xlim(31,33)
139140plt.ylabel("Latitude [deg N]")
140141plt.ylim(-33,-30)
@@ -171,14 +172,19 @@ When we check the output, we can see that the particles have returned to their o
171172``` {code-cell}
172173ds_particles_back = xr.open_zarr("output-backwards.zarr")
173174
174- scatter = plt.scatter(ds_particles_back.lon.T, ds_particles_back.lat.T, c=np.repeat(ds_particles_back.obs.values,npart), cmap="Greys", edgecolors='r')
175+ scatter = plt.scatter(ds_particles_back.lon.T, ds_particles_back.lat.T, c=np.repeat(ds_particles_back.obs.values,npart))
176+ plt.scatter(lon,lat,facecolors="none",edgecolors='r') # starting positions
175177plt.xlabel("Longitude [deg E]")
176178plt.xlim(31,33)
177179plt.ylabel("Latitude [deg N]")
178180plt.ylim(-33,-30)
179181plt.colorbar(scatter, label="Observation number")
180182plt.show()
183+ ```
184+
185+ Using Euler forward advection, the final positions are equal to the original positions with an accuracy of 2 decimals:
181186
187+ ``` {code-cell}
182188# testing that final location == original location
183189np.testing.assert_almost_equal(ds_particles_back['lat'].values[:,-1],ds_particles['lat'].values[:,0], 2)
184190np.testing.assert_almost_equal(ds_particles_back['lon'].values[:,-1],ds_particles['lon'].values[:,0], 2)
0 commit comments