Skip to content

Commit 3acf1ab

Browse files
committed
isort/black
1 parent 1e6d4f4 commit 3acf1ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+336
-249
lines changed

check.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
isort src tests examples
2-
black src tests examples
3-
blackdoc src tests examples
4-
flake8 tests examples src --count --select=E9,F63,F7,F82 --show-source --statistics
5-
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
6-
flake8 tests examples src --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
1+
isort .
2+
black .
3+
blackdoc .
4+
flake8 .
75
python -m pytest -vv --cov py_eddy_tracker --cov-report html

doc/grid_identification.rst

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -47,38 +47,42 @@ Activate verbose
4747
.. code-block:: python
4848
4949
from py_eddy_tracker import start_logger
50-
start_logger().setLevel('DEBUG') # Available options: ERROR, WARNING, INFO, DEBUG
50+
51+
start_logger().setLevel("DEBUG") # Available options: ERROR, WARNING, INFO, DEBUG
5152
5253
Run identification
5354

5455
.. code-block:: python
5556
5657
from datetime import datetime
58+
5759
h = RegularGridDataset(grid_name, lon_name, lat_name)
58-
h.bessel_high_filter('adt', 500, order=3)
60+
h.bessel_high_filter("adt", 500, order=3)
5961
date = datetime(2019, 2, 23)
6062
a, c = h.eddy_identification(
61-
'adt', 'ugos', 'vgos', # Variables used for identification
62-
date, # Date of identification
63-
0.002, # step between two isolines of detection (m)
64-
pixel_limit=(5, 2000), # Min and max pixel count for valid contour
65-
shape_error=55, # Error max (%) between ratio of circle fit and contour
66-
)
63+
"adt",
64+
"ugos",
65+
"vgos", # Variables used for identification
66+
date, # Date of identification
67+
0.002, # step between two isolines of detection (m)
68+
pixel_limit=(5, 2000), # Min and max pixel count for valid contour
69+
shape_error=55, # Error max (%) between ratio of circle fit and contour
70+
)
6771
6872
Plot the resulting identification
6973

7074
.. code-block:: python
7175
72-
fig = plt.figure(figsize=(15,7))
73-
ax = fig.add_axes([.03,.03,.94,.94])
74-
ax.set_title('Eddies detected -- Cyclonic(red) and Anticyclonic(blue)')
75-
ax.set_ylim(-75,75)
76-
ax.set_xlim(0,360)
77-
ax.set_aspect('equal')
78-
a.display(ax, color='b', linewidth=.5)
79-
c.display(ax, color='r', linewidth=.5)
76+
fig = plt.figure(figsize=(15, 7))
77+
ax = fig.add_axes([0.03, 0.03, 0.94, 0.94])
78+
ax.set_title("Eddies detected -- Cyclonic(red) and Anticyclonic(blue)")
79+
ax.set_ylim(-75, 75)
80+
ax.set_xlim(0, 360)
81+
ax.set_aspect("equal")
82+
a.display(ax, color="b", linewidth=0.5)
83+
c.display(ax, color="r", linewidth=0.5)
8084
ax.grid()
81-
fig.savefig('share/png/eddies.png')
85+
fig.savefig("share/png/eddies.png")
8286
8387
.. image:: ../share/png/eddies.png
8488

@@ -87,7 +91,8 @@ Save identification data
8791
.. code-block:: python
8892
8993
from netCDF import Dataset
90-
with Dataset(date.strftime('share/Anticyclonic_%Y%m%d.nc'), 'w') as h:
94+
95+
with Dataset(date.strftime("share/Anticyclonic_%Y%m%d.nc"), "w") as h:
9196
a.to_netcdf(h)
92-
with Dataset(date.strftime('share/Cyclonic_%Y%m%d.nc'), 'w') as h:
97+
with Dataset(date.strftime("share/Cyclonic_%Y%m%d.nc"), "w") as h:
9398
c.to_netcdf(h)

doc/grid_load_display.rst

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,56 @@ Loading grid
77
.. code-block:: python
88
99
from py_eddy_tracker.dataset.grid import RegularGridDataset
10-
grid_name, lon_name, lat_name = 'share/nrt_global_allsat_phy_l4_20190223_20190226.nc', 'longitude', 'latitude'
10+
11+
grid_name, lon_name, lat_name = (
12+
"share/nrt_global_allsat_phy_l4_20190223_20190226.nc",
13+
"longitude",
14+
"latitude",
15+
)
1116
h = RegularGridDataset(grid_name, lon_name, lat_name)
1217
1318
Plotting grid
1419

1520
.. code-block:: python
1621
1722
from matplotlib import pyplot as plt
23+
1824
fig = plt.figure(figsize=(14, 12))
19-
ax = fig.add_axes([.02, .51, .9, .45])
20-
ax.set_title('ADT (m)')
25+
ax = fig.add_axes([0.02, 0.51, 0.9, 0.45])
26+
ax.set_title("ADT (m)")
2127
ax.set_ylim(-75, 75)
22-
ax.set_aspect('equal')
23-
m = h.display(ax, name='adt', vmin=-1, vmax=1)
28+
ax.set_aspect("equal")
29+
m = h.display(ax, name="adt", vmin=-1, vmax=1)
2430
ax.grid(True)
25-
plt.colorbar(m, cax=fig.add_axes([.94, .51, .01, .45]))
31+
plt.colorbar(m, cax=fig.add_axes([0.94, 0.51, 0.01, 0.45]))
2632
2733
2834
Filtering
2935

