Skip to content

Commit 8d1b95e

Browse files
committed
update example to get thumbnail
1 parent e754bce commit 8d1b95e

File tree

4 files changed

+56
-9
lines changed

4 files changed

+56
-9
lines changed

examples/16_network/pet_group_anim.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,16 +135,19 @@ def update(frame):
135135
fig = plt.figure(figsize=(16, 9), dpi=50)
136136
ax = fig.add_axes([0, 0, 1, 1])
137137
ax.set_aspect("equal"), ax.grid(), ax.set_xlim(26, 34), ax.set_ylim(31, 35.5)
138-
groups = ax.scatter(
139-
e.lon,
140-
e.lat,
141-
c=NETWORK_GROUPS[0][2],
142-
cmap=ListedColormap(["gray", *e.COLORS[:-1]], name="from_list", N=30),
143-
vmin=0,
144-
vmax=30,
145-
)
138+
cmap = ListedColormap(["gray", *e.COLORS[:-1]], name="from_list", N=30)
139+
kw_s = dict(cmap=cmap, vmin=0, vmax=30)
140+
groups = ax.scatter(e.lon, e.lat, c=NETWORK_GROUPS[0][2], **kw_s)
146141
current_contour = ax.plot([], [], "k", lw=2, label="Current contour")[0]
147142
matched_contour = ax.plot([], [], "r", lw=1, ls="--", label="Candidate contour")[0]
148143
txt = ax.text(29, 35, "", fontsize=25)
149144
ax.legend(fontsize=25)
150145
ani = VideoAnimation(fig, update, frames=len(NETWORK_GROUPS), interval=220)
146+
147+
# %%
148+
# Final Result
149+
# -----------
150+
fig = plt.figure(figsize=(16, 9))
151+
ax = fig.add_axes([0, 0, 1, 1])
152+
ax.set_aspect("equal"), ax.grid(), ax.set_xlim(26, 34), ax.set_ylim(31, 35.5)
153+
_ = ax.scatter(e.lon, e.lat, c=NETWORK_GROUPS[-1][2], **kw_s)

examples/16_network/pet_segmentation_anim.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,11 @@ def update(i_frame):
116116
e.contour_lon_e[INDICES[0]], e.contour_lat_e[INDICES[0]], color=cmap.colors[0]
117117
)[0]
118118
ani = VideoAnimation(fig, update, frames=range(1, len(TRACKS), 4), interval=125)
119+
120+
# %%
121+
# Final Result
122+
# -----------
123+
fig = plt.figure(figsize=(16, 9))
124+
ax = fig.add_axes([0.04, 0.06, 0.94, 0.88], projection="full_axes")
125+
ax.set_xlim(19, 29), ax.set_ylim(31, 35.5), ax.grid()
126+
_ = ax.scatter(e.lon, e.lat, c=TRACKS[-1], cmap=cmap, vmin=0, vmax=vmax, s=20)

