Skip to content

Commit 4937727

Browse files
committed
update example
1 parent e824544 commit 4937727

File tree

19 files changed

+65
-59
lines changed

19 files changed

+65
-59
lines changed

examples/02_eddy_identification/pet_filter_and_detection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def update_axes(ax, mappable=None):
3333
# Add a new filed to store the high-pass filtered ADT
3434

3535
g = RegularGridDataset(
36-
data.get_path("dt_med_allsat_phy_l4_20160515_20190101.nc"), "longitude", "latitude",
36+
data.get_path("dt_med_allsat_phy_l4_20160515_20190101.nc"), "longitude", "latitude"
3737
)
3838
g.add_uv("adt")
3939
g.copy("adt", "adt_high")

examples/02_eddy_identification/pet_sla_and_adt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def update_axes(ax, mappable=None):
3131
# Load Input grid, ADT will be used to detect eddies
3232

3333
g = RegularGridDataset(
34-
data.get_path("dt_med_allsat_phy_l4_20160515_20190101.nc"), "longitude", "latitude",
34+
data.get_path("dt_med_allsat_phy_l4_20160515_20190101.nc"), "longitude", "latitude"
3535
)
3636
g.add_uv("adt", "ugos", "vgos")
3737
g.add_uv("sla", "ugosa", "vgosa")

examples/06_grid_manipulation/pet_filter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def update_axes(ax, mappable=None):
3232
# %%
3333
# All information will be for regular grid
3434
g = RegularGridDataset(
35-
data.get_path("dt_med_allsat_phy_l4_20160515_20190101.nc"), "longitude", "latitude",
35+
data.get_path("dt_med_allsat_phy_l4_20160515_20190101.nc"), "longitude", "latitude"
3636
)
3737
# %%
3838
# Kernel

