From 2486ecc6224be974c93c634e2f4d6b18cf13d14f Mon Sep 17 00:00:00 2001 From: Philip Chmielowiec Date: Tue, 21 Jan 2025 13:44:28 -0600 Subject: [PATCH] slight cleanup --- test/test_integrate.py | 10 +++++----- uxarray/grid/integrate.py | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/test/test_integrate.py b/test/test_integrate.py index a955281e0..1799b13f1 100644 --- a/test/test_integrate.py +++ b/test/test_integrate.py @@ -17,7 +17,7 @@ from uxarray.grid.coordinates import _lonlat_rad_to_xyz from uxarray.grid.integrate import _get_zonal_face_interval, _process_overlapped_intervals, \ _get_faces_constLat_intersection_info, get_non_conservative_zonal_face_weights_at_const_lat, \ - get_non_conservative_zonal_face_weights_at_const_lat_overlap + get_non_conservative_zonal_face_weights_at_const_lat_original current_path = Path(os.path.dirname(os.path.realpath(__file__))) @@ -549,7 +549,7 @@ def test_get_zonal_faces_weight_at_constLat_equator(): # A error will be raise if we don't set is_latlonface=True since the face_2 will be concave if # It's edges are all GCA with pytest.raises(ValueError): - get_non_conservative_zonal_face_weights_at_const_lat_overlap(np.array([ + get_non_conservative_zonal_face_weights_at_const_lat_original(np.array([ face_0_edge_nodes, face_1_edge_nodes, face_2_edge_nodes ]), np.deg2rad(20), latlon_bounds) @@ -1007,7 +1007,7 @@ def test_get_zonal_faces_weight_at_constLat_latlonface(): }) # Assert the results is the same to the 3 decimal places - weight_df = get_non_conservative_zonal_face_weights_at_const_lat_overlap(np.array([ + weight_df = get_non_conservative_zonal_face_weights_at_const_lat_original(np.array([ face_0_edge_nodes, face_1_edge_nodes, face_2_edge_nodes ]), np.sin(np.deg2rad(20)), latlon_bounds, is_latlonface=True) @@ -1016,7 +1016,7 @@ def test_get_zonal_faces_weight_at_constLat_latlonface(): # A error will be raise if we don't set is_latlonface=True since the face_2 will be concave if # It's edges are all GCA with pytest.raises(ValueError): - get_non_conservative_zonal_face_weights_at_const_lat_overlap(np.array([ + get_non_conservative_zonal_face_weights_at_const_lat_original(np.array([ face_0_edge_nodes, face_1_edge_nodes, face_2_edge_nodes ]), np.deg2rad(20), latlon_bounds) @@ -1050,7 +1050,7 @@ def test_compare_zonal_weights(): n_nodes_per_face_candidate, z) - existing_weights = get_non_conservative_zonal_face_weights_at_const_lat_overlap( + existing_weights = get_non_conservative_zonal_face_weights_at_const_lat_original( faces_edge_nodes_xyz_candidate, z, bounds_candidate )["weight"].to_numpy() diff --git a/uxarray/grid/integrate.py b/uxarray/grid/integrate.py index e15a90ec4..6863fed26 100644 --- a/uxarray/grid/integrate.py +++ b/uxarray/grid/integrate.py @@ -57,7 +57,7 @@ def _is_edge_gca(is_GCA_list, is_latlonface, edges_z): # Correctly handles overlaps -def get_non_conservative_zonal_face_weights_at_const_lat_overlap( +def get_non_conservative_zonal_face_weights_at_const_lat_original( faces_edges_cart_candidate: np.ndarray, latitude_cart: float, face_latlon_bound_candidate: np.ndarray, @@ -610,9 +610,10 @@ def get_non_conservative_zonal_face_weights_at_const_lat( z: float, ) -> np.ndarray: """TODO: Docstring""" + # If near equator, use original approach if np.isclose(z, 0.0, atol=ERROR_TOLERANCE): - overlap_result = get_non_conservative_zonal_face_weights_at_const_lat_overlap( + overlap_result = get_non_conservative_zonal_face_weights_at_const_lat_original( face_edges_xyz, z, face_bounds ) return overlap_result["weight"].to_numpy()