|
77 | 77 | "npart = 10 # number of particles to be released\n", |
78 | 78 | "lon = 32 * np.ones(npart)\n", |
79 | 79 | "lat = np.linspace(-32.5, -30.5, npart, dtype=np.float32)\n", |
80 | | - "time = ds_fields.time.values[0] + np.arange(0, npart) * np.timedelta64(2, \"h\")\n", |
81 | 80 | "z = np.repeat(ds_fields.depth.values[0], npart)\n", |
| 81 | + "time = ds_fields.time.values[0] + np.arange(0, npart) * np.timedelta64(2, \"h\")\n", |
82 | 82 | "\n", |
83 | 83 | "pset = parcels.ParticleSet(\n", |
84 | | - " fieldset=fieldset, pclass=parcels.Particle, lon=lon, lat=lat, time=time, z=z\n", |
| 84 | + " fieldset=fieldset, pclass=parcels.Particle, x=lon, y=lat, z=z, time=time\n", |
85 | 85 | ")\n", |
86 | 86 | "\n", |
87 | 87 | "output_file = parcels.ParticleFile(\"output.parquet\", outputdt=np.timedelta64(2, \"h\"))" |
|
263 | 263 | "outputs": [], |
264 | 264 | "source": [ |
265 | 265 | "fig, ax = plt.subplots(figsize=(5, 3))\n", |
266 | | - "ax.plot(df_particles[\"lon\"], df_particles[\"lat\"], \".-\")\n", |
| 266 | + "ax.plot(df_particles[\"x\"], df_particles[\"y\"], \".-\")\n", |
267 | 267 | "plt.show()" |
268 | 268 | ] |
269 | 269 | }, |
|
283 | 283 | "fig, ax = plt.subplots(figsize=(5, 3))\n", |
284 | 284 | "for traj in df_particles.partition_by(\"particle_id\", maintain_order=True):\n", |
285 | 285 | " traj_id = traj[\"particle_id\"][0]\n", |
286 | | - " ax.plot(traj[\"lon\"], traj[\"lat\"], \".-\", label=f\"P{traj_id}\")\n", |
| 286 | + " ax.plot(traj[\"x\"], traj[\"y\"], \".-\", label=f\"P{traj_id}\")\n", |
287 | 287 | "ax.legend(loc=\"center left\", bbox_to_anchor=(1.02, 0.5), borderaxespad=0.0)\n", |
288 | 288 | "plt.tight_layout()\n", |
289 | 289 | "plt.show()" |
|
307 | 307 | "particles = df_particles.filter(pl.col(\"time\") == pl.lit(time_to_plot))\n", |
308 | 308 | "\n", |
309 | 309 | "fig, ax = plt.subplots(figsize=(5, 3))\n", |
310 | | - "ax.plot(particles[\"lon\"], particles[\"lat\"], \"o\")\n", |
| 310 | + "ax.plot(particles[\"x\"], particles[\"y\"], \"o\")\n", |
311 | 311 | "title_time = pd.to_datetime(time_to_plot).strftime(\"%Y-%m-%d %H:%M:%S\")\n", |
312 | 312 | "ax.set_title(f\"Particle locations at {title_time}\")\n", |
313 | 313 | "plt.show()" |
|
332 | 332 | ")\n", |
333 | 333 | "\n", |
334 | 334 | "fig, ax = plt.subplots(figsize=(5, 3))\n", |
335 | | - "ax.plot(particles[\"lon\"], particles[\"lat\"], \"o\")\n", |
| 335 | + "ax.plot(particles[\"x\"], particles[\"y\"], \"o\")\n", |
336 | 336 | "ax.set_title(f\"Particle locations {time_step} after their release\")\n", |
337 | 337 | "plt.show()" |
338 | 338 | ] |
|
354 | 354 | "\n", |
355 | 355 | "for traj in df_particles.partition_by(\"particle_id\", maintain_order=True):\n", |
356 | 356 | " distance = np.sqrt(\n", |
357 | | - " (traj[\"lon\"] - traj[\"lon\"][0]) ** 2 + (traj[\"lat\"] - traj[\"lat\"][0]) ** 2\n", |
| 357 | + " (traj[\"x\"] - traj[\"x\"][0]) ** 2 + (traj[\"y\"] - traj[\"y\"][0]) ** 2\n", |
358 | 358 | " )\n", |
359 | 359 | " ax[0].plot(traj[\"time\"], distance, \".-\", label=f\"P{traj['particle_id'][0]}\")\n", |
360 | 360 | "\n", |
|
439 | 439 | "# --> plot first timestep\n", |
440 | 440 | "particles = df_particles.filter(pl.col(\"time\") == pl.lit(timerange[0]))\n", |
441 | 441 | "scatter = ax.scatter(\n", |
442 | | - " particles[\"lon\"],\n", |
443 | | - " particles[\"lat\"],\n", |
| 442 | + " particles[\"x\"],\n", |
| 443 | + " particles[\"y\"],\n", |
444 | 444 | " s=10,\n", |
445 | 445 | " c=[trajectory_to_color[p] for p in particles[\"particle_id\"]],\n", |
446 | 446 | ")\n", |
|
464 | 464 | " particles = df_particles.filter(pl.col(\"time\") == pl.lit(timerange[i]))\n", |
465 | 465 | "\n", |
466 | 466 | " if len(particles) > 0:\n", |
467 | | - " scatter.set_offsets(np.c_[particles[\"lon\"], particles[\"lat\"]])\n", |
| 467 | + " scatter.set_offsets(np.c_[particles[\"x\"], particles[\"y\"]])\n", |
468 | 468 | " scatter.set_color([trajectory_to_color[p] for p in particles[\"particle_id\"]])\n", |
469 | 469 | "\n", |
470 | 470 | " # --> reset trails\n", |
|
481 | 481 | " )\n", |
482 | 482 | " if len(traj_trail) > 1:\n", |
483 | 483 | " (trail,) = ax.plot(\n", |
484 | | - " traj_trail[\"lon\"],\n", |
485 | | - " traj_trail[\"lat\"],\n", |
| 484 | + " traj_trail[\"x\"],\n", |
| 485 | + " traj_trail[\"y\"],\n", |
486 | 486 | " color=trajectory_to_color[traj],\n", |
487 | 487 | " linewidth=0.6,\n", |
488 | 488 | " alpha=0.6,\n", |
|
516 | 516 | "name": "python", |
517 | 517 | "nbconvert_exporter": "python", |
518 | 518 | "pygments_lexer": "ipython3", |
519 | | - "version": "3.14.4" |
| 519 | + "version": "3.14.6" |
520 | 520 | } |
521 | 521 | }, |
522 | 522 | "nbformat": 4, |
|
0 commit comments