examples/08_tracking_manipulation/pet_select_track_across_area.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
c.plot(ax, color="gray", lw=0.1, ref=-10, label="all tracks")
3333
c_subset.plot(ax, color="red", lw=0.2, ref=-10, label="selected tracks")
3434
ax.plot(
35-
(x0, x0, x1, x1, x0,),
36-
(y0, y1, y1, y0, y0,),
35+
(x0, x0, x1, x1, x0),
36+
(y0, y1, y1, y0, y0),
3737
color="green",
3838
lw=1.5,
3939
label="Box of selection",

examples/10_tracking_diagnostics/pet_center_count.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@
7575
# Count at the center's position
7676

7777
fig = plt.figure(figsize=(12, 10))
78-
ax = fig.add_subplot(211)
78+
ax_long = fig.add_axes([0.03, 0.53, 0.90, 0.45])
7979
g_a = a.grid_count(bins, center=True, filter=a.lifetime >= 30)
80-
m = g_a.display(ax, **kwargs_pcolormesh)
81-
ax.set_aspect("equal")
82-
ax.set_title("Anticyclones with lifetime >= 30 days")
83-
cb = plt.colorbar(m, cax=fig.add_axes([0.94, 0.1, 0.015, 0.8]))
84-
ax = fig.add_subplot(212)
80+
m = g_a.display(ax_long, **kwargs_pcolormesh)
81+
ax_long.set_title("Anticyclones with lifetime >= 30 days")
82+
ax_short = fig.add_axes([0.03, 0.03, 0.90, 0.45])
8583
g_a = a.grid_count(bins, center=True, filter=a.lifetime < 30)
86-
m = g_a.display(ax, **kwargs_pcolormesh)
87-
ax.set_aspect("equal")
88-
ax.set_title("Anticyclones with lifetime < 30 days")
84+
m = g_a.display(ax_short, **kwargs_pcolormesh)
85+
ax_short.set_title("Anticyclones with lifetime < 30 days")
86+
for ax in (ax_short, ax_long):
87+
ax.set_aspect("equal"), ax.grid()
88+
ax.set_xlim(-6, 36.5), ax.set_ylim(30, 46)
89+
cb = plt.colorbar(m, cax=fig.add_axes([0.94, 0.05, 0.015, 0.9]))

examples/10_tracking_diagnostics/pet_pixel_used.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,15 @@
7070
# --------------------------------------------
7171

7272
fig = plt.figure(figsize=(12, 10))
73-
ax = fig.add_subplot(211)
73+
ax_long = fig.add_axes([0.03, 0.53, 0.90, 0.45])
7474
g_a = a.grid_count(bins, intern=True, filter=a.lifetime >= 30)
75-
m = g_a.display(ax, **kwargs_pcolormesh)
76-
ax.set_aspect("equal")
77-
ax.set_title("Anticyclones with lifetime >= 30 days")
78-
cb = plt.colorbar(m, cax=fig.add_axes([0.94, 0.1, 0.015, 0.8]))
79-
ax = fig.add_subplot(212)
75+
m = g_a.display(ax_long, **kwargs_pcolormesh)
76+
ax_long.set_title("Anticyclones with lifetime >= 30 days")
77+
ax_short = fig.add_axes([0.03, 0.03, 0.90, 0.45])
8078
g_a = a.grid_count(bins, intern=True, filter=a.lifetime < 30)
81-
m = g_a.display(ax, **kwargs_pcolormesh)
82-
ax.set_aspect("equal")
83-
ax.set_title("Anticyclones with lifetime < 30 days")
79+
m = g_a.display(ax_short, **kwargs_pcolormesh)
80+
ax_short.set_title("Anticyclones with lifetime < 30 days")
81+
for ax in (ax_short, ax_long):
82+
ax.set_aspect("equal"), ax.grid()
83+
ax.set_xlim(-6, 36.5), ax.set_ylim(30, 46)
84+
cb = plt.colorbar(m, cax=fig.add_axes([0.94, 0.05, 0.015, 0.9]))

notebooks/python_module/02_eddy_identification/pet_filter_and_detection.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"from datetime import datetime\nfrom matplotlib import pyplot as plt\nfrom py_eddy_tracker.dataset.grid import RegularGridDataset\nfrom py_eddy_tracker import data\nfrom numpy import arange"
29+
"from datetime import datetime\n\nfrom matplotlib import pyplot as plt\nfrom numpy import arange\n\nfrom py_eddy_tracker import data\nfrom py_eddy_tracker.dataset.grid import RegularGridDataset"
3030
]
3131
},
3232
{
@@ -55,7 +55,7 @@
5555
},
5656
"outputs": [],
5757
"source": [
58-
"g = RegularGridDataset(\n data.get_path(\"dt_med_allsat_phy_l4_20160515_20190101.nc\"), \"longitude\", \"latitude\",\n)\ng.add_uv(\"adt\")\ng.copy(\"adt\", \"adt_high\")\nwavelength = 800\ng.bessel_high_filter(\"adt_high\", wavelength)\ndate = datetime(2016, 5, 15)"
58+
"g = RegularGridDataset(\n data.get_path(\"dt_med_allsat_phy_l4_20160515_20190101.nc\"), \"longitude\", \"latitude\"\n)\ng.add_uv(\"adt\")\ng.copy(\"adt\", \"adt_high\")\nwavelength = 800\ng.bessel_high_filter(\"adt_high\", wavelength)\ndate = datetime(2016, 5, 15)"
5959
]
6060
},
6161
{

notebooks/python_module/02_eddy_identification/pet_sla_and_adt.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"from datetime import datetime\nfrom matplotlib import pyplot as plt\nfrom py_eddy_tracker.dataset.grid import RegularGridDataset\nfrom py_eddy_tracker import data"
29+
"from datetime import datetime\n\nfrom matplotlib import pyplot as plt\n\nfrom py_eddy_tracker import data\nfrom py_eddy_tracker.dataset.grid import RegularGridDataset"
3030
]
3131
},
3232
{
@@ -55,7 +55,7 @@
5555
},
5656
"outputs": [],
5757
"source": [
58-
"g = RegularGridDataset(\n data.get_path(\"dt_med_allsat_phy_l4_20160515_20190101.nc\"), \"longitude\", \"latitude\",\n)\ng.add_uv(\"adt\", \"ugos\", \"vgos\")\ng.add_uv(\"sla\", \"ugosa\", \"vgosa\")\nwavelength = 400\ng.copy(\"adt\", \"adt_raw\")\ng.copy(\"sla\", \"sla_raw\")\ng.bessel_high_filter(\"adt\", wavelength)\ng.bessel_high_filter(\"sla\", wavelength)\ndate = datetime(2016, 5, 15)"
58+
"g = RegularGridDataset(\n data.get_path(\"dt_med_allsat_phy_l4_20160515_20190101.nc\"), \"longitude\", \"latitude\"\n)\ng.add_uv(\"adt\", \"ugos\", \"vgos\")\ng.add_uv(\"sla\", \"ugosa\", \"vgosa\")\nwavelength = 400\ng.copy(\"adt\", \"adt_raw\")\ng.copy(\"sla\", \"sla_raw\")\ng.bessel_high_filter(\"adt\", wavelength)\ng.bessel_high_filter(\"sla\", wavelength)\ndate = datetime(2016, 5, 15)"
5959
]
6060
},
6161
{

notebooks/python_module/06_grid_manipulation/pet_filter.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"from py_eddy_tracker.dataset.grid import RegularGridDataset\nfrom py_eddy_tracker import data\nfrom matplotlib import pyplot as plt\nfrom numpy import arange\n\n\ndef start_axes(title):\n fig = plt.figure(figsize=(13, 5))\n ax = fig.add_axes([0.03, 0.03, 0.90, 0.94])\n ax.set_xlim(-6, 36.5), ax.set_ylim(30, 46)\n ax.set_aspect(\"equal\")\n ax.set_title(title)\n return ax\n\n\ndef update_axes(ax, mappable=None):\n ax.grid()\n if mappable:\n plt.colorbar(mappable, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9]))"
29+
"from matplotlib import pyplot as plt\nfrom numpy import arange\n\nfrom py_eddy_tracker import data\nfrom py_eddy_tracker.dataset.grid import RegularGridDataset\n\n\ndef start_axes(title):\n fig = plt.figure(figsize=(13, 5))\n ax = fig.add_axes([0.03, 0.03, 0.90, 0.94])\n ax.set_xlim(-6, 36.5), ax.set_ylim(30, 46)\n ax.set_aspect(\"equal\")\n ax.set_title(title)\n return ax\n\n\ndef update_axes(ax, mappable=None):\n ax.grid()\n if mappable:\n plt.colorbar(mappable, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9]))"
3030
]
3131
},
3232
{
@@ -44,7 +44,7 @@
4444
},
4545
"outputs": [],
4646
"source": [
47-
"g = RegularGridDataset(\n data.get_path(\"dt_med_allsat_phy_l4_20160515_20190101.nc\"), \"longitude\", \"latitude\",\n)"
47+
"g = RegularGridDataset(\n data.get_path(\"dt_med_allsat_phy_l4_20160515_20190101.nc\"), \"longitude\", \"latitude\"\n)"
4848
]
4949
},
5050
{

notebooks/python_module/08_tracking_manipulation/pet_select_track_across_area.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
},
2727
"outputs": [],
2828
"source": [
29-
"from matplotlib import pyplot as plt\nfrom py_eddy_tracker.observations.tracking import TrackEddiesObservations\nimport py_eddy_tracker_sample"
29+
"import py_eddy_tracker_sample\nfrom matplotlib import pyplot as plt\n\nfrom py_eddy_tracker.observations.tracking import TrackEddiesObservations"
3030
]
3131
},
3232
{
@@ -80,7 +80,7 @@
8080
},
8181
"outputs": [],
8282
"source": [
83-
"fig = plt.figure(figsize=(12, 5))\nax = fig.add_axes((0.05, 0.05, 0.9, 0.9))\nax.set_xlim(-1, 9)\nax.set_ylim(36, 40)\nax.set_aspect(\"equal\")\nax.grid()\nc.plot(ax, color=\"gray\", lw=0.1, ref=-10, label=\"all tracks\")\nc_subset.plot(ax, color=\"red\", lw=0.2, ref=-10, label=\"selected tracks\")\nax.plot(\n (x0, x0, x1, x1, x0,),\n (y0, y1, y1, y0, y0,),\n color=\"green\",\n lw=1.5,\n label=\"Box of selection\",\n)\nax.legend()"
83+
"fig = plt.figure(figsize=(12, 5))\nax = fig.add_axes((0.05, 0.05, 0.9, 0.9))\nax.set_xlim(-1, 9)\nax.set_ylim(36, 40)\nax.set_aspect(\"equal\")\nax.grid()\nc.plot(ax, color=\"gray\", lw=0.1, ref=-10, label=\"all tracks\")\nc_subset.plot(ax, color=\"red\", lw=0.2, ref=-10, label=\"selected tracks\")\nax.plot(\n (x0, x0, x1, x1, x0),\n (y0, y1, y1, y0, y0),\n color=\"green\",\n lw=1.5,\n label=\"Box of selection\",\n)\nax.legend()"
8484
]
8585
}
8686
],

0 commit comments

Comments
 (0)