notebooks/python_module/16_network/pet_group_anim.ipynb

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,25 @@
167167
},
168168
"outputs": [],
169169
"source": [
170-
"fig = plt.figure(figsize=(16, 9), dpi=50)\nax = fig.add_axes([0, 0, 1, 1])\nax.set_aspect(\"equal\"), ax.grid(), ax.set_xlim(26, 34), ax.set_ylim(31, 35.5)\ngroups = ax.scatter(\n e.lon,\n e.lat,\n c=NETWORK_GROUPS[0][2],\n cmap=ListedColormap([\"gray\", *e.COLORS[:-1]], name=\"from_list\", N=30),\n vmin=0,\n vmax=30,\n)\ncurrent_contour = ax.plot([], [], \"k\", lw=2, label=\"Current contour\")[0]\nmatched_contour = ax.plot([], [], \"r\", lw=1, ls=\"--\", label=\"Candidate contour\")[0]\ntxt = ax.text(29, 35, \"\", fontsize=25)\nax.legend(fontsize=25)\nani = VideoAnimation(fig, update, frames=len(NETWORK_GROUPS), interval=220)"
170+
"fig = plt.figure(figsize=(16, 9), dpi=50)\nax = fig.add_axes([0, 0, 1, 1])\nax.set_aspect(\"equal\"), ax.grid(), ax.set_xlim(26, 34), ax.set_ylim(31, 35.5)\ncmap = ListedColormap([\"gray\", *e.COLORS[:-1]], name=\"from_list\", N=30)\nkw_s = dict(cmap=cmap, vmin=0, vmax=30)\ngroups = ax.scatter(e.lon, e.lat, c=NETWORK_GROUPS[0][2], **kw_s)\ncurrent_contour = ax.plot([], [], \"k\", lw=2, label=\"Current contour\")[0]\nmatched_contour = ax.plot([], [], \"r\", lw=1, ls=\"--\", label=\"Candidate contour\")[0]\ntxt = ax.text(29, 35, \"\", fontsize=25)\nax.legend(fontsize=25)\nani = VideoAnimation(fig, update, frames=len(NETWORK_GROUPS), interval=220)"
171+
]
172+
},
173+
{
174+
"cell_type": "markdown",
175+
"metadata": {},
176+
"source": [
177+
"## Final Result\n\n"
178+
]
179+
},
180+
{
181+
"cell_type": "code",
182+
"execution_count": null,
183+
"metadata": {
184+
"collapsed": false
185+
},
186+
"outputs": [],
187+
"source": [
188+
"fig = plt.figure(figsize=(16, 9))\nax = fig.add_axes([0, 0, 1, 1])\nax.set_aspect(\"equal\"), ax.grid(), ax.set_xlim(26, 34), ax.set_ylim(31, 35.5)\n_ = ax.scatter(e.lon, e.lat, c=NETWORK_GROUPS[-1][2], **kw_s)"
171189
]
172190
}
173191
],

notebooks/python_module/16_network/pet_segmentation_anim.ipynb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,24 @@
111111
"source": [
112112
"def update(i_frame):\n tr = TRACKS[i_frame]\n mappable_tracks.set_array(tr)\n s = 40 * ones(tr.shape)\n s[tr == 0] = 4\n mappable_tracks.set_sizes(s)\n\n indices_frames = INDICES[i_frame]\n mappable_CONTOUR.set_data(\n e.contour_lon_e[indices_frames],\n e.contour_lat_e[indices_frames],\n )\n mappable_CONTOUR.set_color(cmap.colors[tr[indices_frames] % len(cmap.colors)])\n return (mappable_tracks,)\n\n\nfig = plt.figure(figsize=(16, 9), dpi=60)\nax = fig.add_axes([0.04, 0.06, 0.94, 0.88], projection=\"full_axes\")\nax.set_title(f\"{len(e)} observations to segment\")\nax.set_xlim(19, 29), ax.set_ylim(31, 35.5), ax.grid()\nvmax = TRACKS[-1].max()\ncmap = ListedColormap([\"gray\", *e.COLORS[:-1]], name=\"from_list\", N=vmax)\nmappable_tracks = ax.scatter(\n e.lon, e.lat, c=TRACKS[0], cmap=cmap, vmin=0, vmax=vmax, s=20\n)\nmappable_CONTOUR = ax.plot(\n e.contour_lon_e[INDICES[0]], e.contour_lat_e[INDICES[0]], color=cmap.colors[0]\n)[0]\nani = VideoAnimation(fig, update, frames=range(1, len(TRACKS), 4), interval=125)"
113113
]
114+
},
115+
{
116+
"cell_type": "markdown",
117+
"metadata": {},
118+
"source": [
119+
"## Final Result\n\n"
120+
]
121+
},
122+
{
123+
"cell_type": "code",
124+
"execution_count": null,
125+
"metadata": {
126+
"collapsed": false
127+
},
128+
"outputs": [],
129+
"source": [
130+
"fig = plt.figure(figsize=(16, 9))\nax = fig.add_axes([0.04, 0.06, 0.94, 0.88], projection=\"full_axes\")\nax.set_xlim(19, 29), ax.set_ylim(31, 35.5), ax.grid()\n_ = ax.scatter(e.lon, e.lat, c=TRACKS[-1], cmap=cmap, vmin=0, vmax=vmax, s=20)"
131+
]
114132
}
115133
],
116134
"metadata": {

0 commit comments

Comments
 (0)