|
207 | 207 | "ds = xr.open_zarr(\"output_curvilinear.zarr\")\n", |
208 | 208 | "\n", |
209 | 209 | "plt.plot(ds.lon.T, ds.lat.T, \".-\")\n", |
210 | | - "plt.vlines(np.arange(-180, 900, 360), -90, 90, color=\"r\", label=\"antimeridian\")\n", |
| 210 | + "plt.vlines(np.arange(-180, 901, 360), -90, 90, color=\"r\", label=\"antimeridian\")\n", |
211 | 211 | "plt.ylabel(\"Latitude [deg N]\")\n", |
212 | 212 | "plt.xlabel(\"Longitude [deg E]\")\n", |
| 213 | + "plt.xticks(np.arange(-180, 901, 90))\n", |
213 | 214 | "plt.legend(loc=\"lower right\")\n", |
214 | 215 | "plt.show()" |
215 | 216 | ] |
|
275 | 276 | "ax[0].vlines(np.arange(-180, 360, 360), -90, 90, color=\"r\", label=\"antimeridian\")\n", |
276 | 277 | "ax[0].set_ylabel(\"Latitude [deg N]\")\n", |
277 | 278 | "ax[0].set_xlabel(\"Longitude [deg E]\")\n", |
| 279 | + "ax[0].set_xticks(np.arange(-180, 181, 45))\n", |
278 | 280 | "ax[0].set_title(\"in post processing\")\n", |
279 | 281 | "ax[0].legend(loc=\"lower center\")\n", |
280 | 282 | "\n", |
281 | 283 | "ax[1].plot(ds_periodic.lon.T, ds_periodic.lat.T, \".-\")\n", |
282 | 284 | "ax[1].vlines(np.arange(-180, 360, 360), -90, 90, color=\"r\", label=\"antimeridian\")\n", |
283 | 285 | "ax[1].set_ylabel(\"Latitude [deg N]\")\n", |
284 | 286 | "ax[1].set_xlabel(\"Longitude [deg E]\")\n", |
| 287 | + "ax[1].set_xticks(np.arange(-180, 181, 45))\n", |
285 | 288 | "ax[1].set_title(\"with periodic Kernel\")\n", |
286 | 289 | "ax[1].legend(loc=\"lower center\")\n", |
287 | 290 | "\n", |
288 | 291 | "plt.show()" |
289 | 292 | ] |
290 | | - }, |
291 | | - { |
292 | | - "attachments": {}, |
293 | | - "cell_type": "markdown", |
294 | | - "metadata": {}, |
295 | | - "source": [ |
296 | | - "## Speeding up `ParticleSet` initialisation by efficiently finding particle start-locations on the `Grid`\n", |
297 | | - "\n", |
298 | | - "On a Curvilinear grid, determining the location of all `particles` on the grid is more complicated and therefore takes longer than on a Rectilinear grid. Since Parcels version 2.2.2, a function is available on the `ParticleSet` class, that speeds up the look-up. After creating the `ParticleSet`, but before running the `ParticleSet.execute()`, simply call the function `ParticleSet.populate_indices()`.\n" |
299 | | - ] |
300 | | - }, |
301 | | - { |
302 | | - "cell_type": "code", |
303 | | - "execution_count": null, |
304 | | - "metadata": {}, |
305 | | - "outputs": [], |
306 | | - "source": [ |
307 | | - "pset = parcels.ParticleSet(fieldset, lon=lonp, lat=latp)\n", |
308 | | - "pset.populate_indices()" |
309 | | - ] |
310 | | - }, |
311 | | - { |
312 | | - "cell_type": "markdown", |
313 | | - "metadata": {}, |
314 | | - "source": [ |
315 | | - "For this speed-up to remain in effect while evaluating a `parcels.Field` in a `Kernel`, we need to remember to pass the `particles` object in the square brackets, by using one of:\n", |
316 | | - "```\n", |
317 | | - "particles.P = fieldset.P[particles]\n", |
318 | | - "```\n", |
319 | | - "or\n", |
320 | | - "```\n", |
321 | | - "particles.P = fieldset.P[particles.time, particles.z, particles.lat, particles.lon, particles]\n", |
322 | | - "```" |
323 | | - ] |
324 | 293 | } |
325 | 294 | ], |
326 | 295 | "metadata": { |
|
0 commit comments