Skip to content

Commit dd230b9

Browse files
committed
Change color of cyclone and anticyclone
1 parent 3f2be40 commit dd230b9

File tree

5 files changed

+71
-28
lines changed

5 files changed

+71
-28
lines changed

examples/pet_display_track.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@
1717

1818
a = a.extract_with_length((7 * 20, -1))
1919
c = c.extract_with_length((7 * 20, -1))
20+
a.median_filter(1, 'time', 'lon').loess_filter(5, 'time', 'lon')
21+
a.median_filter(1, 'time', 'lat').loess_filter(5, 'time', 'lat')
22+
c.median_filter(1, 'time', 'lon').loess_filter(5, 'time', 'lon')
23+
c.median_filter(1, 'time', 'lat').loess_filter(5, 'time', 'lat')
24+
2025

2126
# Plot
2227
fig = plt.figure(figsize=(15, 8))
2328
ax = fig.add_subplot(111)
2429
ax.set_aspect("equal")
2530
ax.set_xlim(-5, 37)
2631
ax.set_ylim(30, 46)
27-
a.plot(ax, ref=-10, label="Anticyclonic", color="b", lw=0.1)
28-
c.plot(ax, ref=-10, label="Cyclonic", color="r", lw=0.1)
32+
a.plot(ax, ref=-10, label="Anticyclonic", color="r", lw=0.1)
33+
c.plot(ax, ref=-10, label="Cyclonic", color="b", lw=0.1)
2934
ax.legend()

examples/pet_histo.py

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,42 @@
88
import py_eddy_tracker_sample
99
from numpy import arange
1010

