Skip to content

Commit fcf3044

Browse files
committed
time could be float replace range by arange
1 parent f3f4530 commit fcf3044

File tree

4 files changed

+11
-12
lines changed

4 files changed

+11
-12
lines changed

examples/16_network/pet_follow_particle.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,12 @@ def update(frame):
140140
shape = (n.obs.size, 2)
141141
# Forward run
142142
i_target_f, pct_target_f = -ones(shape, dtype="i4"), zeros(shape, dtype="i1")
143-
for t in range(t_start, t_end - dt):
143+
for t in arange(t_start, t_end - dt):
144144
particle_candidate(x0, y0, c, n, t, i_target_f, pct_target_f, n_days=dt)
145145

146146
# Backward run
147147
i_target_b, pct_target_b = -ones(shape, dtype="i4"), zeros(shape, dtype="i1")
148-
for t in range(t_start + dt, t_end):
148+
for t in arange(t_start + dt, t_end):
149149
particle_candidate(x0, y0, c, n, t, i_target_b, pct_target_b, n_days=-dt)
150150

151151
# %%

examples/16_network/pet_segmentation_anim.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ def update(i_frame):
9696

9797
indices_frames = INDICES[i_frame]
9898
mappable_CONTOUR.set_data(
99-
e.contour_lon_e[indices_frames],
100-
e.contour_lat_e[indices_frames],
99+
e.contour_lon_e[indices_frames], e.contour_lat_e[indices_frames],
101100
)
102101
mappable_CONTOUR.set_color(cmap.colors[tr[indices_frames] % len(cmap.colors)])
103102
return (mappable_tracks,)

notebooks/python_module/16_network/pet_follow_particle.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
},
121121
"outputs": [],
122122
"source": [
123-
"step = 1 / 60.0\n\nx, y = meshgrid(arange(24, 36, step), arange(31, 36, step))\nx0, y0 = x.reshape(-1), y.reshape(-1)\n# Pre-order to speed up\n_, i = group_obs(x0, y0, 1, 360)\nx0, y0 = x0[i], y0[i]\n\nt_start, t_end = n.period\ndt = 14\n\nshape = (n.obs.size, 2)\n# Forward run\ni_target_f, pct_target_f = -ones(shape, dtype=\"i4\"), zeros(shape, dtype=\"i1\")\nfor t in range(t_start, t_end - dt):\n particle_candidate(x0, y0, c, n, t, i_target_f, pct_target_f, n_days=dt)\n\n# Backward run\ni_target_b, pct_target_b = -ones(shape, dtype=\"i4\"), zeros(shape, dtype=\"i1\")\nfor t in range(t_start + dt, t_end):\n particle_candidate(x0, y0, c, n, t, i_target_b, pct_target_b, n_days=-dt)"
123+
"step = 1 / 60.0\n\nx, y = meshgrid(arange(24, 36, step), arange(31, 36, step))\nx0, y0 = x.reshape(-1), y.reshape(-1)\n# Pre-order to speed up\n_, i = group_obs(x0, y0, 1, 360)\nx0, y0 = x0[i], y0[i]\n\nt_start, t_end = n.period\ndt = 14\n\nshape = (n.obs.size, 2)\n# Forward run\ni_target_f, pct_target_f = -ones(shape, dtype=\"i4\"), zeros(shape, dtype=\"i1\")\nfor t in arange(t_start, t_end - dt):\n particle_candidate(x0, y0, c, n, t, i_target_f, pct_target_f, n_days=dt)\n\n# Backward run\ni_target_b, pct_target_b = -ones(shape, dtype=\"i4\"), zeros(shape, dtype=\"i1\")\nfor t in arange(t_start + dt, t_end):\n particle_candidate(x0, y0, c, n, t, i_target_b, pct_target_b, n_days=-dt)"
124124
]
125125
},
126126
{

notebooks/python_module/16_network/pet_segmentation_anim.ipynb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"\n# Network segmentation process\n"
18+
"\nNetwork segmentation process\n============================\n"
1919
]
2020
},
2121
{
@@ -62,7 +62,7 @@
6262
"cell_type": "markdown",
6363
"metadata": {},
6464
"source": [
65-
"## Load data\nLoad data where observations are put in same network but no segmentation\n\n"
65+
"Load data\n---------\nLoad data where observations are put in same network but no segmentation\n\n"
6666
]
6767
},
6868
{
@@ -80,7 +80,7 @@
8080
"cell_type": "markdown",
8181
"metadata": {},
8282
"source": [
83-
"## Do segmentation\nSegmentation based on maximum overlap, temporal window for candidates = 5 days\n\n"
83+
"Do segmentation\n---------------\nSegmentation based on maximum overlap, temporal window for candidates = 5 days\n\n"
8484
]
8585
},
8686
{
@@ -98,7 +98,7 @@
9898
"cell_type": "markdown",
9999
"metadata": {},
100100
"source": [
101-
"## Anim\n\n"
101+
"Anim\n----\n\n"
102102
]
103103
},
104104
{
@@ -109,14 +109,14 @@
109109
},
110110
"outputs": [],
111111
"source": [
112-
"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=GUI_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)"
112+
"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], 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=GUI_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
]
114114
},
115115
{
116116
"cell_type": "markdown",
117117
"metadata": {},
118118
"source": [
119-
"## Final Result\n\n"
119+
"Final Result\n------------\n\n"
120120
]
121121
},
122122
{
@@ -147,7 +147,7 @@
147147
"name": "python",
148148
"nbconvert_exporter": "python",
149149
"pygments_lexer": "ipython3",
150-
"version": "3.7.9"
150+
"version": "3.7.7"
151151
}
152152
},
153153
"nbformat": 4,

0 commit comments

Comments
 (0)