Skip to content

Commit 74075c1

Browse files
Merge pull request AntSimi#101 from CoriPegliasco/advection
modify coherence_analysis and basic changes
2 parents ab3020f + 80c529a commit 74075c1

File tree

17 files changed

+307
-97
lines changed

17 files changed

+307
-97
lines changed

examples/02_eddy_identification/pet_eddy_detection_ACC.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def set_fancy_labels(fig, ticklabelsize=14, labelsize=14, labelweight="semibold"
6565
y_name="latitude",
6666
# Manual area subset
6767
indexs=dict(
68-
latitude=slice(100 - margin, 220 + margin), longitude=slice(0, 230 + margin),
68+
latitude=slice(100 - margin, 220 + margin),
69+
longitude=slice(0, 230 + margin),
6970
),
7071
)
7172
g_raw = RegularGridDataset(**kw_data)
@@ -187,10 +188,16 @@ def set_fancy_labels(fig, ticklabelsize=14, labelsize=14, labelweight="semibold"
187188
ax.set_ylabel("With filter")
188189

189190
ax.plot(
190-
a_[field][i_a] * factor, a[field][j_a] * factor, "r.", label="Anticyclonic",
191+
a_[field][i_a] * factor,
192+
a[field][j_a] * factor,
193+
"r.",
194+
label="Anticyclonic",
191195
)
192196
ax.plot(
193-
c_[field][i_c] * factor, c[field][j_c] * factor, "b.", label="Cyclonic",
197+
c_[field][i_c] * factor,
198+
c[field][j_c] * factor,
199+
"b.",
200+
label="Cyclonic",
194201
)
195202
ax.set_aspect("equal"), ax.grid()
196203
ax.plot((0, 1000), (0, 1000), "g")

examples/06_grid_manipulation/pet_lavd.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ def update(i_frame):
159159
# Format LAVD data
160160
lavd = RegularGridDataset.with_array(
161161
coordinates=("lon", "lat"),
162-
datas=dict(lavd=lavd.T, lon=x_g, lat=y_g,),
162+
datas=dict(
163+
lavd=lavd.T,
164+
lon=x_g,
165+
lat=y_g,
166+
),
163167
centered=True,
164168
)
165169

examples/16_network/pet_atlas.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,33 +153,33 @@ def update_axes(ax, mappable=None):
153153
update_axes(ax, m).set_label("Pixel used in % all atlas")
154154

155155
# %%
156-
# All Spliting
157-
# ------------
158-
# Display the occurence of spliting events
156+
# All splitting
157+
# -------------
158+
# Display the occurence of splitting events
159159
ax = start_axes("")
160-
g_all_spliting = n.spliting_event().grid_count(bins)
161-
m = g_all_spliting.display(ax, **kw_time, vmin=0, vmax=1)
160+
g_all_splitting = n.splitting_event().grid_count(bins)
161+
m = g_all_splitting.display(ax, **kw_time, vmin=0, vmax=1)
162162
update_axes(ax, m).set_label("Pixel used in % of time")
163163

164164
# %%
165-
# Ratio spliting events / eddy presence
165+
# Ratio splitting events / eddy presence
166166
ax = start_axes("")
167-
g_ = g_all_spliting.vars["count"] * 100.0 / g_all.vars["count"]
168-
m = g_all_spliting.display(ax, **kw_ratio, vmin=0, vmax=5, name=g_)
167+
g_ = g_all_splitting.vars["count"] * 100.0 / g_all.vars["count"]
168+
m = g_all_splitting.display(ax, **kw_ratio, vmin=0, vmax=5, name=g_)
169169
update_axes(ax, m).set_label("Pixel used in % all atlas")
170170

171171
# %%
172-
# Spliting in networks longer than 10 days
173-
# ----------------------------------------
172+
# splitting in networks longer than 10 days
173+
# -----------------------------------------
174174
ax = start_axes("")
175-
g_10_spliting = n10.spliting_event().grid_count(bins)
176-
m = g_10_spliting.display(ax, **kw_time, vmin=0, vmax=1)
175+
g_10_splitting = n10.splitting_event().grid_count(bins)
176+
m = g_10_splitting.display(ax, **kw_time, vmin=0, vmax=1)
177177
update_axes(ax, m).set_label("Pixel used in % of time")
178178
# %%
179179
ax = start_axes("")
180180
g_ = ma.array(
181-
g_10_spliting.vars["count"] * 100.0 / g_10.vars["count"],
181+
g_10_splitting.vars["count"] * 100.0 / g_10.vars["count"],
182182
mask=g_10.vars["count"] < 365,
183183
)
184-
m = g_10_spliting.display(ax, **kw_ratio, vmin=0, vmax=5, name=g_)
184+
m = g_10_splitting.display(ax, **kw_ratio, vmin=0, vmax=5, name=g_)
185185
update_axes(ax, m).set_label("Pixel used in % all atlas")

examples/16_network/pet_follow_particle.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ def update(frame):
125125
# %%
126126
# Particle advection
127127
# ^^^^^^^^^^^^^^^^^^
128+
# Advection from speed contour to speed contour (default)
129+
128130
step = 1 / 60.0
129131

130-
t_start, t_end = n.period
132+
t_start, t_end = int(n.period[0]), int(n.period[1])
131133
dt = 14
132134

133135
shape = (n.obs.size, 2)

examples/16_network/pet_relative.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,13 @@
292292
m1
293293

294294
# %%
295-
# Get spliting event
296-
# ------------------
295+
# Get splitting event
296+
# -------------------
297297
# Display the position of the eddies before a splitting
298298
fig = plt.figure(figsize=(15, 8))
299299
ax = fig.add_axes([0.04, 0.06, 0.90, 0.88], projection=GUI_AXES)
300300
n.plot(ax, color_cycle=n.COLORS)
301-
s0, s1, s1_start = n.spliting_event(triplet=True)
301+
s0, s1, s1_start = n.splitting_event(triplet=True)
302302
s0.display(ax, color="violet", lw=2, label="Eddies before splitting")
303303
s1.display(ax, color="blueviolet", lw=2, label="Eddies after splitting")
304304
s1_start.display(ax, color="black", lw=2, label="Eddies starting by splitting")

examples/16_network/pet_replay_segmentation.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,13 @@ def get_obs(dataset):
149149
n_.median_filter(15, "time", "latitude")
150150
kw["s"] = (n_.radius_e * 1e-3) ** 2 / 30 ** 2 * 20
151151
m = n_.scatter_timeline(
152-
ax, "shape_error_e", vmin=14, vmax=70, **kw, yfield="lon", method="all",
152+
ax,
153+
"shape_error_e",
154+
vmin=14,
155+
vmax=70,
156+
**kw,
157+
yfield="lon",
158+
method="all",
153159
)
154160
ax.set_ylabel("Longitude")
155161
cb = update_axes(ax, m["scatter"])

examples/16_network/pet_segmentation_anim.py

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

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

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
matplotlib
22
netCDF4
33
numba>=0.53
4-
numpy
4+
numpy<1.21
55
opencv-python
66
pint
77
polygon3

src/py_eddy_tracker/__init__.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ def identify_time(str_date):
404404
nc_dims=("obs",),
405405
nc_attr=dict(
406406
long_name="Previous observation index",
407-
comment="Index of previous observation in a spliting case",
407+
comment="Index of previous observation in a splitting case",
408408
),
409409
),
410410
next_obs=dict(
@@ -422,14 +422,20 @@ def identify_time(str_date):
422422
nc_name="previous_cost",
423423
nc_type="float32",
424424
nc_dims=("obs",),
425-
nc_attr=dict(long_name="Previous cost for previous observation", comment="",),
425+
nc_attr=dict(
426+
long_name="Previous cost for previous observation",
427+
comment="",
428+
),
426429
),
427430
next_cost=dict(
428431
attr_name=None,
429432
nc_name="next_cost",
430433
nc_type="float32",
431434
nc_dims=("obs",),
432-
nc_attr=dict(long_name="Next cost for next observation", comment="",),
435+
nc_attr=dict(
436+
long_name="Next cost for next observation",
437+
comment="",
438+
),
433439
),
434440
n=dict(
435441
attr_name=None,
@@ -640,7 +646,8 @@ def identify_time(str_date):
640646
nc_type="f4",
641647
nc_dims=("obs",),
642648
nc_attr=dict(
643-
long_name="Log base 10 background chlorophyll", units="Log(Chl/[mg/m^3])",
649+
long_name="Log base 10 background chlorophyll",
650+
units="Log(Chl/[mg/m^3])",
644651
),
645652
),
646653
year=dict(

src/py_eddy_tracker/appli/eddies.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ def browse_dataset_in(
243243
filenames = bytes_(glob(full_path))
244244

245245
dataset_list = empty(
246-
len(filenames), dtype=[("filename", "S500"), ("date", "datetime64[s]")],
246+
len(filenames),
247+
dtype=[("filename", "S500"), ("date", "datetime64[s]")],
247248
)
248249
dataset_list["filename"] = filenames
249250

@@ -371,7 +372,8 @@ def track(
371372

372373
logger.info("Longer track saved have %d obs", c.nb_obs_by_tracks.max())
373374
logger.info(
374-
"The mean length is %d observations for long track", c.nb_obs_by_tracks.mean(),
375+
"The mean length is %d observations for long track",
376+
c.nb_obs_by_tracks.mean(),
375377
)
376378

377379
long_track.write_file(**kw_write)
@@ -381,7 +383,14 @@ def track(
381383

382384

383385
def get_group(
384-
dataset1, dataset2, index1, index2, score, invalid=2, low=10, high=60,
386+
dataset1,
387+
dataset2,
388+
index1,
389+
index2,
390+
score,
391+
invalid=2,
392+
low=10,
393+
high=60,
385394
):
386395
group1, group2 = dict(), dict()
387396
m_valid = (score * 100) >= invalid
@@ -490,7 +499,8 @@ def get_values(v, dataset):
490499
]
491500

492501
labels = dict(
493-
high=f"{high:0.0f} <= high", low=f"{invalid:0.0f} <= low < {low:0.0f}",
502+
high=f"{high:0.0f} <= high",
503+
low=f"{invalid:0.0f} <= low < {low:0.0f}",
494504
)
495505

496506
keys = [labels.get(key, key) for key in list(gr_ref.values())[0].keys()]

0 commit comments

Comments
 (0)