Skip to content

Commit 5a83790

Browse files
committed
Add pargraph in example and use jupyterlab instead jupyter
1 parent eb23902 commit 5a83790

34 files changed

+943
-87
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Documentation Status](https://readthedocs.org/projects/py-eddy-tracker/badge/?version=latest)](https://py-eddy-tracker.readthedocs.io/en/latest/?badge=latest)
1+
[![Documentation Status](https://readthedocs.org/projects/py-eddy-tracker/badge/?version=latest)](https://py-eddy-tracker.readthedocs.io/en/latest/?badge=latest) [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/AntSimi/py-eddy-tracker/master?urlpath=lab/tree/notebooks/python_module/)
22

33
# README #
44

doc/conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@
5050
'binderhub_url': 'https://mybinder.org',
5151
'dependencies': ['../requirements.txt'],
5252
# Optional keys
53-
# 'filepath_prefix': '<prefix>' # A prefix to prepend to any filepaths in Binder links.
54-
# 'notebooks_dir': '<notebooks-directory-name>' # Jupyter notebooks for Binder will be copied to this directory (relative to built documentation root).
55-
# 'use_jupyter_lab': <bool> # Whether Binder links should start Jupyter Lab instead of the Jupyter Notebook interface.
53+
'use_jupyter_lab': True
5654
}
5755
}
5856

doc/index.rst

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,13 @@ Welcome to py-eddy-tracker's documentation!
2727
grid_load_display
2828
spectrum
2929

30-
3130
.. toctree::
3231
:maxdepth: 2
3332
:caption: Tracking
3433

3534
run_tracking
3635
custom_tracking
3736

38-
.. toctree::
39-
:maxdepth: 2
40-
:caption: Work with eddies
41-
42-
observation_manipulation
43-
4437
.. toctree::
4538
:maxdepth: 2
4639
:caption: code

doc/observation_manipulation.rst

Lines changed: 0 additions & 12 deletions
This file was deleted.

examples/02_eddy_identification/pet_display_id.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
from py_eddy_tracker.observations.observation import EddiesObservations
99
from py_eddy_tracker import data
1010

11+
# %%
12+
# Load detection files
1113
a = EddiesObservations.load_file(data.get_path("Anticyclonic_20190223.nc"))
1214
c = EddiesObservations.load_file(data.get_path("Cyclonic_20190223.nc"))
1315

16+
# %%
1417
# Plot
1518
fig = plt.figure(figsize=(15, 8))
1619
ax = fig.add_subplot(111)

examples/02_eddy_identification/pet_eddy_detection.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from py_eddy_tracker.dataset.grid import RegularGridDataset
1313
from py_eddy_tracker import data
1414

15-
15+
# %%
1616
def start_axes(title):
1717
fig = plt.figure(figsize=(13, 5))
1818
ax = fig.add_axes([0.03, 0.03, 0.90, 0.94])
@@ -28,6 +28,8 @@ def update_axes(ax, mappable=None):
2828
plt.colorbar(m, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9]))
2929

3030

31+
# %%
32+
# Load Input grid, ADT will be used to detect eddies
3133
g = RegularGridDataset(
3234
data.get_path("dt_med_allsat_phy_l4_20160515_20190101.nc"), "longitude", "latitude"
3335
)
@@ -36,6 +38,8 @@ def update_axes(ax, mappable=None):
3638
m = g.display(ax, "adt", vmin=-0.15, vmax=0.15)
3739
update_axes(ax, m)
3840

41+
# %%
42+
# U/V are deduced from ADT, this algortihm are not usable around equator (~+- 2°)
3943
g.add_uv("adt")
4044
ax = start_axes("U/V deduce from ADT (m)")
4145
ax.set_xlim(2.5, 9), ax.set_ylim(37.5, 40)
@@ -44,27 +48,38 @@ def update_axes(ax, mappable=None):
4448
ax.quiver(g.x_c, g.y_c, u, v, scale=10)
4549
update_axes(ax, m)
4650

51+
# %%
52+
# Apply high filter to remove long scale to highlight mesoscale
4753
g.bessel_high_filter("adt", 500, order=2)
48-
4954
ax = start_axes("ADT (m) filtered (500km, order 2)")
5055
m = g.display(ax, "adt", vmin=-0.15, vmax=0.15)
5156
update_axes(ax, m)
5257

58+
# %%
59+
#  Run identification with slice of 2 mm
5360
date = datetime(2016, 5, 15)
5461
a, c = g.eddy_identification("adt", "u", "v", date, 0.002)
5562

63+
# %%
64+
# All closed contour found in this input grid (Display only 1 contour every 4)
5665
ax = start_axes("ADT closed contour (only 1 / 4 levels)")
5766
g.contours.display(ax, step=4)
5867
update_axes(ax)
5968

69+
# %%
70+
# Contours include in eddies
6071
ax = start_axes("ADT contour used as eddies")
6172
g.contours.display(ax, only_used=True)
6273
update_axes(ax)
6374

75+
# %%
76+
# Contours reject from several origin (shape error to high, several extremum in contour, ...)
6477
ax = start_axes("ADT contour reject")
6578
g.contours.display(ax, only_unused=True)
6679
update_axes(ax)
6780

81+
# %%
82+
# Contours closed which contains several eddies
6883
ax = start_axes("ADT contour reject but which contain eddies")
6984
g.contours.label_contour_unused_which_contain_eddies(a)
7085
g.contours.label_contour_unused_which_contain_eddies(c)
@@ -76,12 +91,16 @@ def update_axes(ax, mappable=None):
7691
ax.legend()
7792
update_axes(ax)
7893

