@@ -607,6 +607,7 @@ def eddy_identification(
607
607
date ,
608
608
step = 0.005 ,
609
609
shape_error = 55 ,
610
+ presampling_multiplier = 10 ,
610
611
sampling = 50 ,
611
612
sampling_method = "visvalingam" ,
612
613
pixel_limit = None ,
@@ -624,8 +625,10 @@ def eddy_identification(
624
625
:param datetime.datetime date: Date to be stored in object to date data
625
626
:param float,int step: Height between two layers in m
626
627
:param float,int shape_error: Maximal error allowed for outermost contour in %
628
+ :param int presampling_multiplier:
629
+ Evenly oversample the initial number of points in the contour by nb_pts x presampling_multiplier to fit circles
627
630
:param int sampling: Number of points to store contours and speed profile
628
- :param str sampling_method: Method to resample, 'uniform' or 'visvalingam'
631
+ :param str sampling_method: Method to resample the stored contours , 'uniform' or 'visvalingam'
629
632
:param (int,int),None pixel_limit:
630
633
Min and max number of pixels inside the inner and the outermost contour to be considered as an eddy
631
634
:param float,None precision: Truncate values at the defined precision in m
@@ -849,42 +852,59 @@ def eddy_identification(
849
852
obs .amplitude [:] = amp .amplitude
850
853
obs .speed_average [:] = max_average_speed
851
854
obs .num_point_e [:] = contour .lon .shape [0 ]
852
- xy_e = resample (contour .lon , contour .lat , ** out_sampling )
853
- obs .contour_lon_e [:], obs .contour_lat_e [:] = xy_e
854
855
obs .num_point_s [:] = speed_contour .lon .shape [0 ]
855
- xy_s = resample (
856
- speed_contour .lon , speed_contour .lat , ** out_sampling
857
- )
858
- obs .contour_lon_s [:], obs .contour_lat_s [:] = xy_s
859
856
860
- # FIXME : we use a contour without resampling
861
- # First, get position based on innermost contour
862
- centlon_i , centlat_i , _ , _ = _fit_circle_path (
863
- create_vertice (inner_contour .lon , inner_contour .lat )
857
+ # Evenly resample contours with nb_pts = nb_pts_original x presampling_multiplier
858
+ xy_i = uniform_resample (
859
+ inner_contour .lon ,
860
+ inner_contour .lat ,
861
+ num_fac = presampling_multiplier
862
+ )
863
+ xy_e = uniform_resample (
864
+ contour .lon ,
865
+ contour .lat ,
866
+ num_fac = presampling_multiplier ,
864
867
)
865
- # Second, get speed-based radius based on contour of max uavg
868
+ xy_s = uniform_resample (
869
+ speed_contour .lon ,
870
+ speed_contour .lat ,
871
+ num_fac = presampling_multiplier ,
872
+ )
873
+
874
+ # First, get position of max SSH based on best fit circle with resampled innermost contour
875
+ centlon_i , centlat_i , _ , _ = _fit_circle_path (create_vertice (* xy_i ))
876
+ obs .lon_max [:] = centlon_i
877
+ obs .lat_max [:] = centlat_i
878
+
879
+ # Second, get speed-based radius, shape error, eddy center, area based on resampled contour of max uavg
866
880
centlon_s , centlat_s , eddy_radius_s , aerr_s = _fit_circle_path (
867
881
create_vertice (* xy_s )
868
882
)
869
- # Compute again to use resampled contour
870
- _ , _ , eddy_radius_e , aerr_e = _fit_circle_path (
871
- create_vertice (* xy_e )
872
- )
873
-
874
883
obs .radius_s [:] = eddy_radius_s
875
- obs .radius_e [:] = eddy_radius_e
876
- obs .shape_error_e [:] = aerr_e
877
884
obs .shape_error_s [:] = aerr_s
878
885
obs .speed_area [:] = poly_area (
879
886
* coordinates_to_local (* xy_s , lon0 = centlon_s , lat0 = centlat_s )
880
887
)
888
+ obs .lon [:] = centlon_s
889
+ obs .lat [:] = centlat_s
890
+
891
+ # Third, compute effective radius, shape error, area from resampled effective contour
892
+ _ , _ , eddy_radius_e , aerr_e = _fit_circle_path (
893
+ create_vertice (* xy_e )
894
+ )
895
+ obs .radius_e [:] = eddy_radius_e
896
+ obs .shape_error_e [:] = aerr_e
881
897
obs .effective_area [:] = poly_area (
882
898
* coordinates_to_local (* xy_e , lon0 = centlon_s , lat0 = centlat_s )
883
899
)
884
- obs .lon [:] = centlon_s
885
- obs .lat [:] = centlat_s
886
- obs .lon_max [:] = centlon_i
887
- obs .lat_max [:] = centlat_i
900
+
901
+ # Finally, resample contours with output parameters
902
+ xy_e_f = resample (* xy_e , ** out_sampling )
903
+ xy_s_f = resample (* xy_s , ** out_sampling )
904
+
905
+ obs .contour_lon_s [:], obs .contour_lat_s [:] = xy_s_f
906
+ obs .contour_lon_e [:], obs .contour_lat_e [:] = xy_e_f
907
+
888
908
if aerr > 99.9 or aerr_s > 99.9 :
889
909
logger .warning (
890
910
"Strange shape at this step! shape_error : %f, %f" ,
0 commit comments