15
15
from py_eddy_tracker import data
16
16
from py_eddy_tracker .generic import coordinates_to_local , local_to_coordinates
17
17
from py_eddy_tracker .observations .observation import EddiesObservations
18
- from py_eddy_tracker .poly import fit_circle_ , fit_ellips
18
+ from py_eddy_tracker .poly import fit_circle_ , fit_ellipse
19
19
20
20
# %%
21
21
# Load example identification file
22
22
a = EddiesObservations .load_file (data .get_demo_path ("Anticyclonic_20190223.nc" ))
23
23
24
24
25
25
# %%
26
- # Function to draw circle or ellips from parameter
26
+ # Function to draw circle or ellipse from parameter
27
27
def build_circle (x0 , y0 , r ):
28
28
angle = radians (linspace (0 , 360 , 50 ))
29
29
x_norm , y_norm = cos (angle ), sin (angle )
30
30
return local_to_coordinates (x_norm * r , y_norm * r , x0 , y0 )
31
31
32
32
33
- def build_ellips (x0 , y0 , a , b , theta ):
33
+ def build_ellipse (x0 , y0 , a , b , theta ):
34
34
angle = radians (linspace (0 , 360 , 50 ))
35
35
x = a * cos (theta ) * cos (angle ) - b * sin (theta ) * sin (angle )
36
36
y = a * sin (theta ) * cos (angle ) + b * cos (theta ) * sin (angle )
37
37
return local_to_coordinates (x , y , x0 , y0 )
38
38
39
39
40
40
# %%
41
- # Plot fitted circle or ellips on stored contour
41
+ # Plot fitted circle or ellipse on stored contour
42
42
xs , ys = a .contour_lon_s , a .contour_lat_s
43
43
44
44
fig = plt .figure (figsize = (15 , 15 ))
@@ -51,9 +51,9 @@ def build_ellips(x0, y0, a, b, theta):
51
51
ax = fig .add_subplot (4 , 4 , j )
52
52
ax .grid (), ax .set_aspect ("equal" )
53
53
ax .plot (x , y , label = "store" , color = "black" )
54
- x0 , y0 , a , b , theta = fit_ellips (x_ , y_ )
54
+ x0 , y0 , a , b , theta = fit_ellipse (x_ , y_ )
55
55
x0 , y0 = local_to_coordinates (x0 , y0 , x0_ , y0_ )
56
- ax .plot (* build_ellips (x0 , y0 , a , b , theta ), label = "ellips " , color = "green" )
56
+ ax .plot (* build_ellipse (x0 , y0 , a , b , theta ), label = "ellipse " , color = "green" )
57
57
x0 , y0 , radius , shape_error = fit_circle_ (x_ , y_ )
58
58
x0 , y0 = local_to_coordinates (x0 , y0 , x0_ , y0_ )
59
59
ax .plot (* build_circle (x0 , y0 , radius ), label = "circle" , color = "red" , lw = 0.5 )
0 commit comments