Skip to content

Commit c455bc6

Browse files
committed
black & isort
1 parent f52783d commit c455bc6

File tree

14 files changed

+181
-73
lines changed

14 files changed

+181
-73
lines changed

doc/conf.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@
9696
master_doc = "index"
9797

9898
# General information about the project.
99-
project = u"py-eddy-tracker"
100-
copyright = u"2019, A. Delepoulle & E. Mason"
101-
author = u"A. Delepoulle & E. Mason"
99+
project = "py-eddy-tracker"
100+
copyright = "2019, A. Delepoulle & E. Mason"
101+
author = "A. Delepoulle & E. Mason"
102102

103103
# The version info for the project you're documenting, acts as replacement for
104104
# |version| and |release|, also used in various other places throughout the
@@ -272,8 +272,8 @@
272272
(
273273
master_doc,
274274
"py-eddy-tracker.tex",
275-
u"py-eddy-tracker Documentation",
276-
u"A. Delepoulle \\& E. Mason",
275+
"py-eddy-tracker Documentation",
276+
"A. Delepoulle \\& E. Mason",
277277
"manual",
278278
),
279279
]
@@ -304,7 +304,7 @@
304304
# One entry per manual page. List of tuples
305305
# (source start file, name, description, authors, manual section).
306306
man_pages = [
307-
(master_doc, "py-eddy-tracker", u"py-eddy-tracker Documentation", [author], 1)
307+
(master_doc, "py-eddy-tracker", "py-eddy-tracker Documentation", [author], 1)
308308
]
309309

310310
# If true, show URL addresses after external links.
@@ -320,7 +320,7 @@
320320
(
321321
master_doc,
322322
"py-eddy-tracker",
323-
u"py-eddy-tracker Documentation",
323+
"py-eddy-tracker Documentation",
324324
author,
325325
"py-eddy-tracker",
326326
"One line description of project.",

examples/06_grid_manipulation/pet_advect.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ def update(i_frame, t_step):
139139
)
140140
for time_step in (10800, 21600, 43200, 86400):
141141
x, y = x0.copy(), y0.copy()
142-
kw_advect = dict(nb_step=int(50 * 86400 / time_step), time_step=time_step, u_name="u", v_name="v")
142+
kw_advect = dict(
143+
nb_step=int(50 * 86400 / time_step), time_step=time_step, u_name="u", v_name="v"
144+
)
143145
g.advect(x, y, **kw_advect).__next__()
144146
g.advect(x, y, **kw_advect, backward=True).__next__()
145147
d = ((x - x0) ** 2 + (y - y0) ** 2) ** 0.5
@@ -158,7 +160,12 @@ def update(i_frame, t_step):
158160
time_step = 10800
159161
for duration in (5, 50, 100):
160162
x, y = x0.copy(), y0.copy()
161-
kw_advect = dict(nb_step=int(duration * 86400 / time_step), time_step=time_step, u_name="u", v_name="v")
163+
kw_advect = dict(
164+
nb_step=int(duration * 86400 / time_step),
165+
time_step=time_step,
166+
u_name="u",
167+
v_name="v",
168+
)
162169
g.advect(x, y, **kw_advect).__next__()
163170
g.advect(x, y, **kw_advect, backward=True).__next__()
164171
d = ((x - x0) ** 2 + (y - y0) ** 2) ** 0.5

examples/06_grid_manipulation/pet_lavd.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ def save(self, *args, **kwargs):
110110
step_by_day = 3
111111
# Compute step of advection every 4h
112112
nb_step = 2
113-
kw_p = dict(nb_step=nb_step, time_step=86400 / step_by_day / nb_step, u_name="u", v_name="v")
113+
kw_p = dict(
114+
nb_step=nb_step, time_step=86400 / step_by_day / nb_step, u_name="u", v_name="v"
115+
)
114116
# Start a generator which at each iteration return new position at next time step
115117
particule = g.advect(x, y, **kw_p, rk4=True)
116118

