1010from uxarray .constants import ERROR_TOLERANCE , INT_FILL_VALUE
1111import uxarray .utils .computing as ac_utils
1212from uxarray .grid .coordinates import _populate_node_latlon , _lonlat_rad_to_xyz , _normalize_xyz , _xyz_to_lonlat_rad
13- from uxarray .grid .arcs import extreme_gca_latitude , _extreme_gca_latitude_cartesian
13+ from uxarray .grid .arcs import extreme_gca_latitude , extreme_gca_z
1414from uxarray .grid .utils import _get_cartesian_face_edge_nodes , _get_lonlat_rad_face_edge_nodes
1515from uxarray .grid .geometry import _populate_face_latlon_bound , _populate_bounds , _pole_point_inside_polygon_cartesian , stereographic_projection , inverse_stereographic_projection
1616
@@ -308,27 +308,27 @@ def test_extreme_gca_latitude_max():
308308 _normalize_xyz (* [- 0.5 , 0.5 , 0.5 ])
309309 ])
310310
311- max_latitude = _extreme_gca_latitude_cartesian (gca_cart , 'max' )
312- expected_max_latitude = _max_latitude_rad_iterative (gca_cart )
311+ max_latitude = extreme_gca_z (gca_cart , 'max' )
312+ expected_max_latitude = np . cos ( _max_latitude_rad_iterative (gca_cart ) )
313313 assert np .isclose (max_latitude , expected_max_latitude , atol = ERROR_TOLERANCE )
314314
315315 gca_cart = np .array ([[0.0 , 0.0 , 1.0 ], [1.0 , 0.0 , 0.0 ]])
316- max_latitude = _extreme_gca_latitude_cartesian (gca_cart , 'max' )
317- expected_max_latitude = np . pi / 2 # 90 degrees in radians
316+ max_latitude = extreme_gca_z (gca_cart , 'max' )
317+ expected_max_latitude = 1.0
318318 assert np .isclose (max_latitude , expected_max_latitude , atol = ERROR_TOLERANCE )
319319
320320def test_extreme_gca_latitude_max_short ():
321321 # Define a great circle arc in 3D space that has a small span
322322 gca_cart = np .array ([[0.65465367 , - 0.37796447 , - 0.65465367 ], [0.6652466 , - 0.33896007 , - 0.6652466 ]])
323323
324324 # Calculate the maximum latitude
325- max_latitude = _extreme_gca_latitude_cartesian ( gca_cart , 'max' )
325+ max_latitude = np . asin ( extreme_gca_z ( gca_cart , 'max' ) )
326326
327327 # Check if the maximum latitude is correct
328328 expected_max_latitude = _max_latitude_rad_iterative (gca_cart )
329329 assert np .isclose (max_latitude ,
330- expected_max_latitude ,
331- atol = ERROR_TOLERANCE )
330+ expected_max_latitude ,
331+ atol = ERROR_TOLERANCE )
332332
333333
334334def test_extreme_gca_latitude_min ():
@@ -337,13 +337,13 @@ def test_extreme_gca_latitude_min():
337337 _normalize_xyz (* [- 0.5 , 0.5 , - 0.5 ])
338338 ])
339339
340- min_latitude = _extreme_gca_latitude_cartesian ( gca_cart , 'min' )
340+ min_latitude = np . asin ( extreme_gca_z ( gca_cart , 'min' ) )
341341 expected_min_latitude = _min_latitude_rad_iterative (gca_cart )
342342 assert np .isclose (min_latitude , expected_min_latitude , atol = ERROR_TOLERANCE )
343343
344344 gca_cart = np .array ([[0.0 , 0.0 , - 1.0 ], [1.0 , 0.0 , 0.0 ]])
345- min_latitude = _extreme_gca_latitude_cartesian ( gca_cart , 'min' )
346- expected_min_latitude = - np .pi / 2 # 90 degrees in radians
345+ min_latitude = np . asin ( extreme_gca_z ( gca_cart , 'min' ) )
346+ expected_min_latitude = - np .pi / 2
347347 assert np .isclose (min_latitude , expected_min_latitude , atol = ERROR_TOLERANCE )
348348
349349def test_get_latlonbox_width ():
@@ -440,9 +440,9 @@ def test_populate_bounds_normal_latlon_bounds_gca():
440440 vertices_rad = np .radians (vertices_lonlat )
441441 vertices_cart = np .vstack ([_lonlat_rad_to_xyz (vertices_rad [:, 0 ], vertices_rad [:, 1 ])]).T
442442 lat_max = max (np .deg2rad (60.0 ),
443- _extreme_gca_latitude_cartesian ( np .array ([vertices_cart [0 ], vertices_cart [3 ]]), extreme_type = "max" ))
443+ np . asin ( extreme_gca_z ( np .array ([vertices_cart [0 ], vertices_cart [3 ]]), extreme_type = "max" ) ))
444444 lat_min = min (np .deg2rad (10.0 ),
445- _extreme_gca_latitude_cartesian ( np .array ([vertices_cart [1 ], vertices_cart [2 ]]), extreme_type = "min" ))
445+ np . asin ( extreme_gca_z ( np .array ([vertices_cart [1 ], vertices_cart [2 ]]), extreme_type = "min" ) ))
446446 lon_min = np .deg2rad (10.0 )
447447 lon_max = np .deg2rad (50.0 )
448448 grid = ux .Grid .from_face_vertices (vertices_lonlat , latlon = True )
@@ -467,9 +467,9 @@ def test_populate_bounds_antimeridian_latlon_bounds_gca():
467467 vertices_rad = np .radians (vertices_lonlat )
468468 vertices_cart = np .vstack ([_lonlat_rad_to_xyz (vertices_rad [:, 0 ], vertices_rad [:, 1 ])]).T
469469 lat_max = max (np .deg2rad (60.0 ),
470- _extreme_gca_latitude_cartesian ( np .array ([vertices_cart [0 ], vertices_cart [3 ]]), extreme_type = "max" ))
470+ np . asin ( extreme_gca_z ( np .array ([vertices_cart [0 ], vertices_cart [3 ]]), extreme_type = "max" ) ))
471471 lat_min = min (np .deg2rad (10.0 ),
472- _extreme_gca_latitude_cartesian ( np .array ([vertices_cart [1 ], vertices_cart [2 ]]), extreme_type = "min" ))
472+ np . asin ( extreme_gca_z ( np .array ([vertices_cart [1 ], vertices_cart [2 ]]), extreme_type = "min" ) ))
473473 lon_min = np .deg2rad (350.0 )
474474 lon_max = np .deg2rad (50.0 )
475475 grid = ux .Grid .from_face_vertices (vertices_lonlat , latlon = True )
@@ -578,7 +578,7 @@ def test_populate_bounds_node_on_pole_latlon_bounds_gca():
578578 vertices_cart = np .vstack ([_lonlat_rad_to_xyz (vertices_rad [:, 0 ], vertices_rad [:, 1 ])]).T
579579 lat_max = np .pi / 2
580580 lat_min = min (np .deg2rad (10.0 ),
581- _extreme_gca_latitude_cartesian ( np .array ([vertices_cart [1 ], vertices_cart [2 ]]), extreme_type = "min" ))
581+ np . asin ( extreme_gca_z ( np .array ([vertices_cart [1 ], vertices_cart [2 ]]), extreme_type = "min" ) ))
582582 lon_min = np .deg2rad (10.0 )
583583 lon_max = np .deg2rad (50.0 )
584584 grid = ux .Grid .from_face_vertices (vertices_lonlat , latlon = True )
@@ -604,7 +604,7 @@ def test_populate_bounds_edge_over_pole_latlon_bounds_gca():
604604 vertices_cart = np .vstack ([_lonlat_rad_to_xyz (vertices_rad [:, 0 ], vertices_rad [:, 1 ])]).T
605605 lat_max = np .pi / 2
606606 lat_min = min (np .deg2rad (60.0 ),
607- _extreme_gca_latitude_cartesian ( np .array ([vertices_cart [1 ], vertices_cart [2 ]]), extreme_type = "min" ))
607+ np . asin ( extreme_gca_z ( np .array ([vertices_cart [1 ], vertices_cart [2 ]]), extreme_type = "min" ) ))
608608 lon_min = np .deg2rad (210.0 )
609609 lon_max = np .deg2rad (30.0 )
610610 grid = ux .Grid .from_face_vertices (vertices_lonlat , latlon = True )
@@ -630,7 +630,7 @@ def test_populate_bounds_pole_inside_latlon_bounds_gca():
630630 vertices_cart = np .vstack ([_lonlat_rad_to_xyz (vertices_rad [:, 0 ], vertices_rad [:, 1 ])]).T
631631 lat_max = np .pi / 2
632632 lat_min = min (np .deg2rad (60.0 ),
633- _extreme_gca_latitude_cartesian ( np .array ([vertices_cart [1 ], vertices_cart [2 ]]), extreme_type = "min" ))
633+ np . asin ( extreme_gca_z ( np .array ([vertices_cart [1 ], vertices_cart [2 ]]), extreme_type = "min" ) ))
634634 lon_min = 0
635635 lon_max = 2 * np .pi
636636 grid = ux .Grid .from_face_vertices (vertices_lonlat , latlon = True )
0 commit comments