Skip to content

Commit c3f95b8

Browse files
Merge branch 'master' into validation_particle
2 parents 7b4aba6 + bfd6e6a commit c3f95b8

File tree

12 files changed

+27
-102
lines changed

12 files changed

+27
-102
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: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,9 @@ def update(i_frame):
142142

143143
kw_video = dict(frames=arange(nb_time), interval=1000.0 / step_by_day / 2, blit=True)
144144
fig, ax, txt = start_ax(dpi=60)
145-
x_g_, y_g_ = arange(0 - step / 2, 36 + step / 2, step), arange(
146-
28 - step / 2, 46 + step / 2, step
145+
x_g_, y_g_ = (
146+
arange(0 - step / 2, 36 + step / 2, step),
147+
arange(28 - step / 2, 46 + step / 2, step),
147148
)
148149
# pcolorfast will be faster than pcolormesh, we could use pcolorfast due to x and y are regular
149150
pcolormesh = ax.pcolorfast(x_g_, y_g_, lavd, **kw_vorticity)
@@ -158,11 +159,7 @@ def update(i_frame):
158159
# Format LAVD data
159160
lavd = RegularGridDataset.with_array(
160161
coordinates=("lon", "lat"),
161-
datas=dict(
162-
lavd=lavd.T,
163-
lon=x_g,
164-
lat=y_g,
165-
),
162+
datas=dict(lavd=lavd.T, lon=x_g, lat=y_g,),
166163
centered=True,
167164
)
168165

examples/07_cube_manipulation/pet_fsle_med.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# ADT in med
2828
# ----------
2929
# :py:meth:`~py_eddy_tracker.dataset.grid.GridCollection.from_netcdf_cube` method is
30-
# made for data stores in time cube, you could use also
30+
# made for data stores in time cube, you could use also
3131
# :py:meth:`~py_eddy_tracker.dataset.grid.GridCollection.from_netcdf_list` method to
3232
# load data-cube from multiple file.
3333
c = GridCollection.from_netcdf_cube(

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
@@ -407,20 +407,14 @@ def parse_args(self, *args, **kwargs):
407407
nc_name="previous_cost",
408408
nc_type="float32",
409409
nc_dims=("obs",),
410-
nc_attr=dict(
411-
long_name="Previous cost for previous observation",
412-
comment="",
413-
),
410+
nc_attr=dict(long_name="Previous cost for previous observation", comment="",),
414411
),
415412
next_cost=dict(
416413
attr_name=None,
417414
nc_name="next_cost",
418415
nc_type="float32",
419416
nc_dims=("obs",),
420-
nc_attr=dict(
421-
long_name="Next cost for next observation",
422-
comment="",
423-
),
417+
nc_attr=dict(long_name="Next cost for next observation", comment="",),
424418
),
425419
n=dict(
426420
attr_name=None,
@@ -631,8 +625,7 @@ def parse_args(self, *args, **kwargs):
631625
nc_type="f4",
632626
nc_dims=("obs",),
633627
nc_attr=dict(
634-
long_name="Log base 10 background chlorophyll",
635-
units="Log(Chl/[mg/m^3])",
628+
long_name="Log base 10 background chlorophyll", units="Log(Chl/[mg/m^3])",
636629
),
637630
),
638631
year=dict(

src/py_eddy_tracker/appli/eddies.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -367,8 +367,7 @@ def track(
367367

368368
logger.info("Longer track saved have %d obs", c.nb_obs_by_tracks.max())
369369
logger.info(
370-
"The mean length is %d observations for long track",
371-
c.nb_obs_by_tracks.mean(),
370+
"The mean length is %d observations for long track", c.nb_obs_by_tracks.mean(),
372371
)
373372

374373
long_track.write_file(**kw_write)
@@ -378,14 +377,7 @@ def track(
378377

379378

380379
def get_group(
381-
dataset1,
382-
dataset2,
383-
index1,
384-
index2,
385-
score,
386-
invalid=2,
387-
low=10,
388-
high=60,
380+
dataset1, dataset2, index1, index2, score, invalid=2, low=10, high=60,
389381
):
390382
group1, group2 = dict(), dict()
391383
m_valid = (score * 100) >= invalid
@@ -494,8 +486,7 @@ def get_values(v, dataset):
494486
]
495487

496488
labels = dict(
497-
high=f"{high:0.0f} <= high",
498-
low=f"{invalid:0.0f} <= low < {low:0.0f}",
489+
high=f"{high:0.0f} <= high", low=f"{invalid:0.0f} <= low < {low:0.0f}",
499490
)
500491

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

src/py_eddy_tracker/appli/network.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ def subset_network():
7676
help="Remove short dead end, first is for minimal obs number and second for minimal segment time to keep",
7777
)
7878
parser.add_argument(
79-
"--remove_trash",
80-
action="store_true",
81-
help="Remove trash (network id == 0)",
79+
"--remove_trash", action="store_true", help="Remove trash (network id == 0)",
8280
)
8381
parser.add_argument(
8482
"-p",

src/py_eddy_tracker/observations/network.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -677,13 +677,7 @@ def display_timeline(
677677
"""
678678
self.only_one_network()
679679
j = 0
680-
line_kw = dict(
681-
ls="-",
682-
marker="+",
683-
markersize=6,
684-
zorder=1,
685-
lw=3,
686-
)
680+
line_kw = dict(ls="-", marker="+", markersize=6, zorder=1, lw=3,)
687681
line_kw.update(kwargs)
688682
mappables = dict(lines=list())
689683

@@ -916,10 +910,7 @@ def event_map(self, ax, **kwargs):
916910
"""Add the merging and splitting events to a map"""
917911
j = 0
918912
mappables = dict()
919-
symbol_kw = dict(
920-
markersize=10,
921-
color="k",
922-
)
913+
symbol_kw = dict(markersize=10, color="k",)
923914
symbol_kw.update(kwargs)
924915
symbol_kw_split = symbol_kw.copy()
925916
symbol_kw_split["markersize"] += 4
@@ -948,13 +939,7 @@ def event_map(self, ax, **kwargs):
948939
return mappables
949940

950941
def scatter(
951-
self,
952-
ax,
953-
name="time",
954-
factor=1,
955-
ref=None,
956-
edgecolor_cycle=None,
957-
**kwargs,
942+
self, ax, name="time", factor=1, ref=None, edgecolor_cycle=None, **kwargs,
958943
):
959944
"""
960945
This function scatters the path of each network, with the merging and splitting events

src/py_eddy_tracker/observations/observation.py

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -701,11 +701,7 @@ def load_file(cls, filename, **kwargs):
701701
.. code-block:: python
702702
703703
kwargs_latlon_300 = dict(
704-
include_vars=[
705-
"longitude",
706-
"latitude",
707-
],
708-
indexs=dict(obs=slice(0, 300)),
704+
include_vars=["longitude", "latitude",], indexs=dict(obs=slice(0, 300)),
709705
)
710706
small_dataset = TrackEddiesObservations.load_file(
711707
filename, **kwargs_latlon_300
@@ -1677,7 +1673,8 @@ def write_file(
16771673
handler = zarr.open(filename, "w")
16781674
self.to_zarr(handler, **kwargs)
16791675
else:
1680-
with Dataset(filename, "w", format="NETCDF4") as handler:
1676+
nc_format = kwargs.pop("format", "NETCDF4")
1677+
with Dataset(filename, "w", format=nc_format) as handler:
16811678
self.to_netcdf(handler, **kwargs)
16821679

16831680
@property
@@ -1968,11 +1965,7 @@ def bins_stat(self, xname, bins=None, yname=None, method=None, mask=None):
19681965

19691966
def format_label(self, label):
19701967
t0, t1 = self.period
1971-
return label.format(
1972-
t0=t0,
1973-
t1=t1,
1974-
nb_obs=len(self),
1975-
)
1968+
return label.format(t0=t0, t1=t1, nb_obs=len(self),)
19761969

19771970
def display(self, ax, ref=None, extern_only=False, intern_only=False, **kwargs):
19781971
"""Plot the speed and effective (dashed) contour of the eddies
@@ -2331,14 +2324,7 @@ def grid_count_pixel_in(
23312324
x_, y_ = reduce_size(x_, y_)
23322325
v = create_vertice(x_, y_)
23332326
(x_start, x_stop), (y_start, y_stop) = bbox_indice_regular(
2334-
v,
2335-
x_bounds,
2336-
y_bounds,
2337-
xstep,
2338-
ystep,
2339-
N,
2340-
is_circular,
2341-
x_size,
2327+
v, x_bounds, y_bounds, xstep, ystep, N, is_circular, x_size,
23422328
)
23432329
i, j = get_pixel_in_regular(v, x_c, y_c, x_start, x_stop, y_start, y_stop)
23442330
grid_count_(grid, i, j)

0 commit comments

Comments
 (0)