examples/07_cube_manipulation/pet_fsle_med.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,9 @@ def build_triplet(x, y, step=0.02):
142142
used = zeros(x.shape[0], dtype="bool")
143143

144144
# advection generator
145-
kw = dict(t_init=t0, nb_step=1, backward=backward, mask_particule=used, u_name="u", v_name="v")
145+
kw = dict(
146+
t_init=t0, nb_step=1, backward=backward, mask_particule=used, u_name="u", v_name="v"
147+
)
146148
p = c.advect(x, y, time_step=86400 / time_step_by_days, **kw)
147149

148150
# We check at each step of advection if particle distance is over `dist_max`

examples/07_cube_manipulation/pet_particles_drift.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"longitude",
2121
"latitude",
2222
"time",
23-
unset=True
23+
unset=True,
2424
)
2525

2626
# %%
@@ -43,4 +43,4 @@
4343
ax.plot(x, y, lw=3)
4444
ax.set_title("10 days particle paths")
4545
ax.set_xlim(31, 35), ax.set_ylim(32, 34.5)
46-
ax.grid()
46+
ax.grid()

examples/16_network/pet_follow_particle.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ def save(self, *args, **kwargs):
9595
a.txt.set_position((25, 31))
9696

9797
step = 0.25
98-
kw_p = dict(nb_step=2, time_step=86400 * step * 0.5, t_init=t_snapshot - 2 * step, u_name="u", v_name="v")
98+
kw_p = dict(
99+
nb_step=2,
100+
time_step=86400 * step * 0.5,
101+
t_init=t_snapshot - 2 * step,
102+
u_name="u",
103+
v_name="v",
104+
)
99105

100106
mappables = dict()
101107
particules = c.advect(x, y, **kw_p)

src/py_eddy_tracker/appli/network.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ def build_network():
5454
memory=args.memory,
5555
)
5656
group = n.group_observations(
57-
min_overlap=args.min_overlap, minimal_area=args.minimal_area, hybrid_area=args.hybrid_area
57+
min_overlap=args.min_overlap,
58+
minimal_area=args.minimal_area,
59+
hybrid_area=args.hybrid_area,
5860
)
5961
n.build_dataset(group).write_file(filename=args.out)
6062

@@ -97,7 +99,7 @@ def divide_network():
9799
window=args.window,
98100
min_overlap=args.min_overlap,
99101
minimal_area=args.minimal_area,
100-
hybrid_area=args.hybrid_area
102+
hybrid_area=args.hybrid_area,
101103
),
102104
)
103105
n.write_file(filename=args.out)

src/py_eddy_tracker/dataset/grid.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,15 @@ def interp(self, grid_name, lons, lats, method="bilinear"):
19801980
self.x_c, self.y_c, g, m, lons, lats, nearest=method == "nearest"
19811981
)
19821982

1983-
def uv_for_advection(self, u_name=None, v_name=None, time_step=600, h_name=None, backward=False, factor=1):
1983+
def uv_for_advection(
1984+
self,
1985+
u_name=None,
1986+
v_name=None,
1987+
time_step=600,
1988+
h_name=None,
1989+
backward=False,
1990+
factor=1,
1991+
):
19841992
"""
19851993
Get U,V to be used in degrees with precomputed time step
19861994
@@ -1990,7 +1998,7 @@ def uv_for_advection(self, u_name=None, v_name=None, time_step=600, h_name=None,
19901998
:param int time_step: Number of second for each advection
19911999
"""
19922000
if h_name is not None:
1993-
u_name, v_name = 'u', 'v'
2001+
u_name, v_name = "u", "v"
19942002
if u_name not in self.vars:
19952003
self.add_uv(h_name)
19962004
self.vars.pop(h_name, None)

src/py_eddy_tracker/observations/groups.py

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,15 @@ def keep_tracks_by_date(self, date, nb_days):
351351
return self.extract_with_mask(mask)
352352

