Skip to content

Commit aba7c3d

Browse files
black reformating
1 parent f4a6fee commit aba7c3d

File tree

12 files changed

+72
-96
lines changed

12 files changed

+72
-96
lines changed

examples/02_eddy_identification/pet_eddy_detection_ACC.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ 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),
69-
longitude=slice(0, 230 + margin),
68+
latitude=slice(100 - margin, 220 + margin), longitude=slice(0, 230 + margin),
7069
),
7170
)
7271
g_raw = RegularGridDataset(**kw_data)
@@ -188,16 +187,10 @@ def set_fancy_labels(fig, ticklabelsize=14, labelsize=14, labelweight="semibold"
188187
ax.set_ylabel("With filter")
189188

190189
ax.plot(
191-
a_[field][i_a] * factor,
192-
a[field][j_a] * factor,
193-
"r.",
194-
label="Anticyclonic",
190+
a_[field][i_a] * factor, a[field][j_a] * factor, "r.", label="Anticyclonic",
195191
)
196192
ax.plot(
197-
c_[field][i_c] * factor,
198-
c[field][j_c] * factor,
199-
"b.",
200-
label="Cyclonic",
193+
c_[field][i_c] * factor, c[field][j_c] * factor, "b.", label="Cyclonic",
201194
)
202195
ax.set_aspect("equal"), ax.grid()
203196
ax.plot((0, 1000), (0, 1000), "g")

examples/06_grid_manipulation/pet_lavd.py

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

examples/16_network/pet_replay_segmentation.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,7 @@ 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,
153-
"shape_error_e",
154-
vmin=14,
155-
vmax=70,
156-
**kw,
157-
yfield="lon",
158-
method="all",
152+
ax, "shape_error_e", vmin=14, vmax=70, **kw, yfield="lon", method="all",
159153
)
160154
ax.set_ylabel("Longitude")
161155
cb = update_axes(ax, m["scatter"])

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,)

src/py_eddy_tracker/__init__.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -422,20 +422,14 @@ def identify_time(str_date):
422422
nc_name="previous_cost",
423423
nc_type="float32",
424424
nc_dims=("obs",),
425-
nc_attr=dict(
426-
long_name="Previous cost for previous observation",
427-
comment="",
428-
),
425+
nc_attr=dict(long_name="Previous cost for previous observation", comment="",),
429426
),
430427
next_cost=dict(
431428
attr_name=None,
432429
nc_name="next_cost",
433430
nc_type="float32",
434431
nc_dims=("obs",),
435-
nc_attr=dict(
436-
long_name="Next cost for next observation",
437-
comment="",
438-
),
432+
nc_attr=dict(long_name="Next cost for next observation", comment="",),
439433
),
440434
n=dict(
441435
attr_name=None,
@@ -646,8 +640,7 @@ def identify_time(str_date):
646640
nc_type="f4",
647641
nc_dims=("obs",),
648642
nc_attr=dict(
649-
long_name="Log base 10 background chlorophyll",
650-
units="Log(Chl/[mg/m^3])",
643+
long_name="Log base 10 background chlorophyll", units="Log(Chl/[mg/m^3])",
651644
),
652645
),
653646
year=dict(

src/py_eddy_tracker/appli/eddies.py

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

245245
dataset_list = empty(
246-
len(filenames),
247-
dtype=[("filename", "S500"), ("date", "datetime64[s]")],
246+
len(filenames), dtype=[("filename", "S500"), ("date", "datetime64[s]")],
248247
)
249248
dataset_list["filename"] = filenames
250249

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

373372
logger.info("Longer track saved have %d obs", c.nb_obs_by_tracks.max())
374373
logger.info(
375-
"The mean length is %d observations for long track",
376-
c.nb_obs_by_tracks.mean(),
374+
"The mean length is %d observations for long track", c.nb_obs_by_tracks.mean(),
377375
)
378376

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

384382

385383
def get_group(
386-
dataset1,
387-
dataset2,
388-
index1,
389-
index2,
390-
score,
391-
invalid=2,
392-
low=10,
393-
high=60,
384+
dataset1, dataset2, index1, index2, score, invalid=2, low=10, high=60,
394385
):
395386
group1, group2 = dict(), dict()
396387
m_valid = (score * 100) >= invalid
@@ -499,8 +490,7 @@ def get_values(v, dataset):
499490
]
500491

501492
labels = dict(
502-
high=f"{high:0.0f} <= high",
503-
low=f"{invalid:0.0f} <= low < {low:0.0f}",
493+
high=f"{high:0.0f} <= high", low=f"{invalid:0.0f} <= low < {low:0.0f}",
504494
)
505495

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

src/py_eddy_tracker/appli/network.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,16 @@ def build_network():
2323
)
2424

2525
parser.add_argument(
26-
"--min-overlap", "-p", type=float, help="minimum overlap area to associate observations", default=0.2
26+
"--min-overlap",
27+
"-p",
28+
type=float,
29+
help="minimum overlap area to associate observations",
30+
default=0.2,
2731
)
2832
parser.add_argument(
2933
"--minimal-area",
30-
action="store_true",
31-
help="If True, use intersection/little polygon, else intersection/union",
34+
action="store_true",
35+
help="If True, use intersection/little polygon, else intersection/union",
3236
)
3337