11-
a = TrackEddiesObservations.load_file(py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Anticyclonic.zarr"))
12-
c = TrackEddiesObservations.load_file(py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Cyclonic.zarr"))
11+
a = TrackEddiesObservations.load_file(
12+
py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Anticyclonic.zarr")
13+
)
14+
c = TrackEddiesObservations.load_file(
15+
py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Cyclonic.zarr")
16+
)
17+
kwargs_a = dict(label="Anticyclonic", color="r")
18+
kwargs_c = dict(label="Cyclonic", color="b")
19+
1320
# Plot
1421
fig = plt.figure()
1522
ax = fig.add_subplot(111)
16-
ax.hist(a['amplitude'], histtype='step', bins=arange(0.0005,1,0.002), label='Anticyclonic')
17-
ax.hist(c['amplitude'], histtype='step', bins=arange(0.0005,1,0.002), label='Cyclonic')
18-
ax.set_xlabel('Amplitude (m)')
19-
ax.set_xlim(0,.5)
23+
ax.hist(a["amplitude"], histtype="step", bins=arange(0.0005, 1, 0.002), **kwargs_a)
24+
ax.hist(c["amplitude"], histtype="step", bins=arange(0.0005, 1, 0.002), **kwargs_c)
25+
ax.set_xlabel("Amplitude (m)")
26+
ax.set_xlim(0, 0.5)
2027
ax.legend()
2128
ax.grid()
2229

2330
fig = plt.figure()
2431
ax = fig.add_subplot(111)
25-
bins = arange(0,200,1)
26-
ax.hist(a['radius_s'] / 1000., histtype='step', bins=bins, label='Anticyclonic')
27-
ax.hist(c['radius_s'] / 1000., histtype='step', bins=bins, label='Cyclonic')
28-
ax.set_xlabel('Speed_radius (km)')
29-
ax.set_xlim(0,150)
32+
bins = arange(0, 200, 1)
33+
ax.hist(a["radius_s"] / 1000.0, histtype="step", bins=bins, **kwargs_a)
34+
ax.hist(c["radius_s"] / 1000.0, histtype="step", bins=bins, **kwargs_c)
35+
ax.set_xlabel("Speed_radius (km)")
36+
ax.set_xlim(0, 150)
3037
ax.legend()
3138
ax.grid()
3239

3340
fig = plt.figure()
3441
ax = fig.add_subplot(111)
35-
bins = arange(0,100,1)
36-
ax.hist(a['speed_average'] * 100., histtype='step', bins=bins, label='Anticyclonic')
37-
ax.hist(c['speed_average'] * 100., histtype='step', bins=bins, label='Cyclonic')
38-
ax.set_xlabel('speed_average (cm/s)')
42+
bins = arange(0, 100, 1)
43+
ax.hist(a["speed_average"] * 100.0, histtype="step", bins=bins, **kwargs_a)
44+
ax.hist(c["speed_average"] * 100.0, histtype="step", bins=bins, **kwargs_c)
45+
ax.set_xlabel("speed_average (cm/s)")
3946

40-
ax.set_xlim(0,50)
47+
ax.set_xlim(0, 50)
4148
ax.legend()
42-
ax.grid()
49+
ax.grid()

examples/pet_lifetime.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
ax_ratio_cum_lifetime = fig.add_axes([0.55, 0.05, .4, .4])
2020

2121

22-
cum_a, bins, _ = ax_cum_lifetime.hist(a['n'], histtype='step', bins=arange(0,800,1), label='Anticyclonic', color='b')
23-
cum_c, bins, _ = ax_cum_lifetime.hist(c['n'], histtype='step', bins=arange(0,800,1), label='Cyclonic', color='r')
22+
cum_a, bins, _ = ax_cum_lifetime.hist(a['n'], histtype='step', bins=arange(0,800,1), label='Anticyclonic', color='r')
23+
cum_c, bins, _ = ax_cum_lifetime.hist(c['n'], histtype='step', bins=arange(0,800,1), label='Cyclonic', color='b')
2424

2525
x = (bins[1:] + bins[:-1]) / 2.
2626
ax_ratio_cum_lifetime.plot(x, cum_c/cum_a)
2727

2828
nb_a, nb_c = cum_a[:-1] - cum_a[1:], cum_c[:-1] - cum_c[1:]
29-
ax_lifetime.plot(x[1:], nb_a, label='Anticyclonic', color='b')
30-
ax_lifetime.plot(x[1:], nb_c, label='Cyclonic', color='r')
29+
ax_lifetime.plot(x[1:], nb_a, label='Anticyclonic', color='r')
30+
ax_lifetime.plot(x[1:], nb_c, label='Cyclonic', color='b')
3131

3232
ax_ratio_lifetime.plot(x[1:], nb_c / nb_a)
3333

examples/pet_one_track.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
One Track
3+
===================
4+
5+
"""
6+
from matplotlib import pyplot as plt
7+
from py_eddy_tracker.observations.tracking import TrackEddiesObservations
8+
import py_eddy_tracker_sample
9+
10+
a = TrackEddiesObservations.load_file(
11+
py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Anticyclonic.zarr")
12+
)
13+
14+
eddy = a.extract_ids([9672])
15+
eddy_f = a.extract_ids([9672])
16+
eddy_f.median_filter(1, 'time', 'lon').loess_filter(5, 'time', 'lon')
17+
eddy_f.median_filter(1, 'time', 'lat').loess_filter(5, 'time', 'lat')
18+
fig = plt.figure(figsize=(20, 8))
19+
ax = fig.add_subplot(111)
20+
ax.set_xlim(17, 22.5)
21+
ax.set_ylim(35, 36.5)
22+
ax.grid()
23+
eddy.plot(ax, color='r', lw=.5)
24+
eddy_f.plot(ax, color='g', lw=1)
25+

examples/pet_propagation.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ def cum_distance_by_track(distance, track):
3232
c = TrackEddiesObservations.load_file(
3333
py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Cyclonic.zarr")
3434
)
35+
36+
a.median_filter(1, 'time', 'lon').loess_filter(5, 'time', 'lon')
37+
a.median_filter(1, 'time', 'lat').loess_filter(5, 'time', 'lat')
38+
c.median_filter(1, 'time', 'lon').loess_filter(5, 'time', 'lon')
39+
c.median_filter(1, 'time', 'lat').loess_filter(5, 'time', 'lat')
40+
3541
d_a = distance(a.longitude[:-1], a.latitude[:-1], a.longitude[1:], a.latitude[1:])
3642
d_c = distance(c.longitude[:-1], c.latitude[:-1], c.longitude[1:], c.latitude[1:])
3743
d_a = cum_distance_by_track(d_a, a["track"]) / 1000.
@@ -45,20 +51,20 @@ def cum_distance_by_track(distance, track):
4551
ax_ratio_cum_propagation = fig.add_axes([0.55, 0.05, 0.4, 0.4])
4652

4753

48-
bins = arange(0, 1500, 25)
54+
bins = arange(0, 1500, 10)
4955
cum_a, bins, _ = ax_cum_propagation.hist(
50-
d_a, histtype="step", bins=bins, label="Anticyclonic", color="b"
56+
d_a, histtype="step", bins=bins, label="Anticyclonic", color="r"
5157
)
5258
cum_c, bins, _ = ax_cum_propagation.hist(
53-
d_c, histtype="step", bins=bins, label="Cyclonic", color="r"
59+
d_c, histtype="step", bins=bins, label="Cyclonic", color="b"
5460
)
5561

5662
x = (bins[1:] + bins[:-1]) / 2.0
5763
ax_ratio_cum_propagation.plot(x, cum_c / cum_a)
5864

5965
nb_a, nb_c = cum_a[:-1] - cum_a[1:], cum_c[:-1] - cum_c[1:]
60-
ax_propagation.plot(x[1:], nb_a, label="Anticyclonic", color="b")
61-
ax_propagation.plot(x[1:], nb_c, label="Cyclonic", color="r")
66+
ax_propagation.plot(x[1:], nb_a, label="Anticyclonic", color="r")
67+
ax_propagation.plot(x[1:], nb_c, label="Cyclonic", color="b")
6268

6369
ax_ratio_propagation.plot(x[1:], nb_c / nb_a)
6470

0 commit comments

Comments
 (0)