353353
def particle_candidate_atlas(
354-
self, cube, space_step, dt, start_intern=False, end_intern=False, callback_coherence=None, finalize_coherence=None, **kwargs
354+
self,
355+
cube,
356+
space_step,
357+
dt,
358+
start_intern=False,
359+
end_intern=False,
360+
callback_coherence=None,
361+
finalize_coherence=None,
362+
**kwargs
355363
):
356364
"""Select particles within eddies, advect them, return target observation and associated percentages
357365
@@ -383,7 +391,9 @@ def particle_candidate_atlas(
383391
kw_coherence = dict(space_step=space_step, dt=dt, c=cube)
384392
kw_coherence.update(kwargs)
385393
for t in times:
386-
logger.info("Coherence for time step : %s in [%s:%s]", t, times[0], times[-1])
394+
logger.info(
395+
"Coherence for time step : %s in [%s:%s]", t, times[0], times[-1]
396+
)
387397
# Get index for origin
388398
i = t - t_start
389399
indexs0 = i_sort[i_start[i] : i_end[i]]
@@ -393,15 +403,37 @@ def particle_candidate_atlas(
393403
if indexs0.size == 0 or indexs1.size == 0:
394404
continue
395405

396-
results.append(callback_coherence(self, i_target, pct, indexs0, indexs1, start_intern, end_intern, t_start=t, **kw_coherence))
406+
results.append(
407+
callback_coherence(
408+
self,
409+
i_target,
410+
pct,
411+
indexs0,
412+
indexs1,
413+
start_intern,
414+
end_intern,
415+
t_start=t,
416+
**kw_coherence
417+
)
418+
)
397419
indexs[results[-1]] = indexs0, indexs1
398420

399421
if finalize_coherence is not None:
400422
finalize_coherence(results, indexs, i_target, pct)
401423
return i_target, pct
402424

403425
@classmethod
404-
def fill_coherence(cls, network, i_targets, percents, i_origin, i_end, start_intern, end_intern, **kwargs):
426+
def fill_coherence(
427+
cls,
428+
network,
429+
i_targets,
430+
percents,
431+
i_origin,
432+
i_end,
433+
start_intern,
434+
end_intern,
435+
**kwargs
436+
):
405437
"""_summary_
406438
407439
:param array i_targets: global target
@@ -412,21 +444,29 @@ def fill_coherence(cls, network, i_targets, percents, i_origin, i_end, start_int
412444
:param bool end_intern: Use intern or extern contour at end of advection
413445
"""
414446
# Get contour data
415-
contours_start = [network[label][i_origin] for label in cls.intern(start_intern)]
447+
contours_start = [
448+
network[label][i_origin] for label in cls.intern(start_intern)
449+
]
416450
contours_end = [network[label][i_end] for label in cls.intern(end_intern)]
417451
# Compute local coherence
418-
i_local_targets, local_percents = particle_candidate_step(contours_start=contours_start, contours_end=contours_end,**kwargs)
452+
i_local_targets, local_percents = particle_candidate_step(
453+
contours_start=contours_start, contours_end=contours_end, **kwargs
454+
)
419455
# Store
420-
cls.merge_particle_result(i_targets, percents, i_local_targets, local_percents, i_origin, i_end)
421-
456+
cls.merge_particle_result(
457+
i_targets, percents, i_local_targets, local_percents, i_origin, i_end
458+
)
459+
422460
@staticmethod
423-
def merge_particle_result(i_targets, percents, i_local_targets, local_percents, i_origin, i_end):
461+
def merge_particle_result(
462+
i_targets, percents, i_local_targets, local_percents, i_origin, i_end
463+
):
424464
"""Copy local result in merged result with global indexation
425465
426466
:param array i_targets: global target
427-
:param array percents:
467+
:param array percents:
428468
:param array i_local_targets: local index target
429-
:param array local_percents:
469+
:param array local_percents:
430470
:param array i_origin: indices of origins
431471
:param array i_end: indices of ends
432472
"""

0 commit comments

Comments
 (0)