94+
# %%
95+
# Display detected eddies
7996
ax = start_axes("Eddies detected")
8097
a.display(ax, color="r", linewidth=0.5, label="Anticyclonic", ref=-10)
8198
c.display(ax, color="b", linewidth=0.5, label="Cyclonic", ref=-10)
8299
ax.legend()
83100
update_axes(ax)
84101

102+
# %%
103+
# Display speed radius of eddies detected
85104
ax = start_axes("Eddies speed radius (km)")
86105
a.scatter(ax, "radius_s", vmin=10, vmax=50, s=80, ref=-10, cmap="jet", factor=0.001)
87106
m = c.scatter(ax, "radius_s", vmin=10, vmax=50, s=80, ref=-10, cmap="jet", factor=0.001)

examples/06_grid_manipulation/pet_hide_pixel_out_eddies.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,26 @@
1111
from py_eddy_tracker.dataset.grid import RegularGridDataset
1212
from py_eddy_tracker import data
1313

14+
# %%
15+
# Load an eddy file which contains contours
1416
a = EddiesObservations.load_file(data.get_path("Anticyclonic_20190223.nc"))
17+
18+
# %%
19+
# Load a grid where we want found pixels in eddies or out
1520
g = RegularGridDataset(
1621
data.get_path("nrt_global_allsat_phy_l4_20190223_20190226.nc"),
1722
"longitude",
1823
"latitude",
1924
)
2025

21-
# Plot
26+
# %%
27+
# For each contours, we will get pixels indice in contour.
2228
fig = plt.figure(figsize=(12, 6))
2329
ax = fig.add_axes((0.05, 0.05, 0.9, 0.9))
2430
ax.set_aspect("equal")
2531
ax.set_xlim(10, 70)
2632
ax.set_ylim(-50, -25)
33+
# We will used the outter contour
2734
x_name, y_name = a.intern(False)
2835
adt = g.grid("adt")
2936
mask = ones(adt.shape, dtype='bool')
@@ -33,7 +40,7 @@
3340
adt.mask[:] += ~mask
3441
g.display(ax, "adt")
3542
a.display(ax, label="Anticyclonic", color="g", lw=1, extern_only=True)
36-
43+
# %%
3744
fig = plt.figure(figsize=(12, 6))
3845
ax = fig.add_axes((0.05, 0.05, 0.9, 0.9))
3946
ax.set_aspect("equal")

examples/08_tracking_manipulation/pet_display_field.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
from py_eddy_tracker.observations.tracking import TrackEddiesObservations
99
import py_eddy_tracker_sample
1010

11+
# %%
12+
# Load an experimental cyclonic atlas, we keep only eddies which are follow more than 180 days
1113
c = TrackEddiesObservations.load_file(
1214
py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Cyclonic.zarr")
1315
)
14-
1516
c = c.extract_with_length((180, -1))
1617

17-
# Plot
18+
# %%
19+
# Plot amplitude field
1820
fig = plt.figure(figsize=(12, 6))
1921
ax = fig.add_axes((0.05, 0.1, 0.9, 0.9))
2022
ax.set_aspect("equal")

examples/08_tracking_manipulation/pet_display_track.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,23 @@
88
from py_eddy_tracker.observations.tracking import TrackEddiesObservations
99
import py_eddy_tracker_sample
1010

11+
# %%
12+
# Load experimental atlas, and keep only eddies longer than 20 weeks
1113
a = TrackEddiesObservations.load_file(
1214
py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Anticyclonic.zarr")
1315
)
1416
c = TrackEddiesObservations.load_file(
1517
py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Cyclonic.zarr")
1618
)
17-
1819
a = a.extract_with_length((7 * 20, -1))
1920
c = c.extract_with_length((7 * 20, -1))
21+
22+
# %%
23+
# Position filtering for nice display
2024
a.position_filter(median_half_window=1, loess_half_window=5)
2125
c.position_filter(median_half_window=1, loess_half_window=5)
2226

27+
# %%
2328
# Plot
2429
fig = plt.figure(figsize=(12, 5))
2530
ax = fig.add_axes((0.05, 0.1, 0.9, 0.9))
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
"""
22
One Track
33
===================
4-
54
"""
65
from matplotlib import pyplot as plt
76
from py_eddy_tracker.observations.tracking import TrackEddiesObservations
87
import py_eddy_tracker_sample
98

9+
# %%
10+
# Load experimental atlas, and we select one eddy
1011
a = TrackEddiesObservations.load_file(
1112
py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Anticyclonic.zarr")
1213
)
13-
1414
eddy = a.extract_ids([9672])
1515
eddy_f = a.extract_ids([9672])
1616
eddy_f.position_filter(median_half_window=1, loess_half_window=5)
1717

18+
# %%
19+
# plot
1820
fig = plt.figure(figsize=(12, 5))
1921
ax = fig.add_axes((0.05, 0.05, 0.9, 0.9))
2022
ax.set_xlim(17.5, 22)
@@ -24,12 +26,15 @@
2426
eddy.plot(ax, color="r", lw=0.5)
2527
eddy_f.scatter(ax, "n", cmap="jet", s=80)
2628

29+
# %%
2730
fig = plt.figure(figsize=(12, 5))
2831
ax = fig.add_axes((0.05, 0.05, 0.9, 0.9))
2932
ax.set_xlim(17, 23)
3033
ax.set_ylim(34.5, 37)
3134
ax.set_aspect("equal")
3235
ax.grid()
33-
eddy.plot(ax, color="r", lw=0.5, label='track')
34-
eddy.index(range(0, len(eddy), 40)).display(ax, intern_only=True, label='observations every 40')
36+
eddy.plot(ax, color="r", lw=0.5, label="track")
37+
eddy.index(range(0, len(eddy), 40)).display(
38+
ax, intern_only=True, label="observations every 40"
39+
)
3540
ax.legend()

0 commit comments

Comments
 (0)