Skip to content

Commit 2c5d4b9

Browse files
committed
Effective radius will be compute in same geo reference than speed radius
1 parent faf3703 commit 2c5d4b9

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/py_eddy_tracker/dataset/grid.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -588,13 +588,13 @@ def eddy_identification(self, grid_height, uname, vname, date, step=0.005, shape
588588
proj = Proj('+proj=aeqd +ellps=WGS84 +lat_0={1} +lon_0={0}'.format(*inner_contour.mean_coordinates))
589589
# First, get position based on innermost
590590
# contour
591-
c_x, c_y = proj(inner_contour.lon, inner_contour.lat)
592-
centx_i, centy_i, _, _ = fit_circle(c_x, c_y)
591+
centx_i, centy_i, _, _ = fit_circle(*proj(inner_contour.lon, inner_contour.lat))
593592
centlon_i, centlat_i = proj(centx_i, centy_i, inverse=True)
594593
# Second, get speed-based radius based on
595594
# contour of max uavg
596-
c_x, c_y = proj(speed_contour.lon, speed_contour.lat)
597-
centx_s, centy_s, eddy_radius_s, aerr_s = fit_circle(c_x, c_y)
595+
centx_s, centy_s, eddy_radius_s, aerr_s = fit_circle(*proj(speed_contour.lon, speed_contour.lat))
596+
# Computed again to be coherent with speed_radius, we will be compute in same reference
597+
_, _, eddy_radius_e, aerr_e = fit_circle(*proj(current_contour.lon, current_contour.lat))
598598
centlon_s, centlat_s = proj(centx_s, centy_s, inverse=True)
599599

600600
# Instantiate new EddyObservation object (high cost need to be review)
@@ -615,7 +615,7 @@ def eddy_identification(self, grid_height, uname, vname, date, step=0.005, shape
615615
properties.obs['radius_s'] = eddy_radius_s
616616
properties.obs['speed_average'] = max_average_speed
617617
properties.obs['radius_e'] = eddy_radius_e
618-
properties.obs['shape_error_e'] = aerr
618+
properties.obs['shape_error_e'] = aerr_e
619619
properties.obs['shape_error_s'] = aerr_s
620620
properties.obs['lon'] = centlon_s
621621
properties.obs['lat'] = centlat_s

src/scripts/EddyId

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ from datetime import datetime
77
from netCDF4 import Dataset
88
from py_eddy_tracker import EddyParser
99
from py_eddy_tracker.dataset.grid import RegularGridDataset
10-
10+
import zarr
1111

1212
def id_parser():
1313
parser = EddyParser('Eddy Identification')
@@ -30,6 +30,9 @@ def id_parser():
3030
help='Force height unit')
3131
parser.add_argument('--speed_unit', default=None, type=str,
3232
help='Force speed unit')
33+
parser.add_argument('--zarr',
34+
action='store_true',
35+
help='Output will be wrote in zarr')
3336
return parser
3437

3538

@@ -48,7 +51,13 @@ if __name__ == '__main__':
4851
a, c = h.eddy_identification(args.h, u, v, date, args.isoline_step, pixel_limit=(5, 2000),
4952
shape_error=args.fir_errmax, force_height_unit=args.height_unit,
5053
force_speed_unit=args.speed_unit)
51-
with Dataset(args.path_out + date.strftime('/Anticyclonic_%Y%m%d.nc'), 'w') as h:
52-
a.to_netcdf(h)
53-
with Dataset(args.path_out + date.strftime('/Cyclonic_%Y%m%d.nc'), 'w') as h:
54-
c.to_netcdf(h)
54+
if args.zarr:
55+
h = zarr.open(args.path_out + date.strftime('/Anticyclonic_%Y%m%d.zarr'), 'w')
56+
a.to_zarr(h)
57+
h = zarr.open(args.path_out + date.strftime('/Cyclonic_%Y%m%d.zarr'), 'w')
58+
c.to_zarr(h)
59+
else:
60+
with Dataset(args.path_out + date.strftime('/Anticyclonic_%Y%m%d.nc'), 'w') as h:
61+
a.to_netcdf(h)
62+
with Dataset(args.path_out + date.strftime('/Cyclonic_%Y%m%d.nc'), 'w') as h:
63+
c.to_netcdf(h)

0 commit comments

Comments
 (0)