You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"Load Input grid, ADT is used to detect eddies\n\n"
37
+
]
38
+
},
39
+
{
40
+
"cell_type": "code",
41
+
"execution_count": null,
42
+
"metadata": {
43
+
"collapsed": false
44
+
},
45
+
"outputs": [],
46
+
"source": [
47
+
"g = RegularGridDataset(\n data.get_path(\"dt_med_allsat_phy_l4_20160515_20190101.nc\"), \"longitude\", \"latitude\"\n)\n# Compute u/v from height\ng.add_uv(\"adt\")"
48
+
]
49
+
},
50
+
{
51
+
"cell_type": "markdown",
52
+
"metadata": {},
53
+
"source": [
54
+
"Load detection files\n\n"
55
+
]
56
+
},
57
+
{
58
+
"cell_type": "code",
59
+
"execution_count": null,
60
+
"metadata": {
61
+
"collapsed": false
62
+
},
63
+
"outputs": [],
64
+
"source": [
65
+
"a = EddiesObservations.load_file(data.get_path(\"Anticyclonic_20160515.nc\"))\nc = EddiesObservations.load_file(data.get_path(\"Cyclonic_20160515.nc\"))"
"class VideoAnimation(FuncAnimation):\n def _repr_html_(self, *args, **kwargs):\n\"\"\"To get video in html and have a player\"\"\"\n return self.to_html5_video()\n\n def save(self, *args, **kwargs):\n if args[0].endswith(\"gif\"):\n # In this case gif is use to create thumbnail which are not use but consume same time than video\n # So we create an empty file, to save time\n with open(args[0], \"w\") as _:\n pass\n return\n return super().save(*args, **kwargs)"
95
+
]
96
+
},
97
+
{
98
+
"cell_type": "markdown",
99
+
"metadata": {},
100
+
"source": [
101
+
"## Anim\nParticules positions\n\n"
102
+
]
103
+
},
104
+
{
105
+
"cell_type": "code",
106
+
"execution_count": null,
107
+
"metadata": {
108
+
"collapsed": false
109
+
},
110
+
"outputs": [],
111
+
"source": [
112
+
"x, y = np.meshgrid(np.arange(13, 36, 0.125), np.arange(28, 40, 0.125))\nx, y = x.reshape(-1), y.reshape(-1)\n# Remove all original position that we can't advect at first place\nm = ~np.isnan(g.interp(\"u\", x, y))\nx, y = x[m], y[m]\n\n# Movie properties\nkwargs = dict(frames=np.arange(51), interval=90)\nkw_p = dict(nb_step=2, time_step=21600)\nframe_t = kw_p[\"nb_step\"] * kw_p[\"time_step\"] / 86400.0\n\n\ndef anim_ax(generator, **kw):\n t = 0\n for _ in range(4):\n generator.__next__()\n t += frame_t\n\n fig = plt.figure(figsize=(10, 5), dpi=64)\n ax = fig.add_axes([0, 0, 1, 1], projection=\"full_axes\")\n ax.set_xlim(19, 30), ax.set_ylim(31, 36.5), ax.grid()\n a.filled(ax, facecolors=\"r\", alpha=0.1), c.filled(ax, facecolors=\"b\", alpha=0.1)\n return fig, ax.text(21, 32.1, \"\"), ax.plot([], [], \"k\", **kw)[0], t\n\n\ndef update(i_frame, t_step):\n global t\n x, y = p.__next__()\n t += t_step\n l.set_data(x, y)\n txt.set_text(f\"T0 + {t:.1f} days\")"
113
+
]
114
+
},
115
+
{
116
+
"cell_type": "markdown",
117
+
"metadata": {},
118
+
"source": [
119
+
"### Filament forward\n\n"
120
+
]
121
+
},
122
+
{
123
+
"cell_type": "code",
124
+
"execution_count": null,
125
+
"metadata": {
126
+
"collapsed": false
127
+
},
128
+
"outputs": [],
129
+
"source": [
130
+
"p = g.filament(x, y, \"u\", \"v\", **kw_p, filament_size=4, rk4=True)\nfig, txt, l, t = anim_ax(p, lw=0.5)\nani = VideoAnimation(fig, update, **kwargs, fargs=(frame_t,))"
0 commit comments