Skip to content

Commit bfd6e6a

Browse files
Merge pull request AntSimi#94 from AntSimi/minor
typo and allow to choose netcdf format at output
2 parents 92c3262 + 6bce49a commit bfd6e6a

File tree

13 files changed

+30
-104
lines changed

13 files changed

+30
-104
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
@@ -409,20 +409,14 @@ def parse_args(self, *args, **kwargs):
409409
nc_name="previous_cost",
410410
nc_type="float32",
411411
nc_dims=("obs",),
412-
nc_attr=dict(
413-
long_name="Previous cost for previous observation",
414-
comment="",
415-
),
412+
nc_attr=dict(long_name="Previous cost for previous observation", comment="",),
416413
),
417414
next_cost=dict(
418415
attr_name=None,
419416
nc_name="next_cost",
420417
nc_type="float32",
421418
nc_dims=("obs",),
422-
nc_attr=dict(
423-
long_name="Next cost for next observation",
424-
comment="",
425-
),
419+
nc_attr=dict(long_name="Next cost for next observation", comment="",),
426420
),
427421
n=dict(
428422
attr_name=None,
@@ -633,8 +627,7 @@ def parse_args(self, *args, **kwargs):
633627
nc_type="f4",
634628
nc_dims=("obs",),
635629
nc_attr=dict(
636-
long_name="Log base 10 background chlorophyll",
637-
units="Log(Chl/[mg/m^3])",
630+
long_name="Log base 10 background chlorophyll", units="Log(Chl/[mg/m^3])",
638631
),
639632
),
640633
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/groups.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ def particle_candidate(x, y, c, eddies, t_start, i_target, pct, **kwargs):
100100
:params dict kwargs: dict of params given to `advect`
101101
102102
"""
103-
104103
# Obs from initial time
105104
m_start = eddies.time == t_start
106105

src/py_eddy_tracker/observations/network.py

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -679,13 +679,7 @@ def display_timeline(
679679
"""
680680
self.only_one_network()
681681
j = 0
682-
line_kw = dict(
683-
ls="-",
684-
marker="+",
685-
markersize=6,
686-
zorder=1,
687-
lw=3,
688-
)
682+
line_kw = dict(ls="-", marker="+", markersize=6, zorder=1, lw=3,)
689683
line_kw.update(kwargs)
690684
mappables = dict(lines=list())
691685

@@ -918,10 +912,7 @@ def event_map(self, ax, **kwargs):
918912
"""Add the merging and splitting events to a map"""
919913
j = 0
920914
mappables = dict()
921-
symbol_kw = dict(
922-
markersize=10,
923-
color="k",
924-
)
915+
symbol_kw = dict(markersize=10, color="k",)
925916
symbol_kw.update(kwargs)
926917
symbol_kw_split = symbol_kw.copy()
927918
symbol_kw_split["markersize"] += 4
@@ -950,13 +941,7 @@ def event_map(self, ax, **kwargs):
950941
return mappables
951942

952943
def scatter(
953-
self,
954-
ax,
955-
name="time",
956-
factor=1,
957-
ref=None,
958-
edgecolor_cycle=None,
959-
**kwargs,
944+
self, ax, name="time", factor=1, ref=None, edgecolor_cycle=None, **kwargs,
960945
):
961946
"""
962947
This function scatters the path of each network, with the merging and splitting events
@@ -1400,7 +1385,9 @@ def segment_coherence(
14001385
.. code-block:: python
14011386
14021387
def date2file(julian_day):
1403-
date = datetime.timedelta(days=julian_day) + datetime.datetime(1950, 1, 1)
1388+
date = datetime.timedelta(days=julian_day) + datetime.datetime(
1389+
1950, 1, 1
1390+
)
14041391
14051392
return f"/tmp/dt_global_allsat_phy_l4_{date.strftime('%Y%m%d')}.nc"
14061393

0 commit comments

Comments
 (0)