3036
.. code-block:: python
3137
3238
h = RegularGridDataset(grid_name, lon_name, lat_name)
33-
h.bessel_high_filter('adt', 500, order=3)
39+
h.bessel_high_filter("adt", 500, order=3)
3440
3541
3642
Save grid
3743

3844
.. code-block:: python
3945
40-
h.write('/tmp/grid.nc')
46+
h.write("/tmp/grid.nc")
4147
4248
4349
Add second plot
4450

4551
.. code-block:: python
4652
47-
ax = fig.add_axes([.02, .02, .9, .45])
48-
ax.set_title('ADT Filtered (m)')
49-
ax.set_aspect('equal')
53+
ax = fig.add_axes([0.02, 0.02, 0.9, 0.45])
54+
ax.set_title("ADT Filtered (m)")
55+
ax.set_aspect("equal")
5056
ax.set_ylim(-75, 75)
51-
m = h.display(ax, name='adt', vmin=-.1, vmax=.1)
57+
m = h.display(ax, name="adt", vmin=-0.1, vmax=0.1)
5258
ax.grid(True)
53-
plt.colorbar(m, cax=fig.add_axes([.94, .02, .01, .45]))
54-
fig.savefig('share/png/filter.png')
59+
plt.colorbar(m, cax=fig.add_axes([0.94, 0.02, 0.01, 0.45]))
60+
fig.savefig("share/png/filter.png")
5561
5662
.. image:: ../share/png/filter.png

doc/spectrum.rst

