|
| 1 | +""" |
| 2 | +Eddy detection |
| 3 | +============== |
| 4 | +
|
| 5 | +Script will detect eddies on adt field, and compute u,v with method add_uv(which could use, only if equator is avoid) |
| 6 | +
|
| 7 | +""" |
| 8 | +from datetime import datetime |
| 9 | +from matplotlib import pyplot as plt |
| 10 | +from py_eddy_tracker.dataset.grid import RegularGridDataset |
| 11 | +from py_eddy_tracker import data |
| 12 | + |
| 13 | + |
| 14 | +def start_axes(title): |
| 15 | + fig = plt.figure(figsize=(12.5, 5)) |
| 16 | + ax = fig.add_axes([0.03, 0.03, 0.94, 0.94]) |
| 17 | + ax.set_xlim(-5, 37) |
| 18 | + ax.set_ylim(30, 46) |
| 19 | + ax.set_aspect("equal") |
| 20 | + ax.set_title(title) |
| 21 | + return ax |
| 22 | + |
| 23 | + |
| 24 | +def update_axes(ax, mappable=None): |
| 25 | + ax.grid() |
| 26 | + if mappable: |
| 27 | + plt.colorbar(m, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9])) |
| 28 | + |
| 29 | + |
| 30 | +g = RegularGridDataset( |
| 31 | + data.get_path("dt_med_allsat_phy_l4_20160515_20190101.nc"), "longitude", "latitude" |
| 32 | +) |
| 33 | + |
| 34 | +ax = start_axes("ADT(m)") |
| 35 | +m = g.display(ax, "adt", vmin=-0.15, vmax=0.15) |
| 36 | +update_axes(ax, m) |
| 37 | + |
| 38 | +g.add_uv("adt") |
| 39 | +g.bessel_high_filter("adt", 500, order=2) |
| 40 | + |
| 41 | +ax = start_axes("ADT (m) filtered(500km, order 2)") |
| 42 | +m = g.display(ax, "adt", vmin=-0.15, vmax=0.15) |
| 43 | +update_axes(ax, m) |
| 44 | + |
| 45 | +date = datetime(2016, 5, 15) |
| 46 | +a, c = g.eddy_identification("adt", "u", "v", date, 0.002) |
| 47 | + |
| 48 | +ax = start_axes("ADT closed contour (only 1 / 4 levels)") |
| 49 | +g.contours.display(ax, step=4) |
| 50 | +update_axes(ax) |
| 51 | + |
| 52 | +ax = start_axes("ADT contour used as eddies") |
| 53 | +g.contours.display(ax, only_used=True) |
| 54 | +update_axes(ax) |
| 55 | + |
| 56 | +ax = start_axes("ADT contour reject") |
| 57 | +g.contours.display(ax, only_unused=True) |
| 58 | +update_axes(ax) |
| 59 | + |
| 60 | +ax = start_axes("ADT contour reject but which contain eddies") |
| 61 | +g.contours.label_contour_unused_which_contain_eddies(a) |
| 62 | +g.contours.label_contour_unused_which_contain_eddies(c) |
| 63 | +g.contours.display(ax, only_contain_eddies=True, color="k", lw=1, label="Could be interaction contour") |
| 64 | +a.display(ax, color="b", linewidth=0.5, label="Anticyclonic", ref=-10) |
| 65 | +c.display(ax, color="r", linewidth=0.5, label="Cyclonic", ref=-10) |
| 66 | +ax.legend() |
| 67 | +update_axes(ax) |
| 68 | + |
| 69 | +ax = start_axes("Eddies detected") |
| 70 | +a.display(ax, color="b", linewidth=0.5, label="Anticyclonic", ref=-10) |
| 71 | +c.display(ax, color="r", linewidth=0.5, label="Cyclonic", ref=-10) |
| 72 | +ax.legend() |
| 73 | +update_axes(ax) |
| 74 | + |
| 75 | +ax = start_axes("Eddies speed radius (km)") |
| 76 | +a.scatter(ax, "radius_s", vmin=10, vmax=50, s=80, ref=-10, cmap='jet', factor=0.001) |
| 77 | +m = c.scatter(ax, "radius_s", vmin=10, vmax=50, s=80, ref=-10, cmap='jet', factor=0.001) |
| 78 | +update_axes(ax, m) |
0 commit comments