|
14 | 14 | c = TrackEddiesObservations.load_file(
|
15 | 15 | py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Cyclonic.zarr")
|
16 | 16 | )
|
17 |
| -kwargs_a = dict(label="Anticyclonic", color="r") |
18 |
| -kwargs_c = dict(label="Cyclonic", color="b") |
| 17 | +kwargs_a = dict(label="Anticyclonic", color="r", histtype="step", density=True) |
| 18 | +kwargs_c = dict(label="Cyclonic", color="b", histtype="step", density=True) |
19 | 19 |
|
20 | 20 | # Plot
|
21 |
| -fig = plt.figure() |
22 |
| -ax = fig.add_subplot(111) |
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) |
27 |
| -ax.legend() |
28 |
| -ax.grid() |
| 21 | +fig = plt.figure(figsize=(12, 7)) |
29 | 22 |
|
30 |
| -fig = plt.figure() |
31 |
| -ax = fig.add_subplot(111) |
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) |
37 |
| -ax.legend() |
38 |
| -ax.grid() |
| 23 | +for x0, name, title, xmax, factor, bins in zip( |
| 24 | + (0.4, 0.72, 0.08), |
| 25 | + ("radius_s", "speed_average", "amplitude"), |
| 26 | + ("Speed radius (km)", "Speed average (cm/s)", "Amplitude (cm)"), |
| 27 | + (100, 50, 20), |
| 28 | + (0.001, 100, 100), |
| 29 | + (arange(0, 2000, 1), arange(0, 1000, 0.5), arange(0.0005, 1000, 0.2)), |
| 30 | +): |
| 31 | + ax_hist = fig.add_axes((x0, 0.24, 0.27, 0.35)) |
| 32 | + nb_a, _, _ = ax_hist.hist(a[name] * factor, bins=bins, **kwargs_a) |
| 33 | + nb_c, _, _ = ax_hist.hist(c[name] * factor, bins=bins, **kwargs_c) |
| 34 | + ax_hist.set_xticklabels([]) |
| 35 | + ax_hist.set_xlim(0, xmax) |
| 36 | + ax_hist.grid() |
39 | 37 |
|
40 |
| -fig = plt.figure() |
41 |
| -ax = fig.add_subplot(111) |
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)") |
| 38 | + ax_cum = fig.add_axes((x0, 0.62, 0.27, 0.35)) |
| 39 | + ax_cum.hist(a[name] * factor, bins=bins, cumulative=-1, **kwargs_a) |
| 40 | + ax_cum.hist(c[name] * factor, bins=bins, cumulative=-1, **kwargs_c) |
| 41 | + ax_cum.set_xticklabels([]) |
| 42 | + ax_cum.set_title(title) |
| 43 | + ax_cum.set_xlim(0, xmax) |
| 44 | + ax_cum.set_ylim(0, 1) |
| 45 | + ax_cum.grid() |
46 | 46 |
|
47 |
| -ax.set_xlim(0, 50) |
48 |
| -ax.legend() |
49 |
| -ax.grid() |
| 47 | + ax_ratio = fig.add_axes((x0, 0.06, 0.27, 0.15)) |
| 48 | + ax_ratio.set_xlim(0, xmax) |
| 49 | + ax_ratio.set_ylim(0, 2) |
| 50 | + ax_ratio.plot((bins[1:] + bins[:-1]) / 2, nb_c / nb_a) |
| 51 | + ax_ratio.axhline(1, color="k") |
| 52 | + ax_ratio.grid() |
| 53 | + ax_ratio.set_xlabel(title) |
| 54 | + |
| 55 | +ax_cum.set_ylabel("Cumulative\npercent distribution") |
| 56 | +ax_hist.set_ylabel("Percent of observations") |
| 57 | +ax_ratio.set_ylabel("Ratio percent\nCyc/Acyc") |
| 58 | +ax_cum.legend() |
0 commit comments