Lines changed: 38 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Load data
1111
1212
raw = RegularGridDataset(grid_name, lon_name, lat_name)
1313
filtered = RegularGridDataset(grid_name, lon_name, lat_name)
14-
filtered.bessel_low_filter('adt', 150, order=3)
14+
filtered.bessel_low_filter("adt", 150, order=3)
1515
1616
areas = dict(
1717
sud_pacific=dict(llcrnrlon=188, urcrnrlon=280, llcrnrlat=-64, urcrnrlat=-7),
@@ -23,24 +23,34 @@ Compute and display spectrum
2323

2424
.. code-block:: python
2525
26-
fig = plt.figure(figsize=(10,6))
26+
fig = plt.figure(figsize=(10, 6))
2727
ax = fig.add_subplot(111)
28-
ax.set_title('Spectrum')
29-
ax.set_xlabel('km')
28+
ax.set_title("Spectrum")
29+
ax.set_xlabel("km")
3030
for name_area, area in areas.items():
3131
32-
lon_spec, lat_spec = raw.spectrum_lonlat('adt', area=area)
33-
mappable = ax.loglog(*lat_spec, label='lat %s raw' % name_area)[0]
34-
ax.loglog(*lon_spec, label='lon %s raw' % name_area, color=mappable.get_color(), linestyle='--')
35-
36-
lon_spec, lat_spec = filtered.spectrum_lonlat('adt', area=area)
37-
mappable = ax.loglog(*lat_spec, label='lat %s high' % name_area)[0]
38-
ax.loglog(*lon_spec, label='lon %s high' % name_area, color=mappable.get_color(), linestyle='--')
39-
40-
ax.set_xscale('log')
32+
lon_spec, lat_spec = raw.spectrum_lonlat("adt", area=area)
33+
mappable = ax.loglog(*lat_spec, label="lat %s raw" % name_area)[0]
34+
ax.loglog(
35+
*lon_spec,
36+
label="lon %s raw" % name_area,
37+
color=mappable.get_color(),
38+
linestyle="--"
39+
)
40+
41+
lon_spec, lat_spec = filtered.spectrum_lonlat("adt", area=area)
42+
mappable = ax.loglog(*lat_spec, label="lat %s high" % name_area)[0]
43+
ax.loglog(
44+
*lon_spec,
45+
label="lon %s high" % name_area,
46+
color=mappable.get_color(),
47+
linestyle="--"
48+
)
49+
50+
ax.set_xscale("log")
4151
ax.legend()
4252
ax.grid()
43-
fig.savefig('share/png/spectrum.png')
53+
fig.savefig("share/png/spectrum.png")
4454
4555
4656
.. image:: ../share/png/spectrum.png
@@ -49,18 +59,23 @@ Compute and display spectrum ratio
4959

5060
.. code-block:: python
5161
52-
fig = plt.figure(figsize=(10,6))
62+
fig = plt.figure(figsize=(10, 6))
5363
ax = fig.add_subplot(111)
54-
ax.set_title('Spectrum ratio')
55-
ax.set_xlabel('km')
64+
ax.set_title("Spectrum ratio")
65+
ax.set_xlabel("km")
5666
for name_area, area in areas.items():
57-
lon_spec, lat_spec = filtered.spectrum_lonlat('adt', area=area, ref=raw)
58-
mappable = ax.plot(*lat_spec, label='lat %s high' % name_area)[0]
59-
ax.plot(*lon_spec, label='lon %s high' % name_area, color=mappable.get_color(), linestyle='--')
60-
61-
ax.set_xscale('log')
67+
lon_spec, lat_spec = filtered.spectrum_lonlat("adt", area=area, ref=raw)
68+
mappable = ax.plot(*lat_spec, label="lat %s high" % name_area)[0]
69+
ax.plot(
70+
*lon_spec,
71+
label="lon %s high" % name_area,
72+
color=mappable.get_color(),
73+
linestyle="--"
74+
)
75+
76+
ax.set_xscale("log")
6277
ax.legend()
6378
ax.grid()
64-
fig.savefig('share/png/spectrum_ratio.png')
79+
fig.savefig("share/png/spectrum_ratio.png")
6580
6681
.. image:: ../share/png/spectrum_ratio.png

examples/01_general_things/pet_storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
manage eddies associated in networks, the ```track``` and ```segment``` fields allow to separate observations
1616
"""
1717

18-
import py_eddy_tracker_sample
1918
from matplotlib import pyplot as plt
2019
from numpy import arange, outer
20+
import py_eddy_tracker_sample
2121

2222
from py_eddy_tracker.data import get_demo_path
2323
from py_eddy_tracker.observations.network import NetworkObservations

examples/02_eddy_identification/pet_eddy_detection_ACC.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"""
1010
from datetime import datetime
1111

12-
from matplotlib import pyplot as plt
13-
from matplotlib import style
12+
from matplotlib import pyplot as plt, style
1413

1514
from py_eddy_tracker import data
1615
from py_eddy_tracker.dataset.grid import RegularGridDataset
@@ -65,7 +64,8 @@ def set_fancy_labels(fig, ticklabelsize=14, labelsize=14, labelweight="semibold"
6564
y_name="latitude",
6665
# Manual area subset
6766
indexs=dict(
68-
latitude=slice(100 - margin, 220 + margin), longitude=slice(0, 230 + margin),
67+
latitude=slice(100 - margin, 220 + margin),
68+
longitude=slice(0, 230 + margin),
6969
),
7070
)
7171
g_raw = RegularGridDataset(**kw_data)
@@ -187,10 +187,16 @@ def set_fancy_labels(fig, ticklabelsize=14, labelsize=14, labelweight="semibold"
187187
ax.set_ylabel("With filter")
188188

189189
ax.plot(
190-
a_[field][i_a] * factor, a[field][j_a] * factor, "r.", label="Anticyclonic",
190+
a_[field][i_a] * factor,
191+
a[field][j_a] * factor,
192+
"r.",
193+
label="Anticyclonic",
191194
)
192195
ax.plot(
193-
c_[field][i_c] * factor, c[field][j_c] * factor, "b.", label="Cyclonic",
196+
c_[field][i_c] * factor,
197+
c[field][j_c] * factor,
198+
"b.",
199+
label="Cyclonic",
194200
)
195201
ax.set_aspect("equal"), ax.grid()
196202
ax.plot((0, 1000), (0, 1000), "g")

examples/02_eddy_identification/pet_interp_grid_on_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def update_axes(ax, mappable=None):
4343
# %%
4444
# Compute and store eke in cm²/s²
4545
aviso_map.add_grid(
46-
"eke", (aviso_map.grid("u") ** 2 + aviso_map.grid("v") ** 2) * 0.5 * (100 ** 2)
46+
"eke", (aviso_map.grid("u") ** 2 + aviso_map.grid("v") ** 2) * 0.5 * (100**2)
4747
)
4848

4949
eke_kwargs = dict(vmin=1, vmax=1000, cmap="magma_r")

examples/02_eddy_identification/pet_statistics_on_identification.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
55
Some statistics on raw identification without any tracking
66
"""
7-
import numpy as np
87
from matplotlib import pyplot as plt
98
from matplotlib.dates import date2num
9+
import numpy as np
1010

1111
from py_eddy_tracker import start_logger
1212
from py_eddy_tracker.data import get_remote_demo_sample

examples/06_grid_manipulation/pet_lavd.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ def update(i_frame):
158158
# %%
159159
# Format LAVD data
160160
lavd = RegularGridDataset.with_array(
161-
coordinates=("lon", "lat"),
162-
datas=dict(lavd=lavd.T, lon=x_g, lat=y_g,),
163-
centered=True,
161+
coordinates=("lon", "lat"), datas=dict(lavd=lavd.T, lon=x_g, lat=y_g), centered=True
164162
)
165163

166164
# %%

examples/07_cube_manipulation/pet_cube.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
55
Example which use CMEMS surface current with a Runge-Kutta 4 algorithm to advect particles.
66
"""
7+
from datetime import datetime, timedelta
8+
79
# sphinx_gallery_thumbnail_number = 2
810
import re
9-
from datetime import datetime, timedelta
1011

1112
from matplotlib import pyplot as plt
1213
from matplotlib.animation import FuncAnimation

0 commit comments

Comments
 (0)