3438
parser.contour_intern_arg()
@@ -42,7 +46,9 @@ def build_network():
4246
intern=args.intern,
4347
memory=args.memory,
4448
)
45-
group = n.group_observations(min_overlap=args.min_overlap, minimal_area=args.minimal_area)
49+
group = n.group_observations(
50+
min_overlap=args.min_overlap, minimal_area=args.minimal_area
51+
)
4652
n.build_dataset(group).write_file(filename=args.out)
4753

4854

@@ -55,12 +61,16 @@ def divide_network():
5561
"--window", "-w", type=int, help="Half time window to search eddy", default=1
5662
)
5763
parser.add_argument(
58-
"--min-overlap", "-p", type=float, help="minimum overlap area to associate observations", default=0.2
64+
"--min-overlap",
65+
"-p",
66+
type=float,
67+
help="minimum overlap area to associate observations",
68+
default=0.2,
5969
)
6070
parser.add_argument(
6171
"--minimal-area",
62-
action="store_true",
63-
help="If True, use intersection/little polygon, else intersection/union",
72+
action="store_true",
73+
help="If True, use intersection/little polygon, else intersection/union",
6474
)
6575
args = parser.parse_args()
6676
contour_name = TrackEddiesObservations.intern(args.intern, public_label=True)
@@ -70,7 +80,12 @@ def divide_network():
7080
)
7181
n = NetworkObservations.from_split_network(
7282
TrackEddiesObservations.load_file(args.input, raw_data=True),
73-
e.split_network(intern=args.intern, window=args.window, min_overlap=args.min_overlap, minimal_area=args.minimal_area),
83+
e.split_network(
84+
intern=args.intern,
85+
window=args.window,
86+
min_overlap=args.min_overlap,
87+
minimal_area=args.minimal_area,
88+
),
7489
)
7590
n.write_file(filename=args.out)
7691

@@ -94,9 +109,7 @@ def subset_network():
94109
help="Remove short dead end, first is for minimal obs number and second for minimal segment time to keep",
95110
)
96111
parser.add_argument(
97-
"--remove_trash",
98-
action="store_true",
99-
help="Remove trash (network id == 0)",
112+
"--remove_trash", action="store_true", help="Remove trash (network id == 0)",
100113
)
101114
parser.add_argument(
102115
"-p",

src/py_eddy_tracker/dataset/grid.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -858,13 +858,11 @@ def eddy_identification(
858858
xy_i = uniform_resample(
859859
inner_contour.lon,
860860
inner_contour.lat,
861-
num_fac=presampling_multiplier
862-
)
863-
xy_e = uniform_resample(
864-
contour.lon,
865-
contour.lat,
866861
num_fac=presampling_multiplier,
867862
)
863+
xy_e = uniform_resample(
864+
contour.lon, contour.lat, num_fac=presampling_multiplier,
865+
)
868866
xy_s = uniform_resample(
869867
speed_contour.lon,
870868
speed_contour.lat,

src/py_eddy_tracker/eddy_feature.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,8 @@ def __init__(self, x, y, z, levels, wrap_x=False, keep_unclose=False):
433433
closed_contours = 0
434434
# Count level and contour
435435
for i, collection in enumerate(self.contours.collections):
436-
collection.get_nearest_path_bbox_contain_pt = (
437-
lambda x, y, i=i: self.get_index_nearest_path_bbox_contain_pt(i, x, y)
436+
collection.get_nearest_path_bbox_contain_pt = lambda x, y, i=i: self.get_index_nearest_path_bbox_contain_pt(
437+
i, x, y
438438
)
439439
nb_level += 1
440440

src/py_eddy_tracker/observations/network.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,10 @@ def extract_light_with_mask(self, mask, track_extra_variables=[]):
13371337
logger.debug("Copy of field %s ...", field)
13381338
new.obs[field] = self.obs[field][mask]
13391339

1340-
if "previous_obs" in track_extra_variables and "next_obs" in track_extra_variables:
1340+
if (
1341+
"previous_obs" in track_extra_variables
1342+
and "next_obs" in track_extra_variables
1343+
):
13411344
# n & p must be re-index
13421345
n, p = self.next_obs[mask], self.previous_obs[mask]
13431346
# we add 2 for -1 index return index -1
@@ -1741,7 +1744,12 @@ def group_observations(self, min_overlap=0.2, minimal_area=False):
17411744
for j in range(i + 1, min(self.window + i + 1, self.nb_input)):
17421745
xj, yj = self.buffer.load_contour(self.filenames[j])
17431746
ii, ij = bbox_intersection(xi, yi, xj, yj)
1744-
m = vertice_overlap(xi[ii], yi[ii], xj[ij], yj[ij], minimal_area=minimal_area) > min_overlap
1747+
m = (
1748+
vertice_overlap(
1749+
xi[ii], yi[ii], xj[ij], yj[ij], minimal_area=minimal_area
1750+
)
1751+
> min_overlap
1752+
)
17451753
results.append((i, j, ii[m], ij[m]))
17461754
if display_iteration:
17471755
print()

0 commit comments

Comments
 (0)