Exemplo n.º 1
0
# %%
# Load Input grid, ADT is used to detect eddies
margin = 30

kw_data = dict(
    filename=data.get_demo_path(
        "nrt_global_allsat_phy_l4_20190223_20190226.nc"),
    x_name="longitude",
    y_name="latitude",
    # Manual area subset
    indexs=dict(
        latitude=slice(100 - margin, 220 + margin),
        longitude=slice(0, 230 + margin),
    ),
)
g_raw = RegularGridDataset(**kw_data)
g_raw.add_uv("adt")
g = RegularGridDataset(**kw_data)
g.copy("adt", "adt_low")
g.bessel_high_filter("adt", 700)
g.bessel_low_filter("adt_low", 700)
g.add_uv("adt")

# %%
# Identification
# ^^^^^^^^^^^^^^
# Run the identification step with slices of 2 mm
date = datetime(2016, 5, 15)
kw_ident = dict(date=date,
                step=0.002,
                shape_error=70,
Exemplo n.º 2
0
    axes.grid()
    if mappable:
        plt.colorbar(mappable,
                     cax=axes.figure.add_axes([0.94, 0.05, 0.01, 0.9]))


# %%
# Load detection files
a = EddiesObservations.load_file(data.get_path("Anticyclonic_20190223.nc"))
c = EddiesObservations.load_file(data.get_path("Cyclonic_20190223.nc"))

# %%
# Load Input grid, ADT will be used to detect eddies
g = RegularGridDataset(
    data.get_path("nrt_global_allsat_phy_l4_20190223_20190226.nc"),
    "longitude",
    "latitude",
)

ax = start_axes("ADT (cm)")
m = g.display(ax, "adt", vmin=-120, vmax=120, factor=100)
update_axes(ax, m)

# %%
# Get parameter for ow
u_x = g.compute_stencil(g.grid("ugos"))
u_y = g.compute_stencil(g.grid("ugos"), vertical=True)
v_x = g.compute_stencil(g.grid("vgos"))
v_y = g.compute_stencil(g.grid("vgos"), vertical=True)
ow = g.vars["ow"] = (u_x - v_y)**2 + (v_x + u_y)**2 - (v_x - u_y)**2
Exemplo n.º 3
0
            
    ax.set_extent(extent)
    ax.gridlines()
    ax.coastlines(resolution='50m')
    ax.set_title(title)
    return ax

def update_axes(ax, mappable=None, unit=''):
    ax.grid()
    if mappable:  
        plt.colorbar(mappable, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9],title=unit))

# %%
# Loading SLA and first display
# -----------------------------
g = RegularGridDataset(data.get_path(filename_alt), lon_name_alt,lat_name_alt)
ax = start_axes("SLA", extent=extent)
m = g.display(ax, "sla", vmin=0.05, vmax=0.35)
u,v = g.grid("ugosa").T,g.grid("vgosa").T
ax.quiver(g.x_c, g.y_c, u, v, scale=10)
update_axes(ax, m, unit='[m]')

# %%
# Loading SST and first display
# -----------------------------
t = RegularGridDataset(filename=data.get_path(filename_sst),
                       x_name=lon_name_sst,
                       y_name=lat_name_sst)

# The following now load the corresponding variables from the SST netcdf (it's not needed to load it beforehand, so not executed.)
# t.grid(var_name_sst)
Exemplo n.º 4
0
    ax.set_xlim(-6, 36.5), ax.set_ylim(30, 46)
    ax.set_aspect("equal")
    ax.set_title(title)
    return ax


def update_axes(ax, mappable=None):
    ax.grid()
    if mappable:
        plt.colorbar(m, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9]))


# %%
# Load Input grid, ADT will be used to detect eddies
g = RegularGridDataset(
    data.get_path("dt_med_allsat_phy_l4_20160515_20190101.nc"), "longitude",
    "latitude")

ax = start_axes("ADT (m)")
m = g.display(ax, "adt", vmin=-0.15, vmax=0.15)
update_axes(ax, m)

# %%
# Get u/v
# -------
# U/V are deduced from ADT, this algortihm are not usable around equator (~+- 2°)
g.add_uv("adt")
ax = start_axes("U/V deduce from ADT (m)")
ax.set_xlim(2.5, 9), ax.set_ylim(37.5, 40)
m = g.display(ax, "adt", vmin=-0.15, vmax=0.15)
u, v = g.grid("u").T, g.grid("v").T
Exemplo n.º 5
0
from matplotlib import pyplot as plt
from py_eddy_tracker.dataset.grid import RegularGridDataset
grid_name, lon_name, lat_name = 'nrt_global_allsat_phy_l4_20190223_20190226.nc', 'longitude', 'latitude'
if False:

    h = RegularGridDataset(grid_name, lon_name, lat_name)

    fig = plt.figure(figsize=(14, 12))
    ax = fig.add_axes([.02, .51, .9, .45])
    ax.set_title('ADT (m)')
    ax.set_ylim(-75, 75)
    ax.set_aspect('equal')
    m = h.display(ax, name='adt', vmin=-1, vmax=1)
    ax.grid(True)
    plt.colorbar(m, cax=fig.add_axes([.94, .51, .01, .45]))
    h = RegularGridDataset(grid_name, lon_name, lat_name)
    h.bessel_high_filter('adt', 500, order=3)
    ax = fig.add_axes([.02, .02, .9, .45])
    ax.set_title('ADT Filtered (m)')
    ax.set_aspect('equal')
    ax.set_ylim(-75, 75)
    m = h.display(ax, name='adt', vmin=-.1, vmax=.1)
    ax.grid(True)
    plt.colorbar(m, cax=fig.add_axes([.94, .02, .01, .45]))
    fig.savefig('png/filter.png')

