Skip to content

Commit 251569b

Browse files
committed
add docstring
1 parent 0f80506 commit 251569b

File tree

4 files changed

+37
-15
lines changed

4 files changed

+37
-15
lines changed

examples/02_eddy_identification/pet_display_id.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313
a = EddiesObservations.load_file(data.get_path("Anticyclonic_20190223.nc"))
1414
c = EddiesObservations.load_file(data.get_path("Cyclonic_20190223.nc"))
1515

16+
# %%
17+
# filled contour with amplitude field
18+
fig = plt.figure(figsize=(15, 8))
19+
ax = fig.add_axes([0.03, 0.03, 0.90, 0.94])
20+
ax.set_aspect("equal")
21+
ax.set_xlim(0, 140)
22+
ax.set_ylim(-80, 0)
23+
kwargs = dict(extern_only=True, color="k", lw=1)
24+
a.display(ax, **kwargs), c.display(ax, **kwargs)
25+
a.filled(ax, "amplitude", cmap="magma_r", vmin=0, vmax=.5)
26+
m = c.filled(ax, "amplitude", cmap="magma_r", vmin=0, vmax=.5)
27+
colorbar = plt.colorbar(m, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9]))
28+
colorbar.set_label('Amplitude (m)')
29+
30+
plt.show()
31+
1632
# %%
1733
# draw contour
1834
fig = plt.figure(figsize=(15, 8))
@@ -24,17 +40,6 @@
2440
c.display(ax, label="Cyclonic", color="b", lw=1)
2541
ax.legend(loc="upper right")
2642

27-
# %%
28-
# filled contour
29-
fig = plt.figure(figsize=(15, 8))
30-
ax = fig.add_axes([0.03, 0.03, 0.90, 0.94])
31-
ax.set_aspect("equal")
32-
ax.set_xlim(0, 140)
33-
ax.set_ylim(-80, 0)
34-
a.display(ax, label="Anticyclonic", color="r", lw=1)
35-
m = a.filled(ax, "amplitude", cmap="magma_r", vmin=0, vmax=.5)
36-
plt.colorbar(m, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9]))
37-
plt.show()
3843
# %%
3944
# Get general informations
4045
print(a)

notebooks/python_module/02_eddy_identification/pet_display_id.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"cell_type": "markdown",
5252
"metadata": {},
5353
"source": [
54-
"draw contour\n\n"
54+
"filled contour with amplitude field\n\n"
5555
]
5656
},
5757
{
@@ -62,14 +62,14 @@
6262
},
6363
"outputs": [],
6464
"source": [
65-
"fig = plt.figure(figsize=(15, 8))\nax = fig.add_axes([0.03, 0.03, 0.94, 0.94])\nax.set_aspect(\"equal\")\nax.set_xlim(0, 360)\nax.set_ylim(-80, 80)\na.display(ax, label=\"Anticyclonic\", color=\"r\", lw=1)\nc.display(ax, label=\"Cyclonic\", color=\"b\", lw=1)\nax.legend(loc=\"upper right\")"
65+
"fig = plt.figure(figsize=(15, 8))\nax = fig.add_axes([0.03, 0.03, 0.90, 0.94])\nax.set_aspect(\"equal\")\nax.set_xlim(0, 140)\nax.set_ylim(-80, 0)\nkwargs = dict(extern_only=True, color=\"k\", lw=1)\na.display(ax, **kwargs), c.display(ax, **kwargs)\na.filled(ax, \"amplitude\", cmap=\"magma_r\", vmin=0, vmax=.5)\nm = c.filled(ax, \"amplitude\", cmap=\"magma_r\", vmin=0, vmax=.5)\ncolorbar = plt.colorbar(m, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9]))\ncolorbar.set_label('Amplitude (m)')\n\nplt.show()"
6666
]
6767
},
6868
{
6969
"cell_type": "markdown",
7070
"metadata": {},
7171
"source": [
72-
"filled contour\n\n"
72+
"draw contour\n\n"
7373
]
7474
},
7575
{
@@ -80,7 +80,7 @@
8080
},
8181
"outputs": [],
8282
"source": [
83-
"fig = plt.figure(figsize=(15, 8))\nax = fig.add_axes([0.03, 0.03, 0.90, 0.94])\nax.set_aspect(\"equal\")\nax.set_xlim(0, 140)\nax.set_ylim(-80, 0)\na.display(ax, label=\"Anticyclonic\", color=\"r\", lw=1)\nm = a.filled(ax, \"amplitude\", cmap=\"magma_r\", vmin=0, vmax=.5)\nplt.colorbar(m, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9]))\nplt.show()"
83+
"fig = plt.figure(figsize=(15, 8))\nax = fig.add_axes([0.03, 0.03, 0.94, 0.94])\nax.set_aspect(\"equal\")\nax.set_xlim(0, 360)\nax.set_ylim(-80, 80)\na.display(ax, label=\"Anticyclonic\", color=\"r\", lw=1)\nc.display(ax, label=\"Cyclonic\", color=\"b\", lw=1)\nax.legend(loc=\"upper right\")"
8484
]
8585
},
8686
{

src/py_eddy_tracker/dataset/grid.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,7 @@ def eddy_identification(
593593
:return: Return a list of 2 elements: Anticyclone and Cyclone
594594
:rtype: py_eddy_tracker.observations.observation.EddiesObservations
595595
596+
.. minigallery:: py_eddy_tracker.GridDataset.eddy_identification
596597
"""
597598
if not isinstance(date, datetime):
598599
raise Exception("Date argument be a datetime object")

src/py_eddy_tracker/observations/observation.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ def add_rotation_type(self):
322322
return new
323323

324324
def circle_contour(self):
325+
"""
326+
Set contour like a circle with radius and center data
327+
328+
.. minigallery:: py_eddy_tracker.EddiesObservations.circle_contour
329+
"""
325330
angle = radians(linspace(0, 360, self.track_array_variables))
326331
x_norm, y_norm = cos(angle), sin(angle)
327332
for i, obs in enumerate(self):
@@ -1423,6 +1428,17 @@ def display(
14231428
ax.plot(lon_e, lat_e, linestyle="-.", **kwargs_e)
14241429

14251430
def grid_count(self, bins, intern=False, center=False):
1431+
"""
1432+
Compute count of eddies in each bin (use of all pixel in each contour)
1433+
1434+
:param (numpy.array,numpy.array) bins: bins to compute count
1435+
:param bool intern: if True use speed contour only
1436+
:param bool center: if True use of center to count
1437+
:return: return grid of count
1438+
:rtype: py_eddy_tracker.dataset.grid.RegularGridDataset
1439+
1440+
.. minigallery:: py_eddy_tracker.EddiesObservations.grid_count
1441+
"""
14261442
x_name, y_name = self.intern(intern)
14271443
x_bins, y_bins = arange(*bins[0]), arange(*bins[1])
14281444
x0 = bins[0][0]

0 commit comments

Comments
 (0)