|
253 | 253 | "cell_type": "markdown", |
254 | 254 | "metadata": {}, |
255 | 255 | "source": [ |
256 | | - "Now we will simulate the advection and diffusion of the particles using the `AdvectionDiffusionM1` kernel. We run the simulation for 0.3 seconds, with a numerical timestep $\\Delta t = 0.001$s. We also write away particle locations at each timestep for plotting. Note that this will hinder a runtime comparison between kernels, since it will cause most time to be spent on I/O.\n" |
| 256 | + "Now we will simulate the advection and diffusion of the particles using the `AdvectionDiffusionM1` kernel. We run the simulation for 0.3 seconds, with a numerical timestep $\\Delta t = 0.001$ s. We also write away particle locations at each timestep for plotting. Note that this will hinder a runtime comparison between kernels, since it will cause most time to be spent on I/O.\n" |
257 | 257 | ] |
258 | 258 | }, |
259 | 259 | { |
|
463 | 463 | "cell_type": "markdown", |
464 | 464 | "metadata": {}, |
465 | 465 | "source": [ |
466 | | - "Reading velocity fields from netcdf files\n" |
| 466 | + "Reading velocity fields from a Copernicus Marine Service dataset:\n" |
467 | 467 | ] |
468 | 468 | }, |
469 | 469 | { |
|
562 | 562 | "cell_type": "markdown", |
563 | 563 | "metadata": {}, |
564 | 564 | "source": [ |
565 | | - "In the example, particles are released at one location periodically (every hour) for 12 hours\n" |
566 | | - ] |
567 | | - }, |
568 | | - { |
569 | | - "attachments": {}, |
570 | | - "cell_type": "markdown", |
571 | | - "metadata": {}, |
572 | | - "source": [ |
573 | | - "Simulating the particles moving during 7 days using advection (`AdvectionRK4`) and diffusion (`smagdiff`) kernels.\n" |
| 565 | + "In the example, particles are released at one location and simulated for 2 days using advection (`AdvectionRK4`) and diffusion (`smagdiff`) kernels." |
574 | 566 | ] |
575 | 567 | }, |
576 | 568 | { |
|
579 | 571 | "metadata": {}, |
580 | 572 | "outputs": [], |
581 | 573 | "source": [ |
582 | | - "time = np.repeat(\n", |
583 | | - " fieldset.time_interval.left, 13\n", |
584 | | - ") # np.arange(fieldset.time_interval.left, fieldset.time_interval.left+np.timedelta64(13,\"h\"), np.timedelta64(1,'h'))\n", |
| 574 | + "time = np.repeat(fieldset.time_interval.left, 13)\n", |
585 | 575 | "lon = [32] * len(time)\n", |
586 | | - "lat = [-30.5] * len(time)\n", |
| 576 | + "lat = [-30.1] * len(time)\n", |
587 | 577 | "z = [ds_fields.depth[0]] * len(time)\n", |
588 | 578 | "pset = parcels.ParticleSet(\n", |
589 | 579 | " fieldset=fieldset,\n", |
|
602 | 592 | "\n", |
603 | 593 | "pset.execute(\n", |
604 | 594 | " [parcels.kernels.AdvectionRK4, smagdiff],\n", |
605 | | - " runtime=np.timedelta64(3, \"D\"),\n", |
| 595 | + " runtime=np.timedelta64(2, \"D\"),\n", |
606 | 596 | " dt=np.timedelta64(5, \"m\"),\n", |
607 | 597 | " output_file=output_file,\n", |
608 | 598 | ")" |
|
613 | 603 | "cell_type": "markdown", |
614 | 604 | "metadata": {}, |
615 | 605 | "source": [ |
616 | | - "Visualize the trajectories using the trajan package\n" |
| 606 | + "When we visualize the trajectories using the trajan package, we can see that the particles released at the same time and location spread out over time:\n" |
617 | 607 | ] |
618 | 608 | }, |
619 | 609 | { |
|
623 | 613 | "outputs": [], |
624 | 614 | "source": [ |
625 | 615 | "ds_particles = xr.open_zarr(\"smagdiff.zarr\")\n", |
626 | | - "ds_particles.traj.plot()\n", |
| 616 | + "temperature = ds_fields.isel(time=0, depth=0).thetao.plot(cmap=\"magma\")\n", |
| 617 | + "velocity = ds_fields.isel(time=0, depth=0).plot.quiver(\n", |
| 618 | + " x=\"longitude\", y=\"latitude\", u=\"uo\", v=\"vo\"\n", |
| 619 | + ")\n", |
| 620 | + "ds_particles.traj.plot(color=\"blue\")\n", |
| 621 | + "plt.ylim(-31, -30)\n", |
| 622 | + "plt.xlim(31, 32.1)\n", |
627 | 623 | "plt.show()" |
628 | 624 | ] |
629 | 625 | }, |
|
649 | 645 | "\n", |
650 | 646 | "Smagorinsky, J. (1963). “General circulation experiments with primitive equations. 1. The basic experiment.” _Monthly Weather Review_, 91, 99–164. https://doi.org/10.1175/1520-0493(1963)091%3C0099:GCEWTP%3E2.3.CO;2\n" |
651 | 647 | ] |
| 648 | + }, |
| 649 | + { |
| 650 | + "cell_type": "markdown", |
| 651 | + "metadata": {}, |
| 652 | + "source": [] |
652 | 653 | } |
653 | 654 | ], |
654 | 655 | "metadata": { |
|
0 commit comments