if True:
    import logging
    logging.getLogger().setLevel(
        'DEBUG')  # Values: ERROR, WARNING, INFO, DEBUG
    from datetime import datetime
Exemplo n.º 6
0
from matplotlib.path import Path
from numpy import array, ma
from pytest import approx

from py_eddy_tracker.data import get_path
from py_eddy_tracker.dataset.grid import RegularGridDataset

G = RegularGridDataset(get_path("mask_1_60.nc"), "lon", "lat")
X = 0.025
contour = Path((
    (-X, 0),
    (X, 0),
    (X, X),
    (-X, X),
    (-X, 0),
))


# contour
def test_contour_lon():
    assert (contour.lon == (-X, X, X, -X, -X)).all()


def test_contour_lat():
    assert (contour.lat == (0, 0, X, X, 0)).all()


def test_contour_mean():
    assert (contour.mean_coordinates == (0, X / 2)).all()

Exemplo n.º 7
0

def update_axes(ax, mappable=None):
    ax.grid()
    if mappable:
        plt.colorbar(mappable, cax=ax.figure.add_axes([0.95, 0.05, 0.01, 0.9]))


# %%
# Load Input grid, ADT will be used to detect eddies
margin = 30
g = RegularGridDataset(
    data.get_path("nrt_global_allsat_phy_l4_20190223_20190226.nc"),
    "longitude",
    "latitude",
    # Manual area subset
    indexs=dict(
        longitude=slice(1116 - margin, 1216 + margin),
        latitude=slice(476 - margin, 536 + margin),
    ),
)

ax = start_axes("ADT (m)")
m = g.display(ax, "adt", vmin=-0.15, vmax=1)
# Draw line on the gulf stream front
great_current = Contours(g.x_c,
                         g.y_c,
                         g.grid("adt"),
                         levels=(0.35, ),
                         keep_unclose=True)
great_current.display(ax, color="k")
update_axes(ax, m)
date = datetime(2016, 7, 7)

filename_alt = data.get_path(
    f"dt_blacksea_allsat_phy_l4_{date:%Y%m%d}_20200801.nc")
filename_sst = data.get_path(
    f"{date:%Y%m%d}000000-GOS-L4_GHRSST-SSTfnd-OISST_HR_REP-BLK-v02.0-fv01.0.nc"
)
var_name_sst = "analysed_sst"

extent = [27, 42, 40.5, 47]

# %%
# Loading data
# ------------
sst = RegularGridDataset(filename=filename_sst, x_name="lon", y_name="lat")
alti = RegularGridDataset(data.get_path(filename_alt),
                          x_name="longitude",
                          y_name="latitude")
# We can use `Grid` tools to interpolate ADT on the sst grid
sst.regrid(alti, "sla")
sst.add_uv("sla")


# %%
# Functions to initiate figure axes
def start_axes(title, extent=extent):
    fig = plt.figure(figsize=(13, 6), dpi=120)
    ax = fig.add_axes([0.03, 0.05, 0.89, 0.91])
    ax.set_xlim(extent[0], extent[1])
    ax.set_ylim(extent[2], extent[3])
from netCDF4 import Dataset
from py_eddy_tracker.dataset.grid import RegularGridDataset, UnRegularGridDataset
import logging
logging.basicConfig(level=logging.DEBUG)

# h = UnRegularGridDataset('NEATL36_1d_grid2D_20140515-20140515_short.nc', 'nav_lon', 'nav_lat')
# h.high_filter('sossheig', 20, 10)
# h.add_uv('sossheig')
# h.write('unregular.nc')

h = RegularGridDataset(
    '/data/adelepoulle/Test/Test_eddy/20180417_eddy_tracker_validation_object_oriented/nrt_global_allsat_phy_l4_20180409_20180415.nc',
    'longitude', 'latitude')
h.high_filter('sla', 10, 5)
anticyclonic, cyclonic = h.eddy_identification('sla', 'ugos', 'vgos', 0.0025)
print(len(anticyclonic))
print(len(cyclonic))
with Dataset('/tmp/a.nc', 'w') as h:
    anticyclonic.to_netcdf(h)
with Dataset('/tmp/c.nc', 'w') as h:
    cyclonic.to_netcdf(h)

# h = UnRegularGridDataset('/tmp/t.nc', 'nav_lon', 'nav_lat')
# eddies = h.eddy_identification('sossheig', step=0.005)