Skip to content

Commit e47637f

Browse files
committed
Start use of sphinx-gallery : minigallery in docstring
1 parent f4ba6c0 commit e47637f

File tree

5 files changed

+45
-5
lines changed

5 files changed

+45
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ instance/
7070

7171
# Sphinx documentation
7272
docs/_build/
73+
doc/gen_modules/
7374

7475
# PyBuilder
7576
target/

doc/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
"examples_dirs": "../examples", # path to your example scripts
4747
"gallery_dirs": "python_module",
4848
"capture_repr": ("_repr_html_",),
49+
"backreferences_dir": "gen_modules/backreferences",
50+
"doc_module": ("py_eddy_tracker",),
4951
"line_numbers": False,
5052
"filename_pattern": "/pet",
5153
"binder": {

examples/08_tracking_manipulation/pet_display_track.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@
99
import py_eddy_tracker_sample
1010

1111
# %%
12-
# Load experimental atlas, and keep only eddies longer than 20 weeks
12+
# Load experimental atlas
1313
a = TrackEddiesObservations.load_file(
1414
py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Anticyclonic.zarr")
1515
)
1616
c = TrackEddiesObservations.load_file(
1717
py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Cyclonic.zarr")
1818
)
19+
print(a)
20+
21+
# %%
22+
# keep only eddies longer than 20 weeks, use -1 to have no upper limit
1923
a = a.extract_with_length((7 * 20, -1))
2024
c = c.extract_with_length((7 * 20, -1))
25+
print(a)
2126

2227
# %%
2328
# Position filtering for nice display

notebooks/python_module/08_tracking_manipulation/pet_display_track.ipynb

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"cell_type": "markdown",
1616
"metadata": {},
1717
"source": [
18-
"\nDisplay Tracks\n======================\n"
18+
"\n# Display Tracks\n"
1919
]
2020
},
2121
{
@@ -33,7 +33,7 @@
3333
"cell_type": "markdown",
3434
"metadata": {},
3535
"source": [
36-
"Load experimental atlas, and keep only eddies longer than 20 weeks\n\n"
36+
"Load experimental atlas\n\n"
3737
]
3838
},
3939
{
@@ -44,7 +44,25 @@
4444
},
4545
"outputs": [],
4646
"source": [
47-
"a = TrackEddiesObservations.load_file(\n py_eddy_tracker_sample.get_path(\"eddies_med_adt_allsat_dt2018/Anticyclonic.zarr\")\n)\nc = TrackEddiesObservations.load_file(\n py_eddy_tracker_sample.get_path(\"eddies_med_adt_allsat_dt2018/Cyclonic.zarr\")\n)\na = a.extract_with_length((7 * 20, -1))\nc = c.extract_with_length((7 * 20, -1))"
47+
"a = TrackEddiesObservations.load_file(\n py_eddy_tracker_sample.get_path(\"eddies_med_adt_allsat_dt2018/Anticyclonic.zarr\")\n)\nc = TrackEddiesObservations.load_file(\n py_eddy_tracker_sample.get_path(\"eddies_med_adt_allsat_dt2018/Cyclonic.zarr\")\n)\nprint(a)"
48+
]
49+
},
50+
{
51+
"cell_type": "markdown",
52+
"metadata": {},
53+
"source": [
54+
"keep only eddies longer than 20 weeks\n\n"
55+
]
56+
},
57+
{
58+
"cell_type": "code",
59+
"execution_count": null,
60+
"metadata": {
61+
"collapsed": false
62+
},
63+
"outputs": [],
64+
"source": [
65+
"a = a.extract_with_length((7 * 20, -1))\nc = c.extract_with_length((7 * 20, -1))\nprint(a)"
4866
]
4967
},
5068
{

src/py_eddy_tracker/observations/tracking.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,11 @@ def extract_with_area(self, area, **kwargs):
233233
Extract with a bounding box
234234
235235
:param dict area: 4 coordinates in a dictionary to specify bounding box (lower left corner and upper right corner)
236+
:param dict kwargs: look at :py:meth:`__extract_with_mask`
237+
:return: Return all eddy tracks which are in bounds
238+
:rtype: TrackEddiesObservations
236239
240+
.. minigallery:: py_eddy_tracker.observations.tracking.TrackEddiesObservations.extract_with_area
237241
"""
238242
mask = (self.latitude > area["llcrnrlat"]) * (self.latitude < area["urcrnrlat"])
239243
lon0 = area["llcrnrlon"]
@@ -246,8 +250,11 @@ def extract_with_period(self, period, **kwargs):
246250
Extract with a period
247251
248252
:param (datetime.datetime,datetime.datetime) period: two date to define period, must be specify from 1/1/1950
253+
:param dict kwargs: look at :py:meth:`__extract_with_mask`
254+
:return: Return all eddy tracks which are in bounds
255+
:rtype: TrackEddiesObservations
249256
250-
:return: same object with selected data
257+
.. minigallery:: py_eddy_tracker.observations.tracking.TrackEddiesObservations.extract_with_period
251258
"""
252259
dataset_period = self.period
253260
p_min, p_max = period
@@ -324,6 +331,13 @@ def extract_in_direction(self, direction, value=0):
324331
return self.__extract_with_mask(mask)
325332

326333
def extract_with_length(self, bounds):
334+
"""
335+
:param (int,int) bounds: length min and max of selected eddies, if use of -1 this bound is not used
336+
:return: Return all eddy tracks which have length between bounds
337+
:rtype: TrackEddiesObservations
338+
339+
.. minigallery:: py_eddy_tracker.observations.tracking.TrackEddiesObservations.extract_with_length
340+
"""
327341
b0, b1 = bounds
328342
if b0 >= 0 and b1 >= 0:
329343
track_mask = (self.nb_obs_by_track >= b0) * (self.nb_obs_by_track <= b1)

0 commit comments

Comments
 (0)