Skip to content

Commit 84c5a0c

Browse files
authored
Merge branch 'main' into zedwick/bilinear-remapping
2 parents a1974d1 + 94aa3cf commit 84c5a0c

16 files changed

Lines changed: 843 additions & 854 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575

7676
- name: Upload code coverage to Codecov
7777
if: github.repository == 'UXARRAY/uxarray'
78-
uses: codecov/codecov-action@v5.4.0
78+
uses: codecov/codecov-action@v5.4.2
7979
env:
8080
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
8181
with:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repos:
1414

1515
- repo: https://github.com/astral-sh/ruff-pre-commit
1616
# Ruff version.
17-
rev: v0.11.5
17+
rev: v0.11.6
1818
hooks:
1919
- id: ruff
2020
name: lint with ruff

docs/examples/visualization/mpas_topology.ipynb

Lines changed: 20 additions & 44 deletions
Large diffs are not rendered by default.

docs/user-guide/area_calc.ipynb

Lines changed: 39 additions & 39 deletions
Large diffs are not rendered by default.

test/test_geometry.py

Lines changed: 50 additions & 48 deletions
Large diffs are not rendered by default.

test/test_helpers.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from uxarray.constants import INT_DTYPE, INT_FILL_VALUE
1212
from uxarray.grid.coordinates import _lonlat_rad_to_xyz, _normalize_xyz, _xyz_to_lonlat_rad
1313
from uxarray.grid.arcs import point_within_gca, _angle_of_2_vectors, in_between
14-
from uxarray.grid.utils import _get_cartesian_face_edge_nodes, _get_lonlat_rad_face_edge_nodes
14+
from uxarray.grid.utils import _get_cartesian_face_edge_nodes_array, _get_lonlat_rad_face_edge_nodes_array
1515
from uxarray.grid.geometry import pole_point_inside_polygon, _pole_point_inside_polygon_cartesian
1616

1717
try:
@@ -41,7 +41,7 @@ def test_face_area_coords():
4141
face_dimension = np.array([3], dtype=INT_DTYPE)
4242

4343
area, _ = ux.grid.area.get_all_face_area_from_coords(
44-
x, y, z, face_nodes, face_dimension, 3, coords_type="cartesian")
44+
x, y, z, face_nodes, face_dimension)
4545
nt.assert_almost_equal(area, constants.TRI_AREA, decimal=5)
4646

4747

@@ -54,12 +54,12 @@ def test_calculate_face_area():
5454
z = np.array([0.66674712, 0.43462917, 0.66674712])
5555

5656
area, _ = ux.grid.area.calculate_face_area(
57-
x, y, z, "gaussian", 5, "cartesian", latitude_adjusted_area=False)
57+
x, y, z, "gaussian", 5, latitude_adjusted_area=False)
5858

5959
nt.assert_almost_equal(area, constants.TRI_AREA, decimal=5)
6060

6161
area_corrected, _ = ux.grid.area.calculate_face_area(
62-
x, y, z, "gaussian", 5, "cartesian", latitude_adjusted_area=True)
62+
x, y, z, "gaussian", 5, latitude_adjusted_area=True)
6363

6464
nt.assert_almost_equal(area_corrected, constants.CORRECTED_TRI_AREA, decimal=5)
6565

@@ -273,7 +273,7 @@ def test_get_cartesian_face_edge_nodes_pipeline():
273273
node_y = grid.node_y.values
274274
node_z = grid.node_z.values
275275

276-
face_edges_connectivity_cartesian = _get_cartesian_face_edge_nodes(
276+
face_edges_connectivity_cartesian = _get_cartesian_face_edge_nodes_array(
277277
face_node_conn, n_face, n_max_face_edges, node_x, node_y, node_z
278278
)
279279

@@ -298,7 +298,7 @@ def test_get_cartesian_face_edge_nodes_filled_value():
298298
node_y = grid.node_y.values
299299
node_z = grid.node_z.values
300300

301-
face_edges_connectivity_cartesian = _get_cartesian_face_edge_nodes(
301+
face_edges_connectivity_cartesian = _get_cartesian_face_edge_nodes_array(
302302
face_node_conn, n_face, n_max_face_edges, node_x, node_y, node_z
303303
)
304304

@@ -335,7 +335,7 @@ def test_get_cartesian_face_edge_nodes_filled_value2():
335335
node_y = np.array([v0_cart[1],v1_cart[1],v2_cart[1],v3_cart[1],v4_cart[1]])
336336
node_z = np.array([v0_cart[2],v1_cart[2],v2_cart[2],v3_cart[2],v4_cart[2]])
337337

338-
face_edges_connectivity_cartesian = _get_cartesian_face_edge_nodes(
338+
face_edges_connectivity_cartesian = _get_cartesian_face_edge_nodes_array(
339339
face_node_conn, n_face, n_max_face_edges, node_x, node_y, node_z
340340
)
341341

@@ -368,7 +368,7 @@ def test_get_lonlat_face_edge_nodes_pipeline():
368368
node_lon = grid.node_lon.values
369369
node_lat = grid.node_lat.values
370370

371-
face_edges_connectivity_lonlat = _get_lonlat_rad_face_edge_nodes(
371+
face_edges_connectivity_lonlat = _get_lonlat_rad_face_edge_nodes_array(
372372
face_node_conn, n_face, n_max_face_edges, node_lon, node_lat
373373
)
374374

@@ -398,7 +398,7 @@ def test_get_lonlat_face_edge_nodes_filled_value():
398398
node_lon = grid.node_lon.values
399399
node_lat = grid.node_lat.values
400400

401-
face_edges_connectivity_lonlat = _get_lonlat_rad_face_edge_nodes(
401+
face_edges_connectivity_lonlat = _get_lonlat_rad_face_edge_nodes_array(
402402
face_node_conn, n_face, n_max_face_edges, node_lon, node_lat
403403
)
404404

@@ -434,7 +434,7 @@ def test_get_lonlat_face_edge_nodes_filled_value2():
434434
node_lon = np.array([v0_rad[0],v1_rad[0],v2_rad[0],v3_rad[0],v4_rad[0]])
435435
node_lat = np.array([v0_rad[1],v1_rad[1],v2_rad[1],v3_rad[1],v4_rad[1]])
436436

437-
face_edges_connectivity_lonlat = _get_lonlat_rad_face_edge_nodes(
437+
face_edges_connectivity_lonlat = _get_lonlat_rad_face_edge_nodes_array(
438438
face_node_conn, n_face, n_max_face_edges, node_lon, node_lat
439439
)
440440

test/test_integrate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
_get_faces_constLat_intersection_info, _zonal_face_weights, \
2020
_zonal_face_weights_robust
2121

22-
from uxarray.grid.utils import _get_cartesian_face_edge_nodes
22+
from uxarray.grid.utils import _get_cartesian_face_edge_nodes_array
2323

2424
current_path = Path(os.path.dirname(os.path.realpath(__file__)))
2525

@@ -1037,7 +1037,7 @@ def test_compare_zonal_weights():
10371037
for gridfile in gridfiles:
10381038
uxgrid = ux.open_grid(gridfile)
10391039
n_nodes_per_face = uxgrid.n_nodes_per_face.values
1040-
face_edge_nodes_xyz = _get_cartesian_face_edge_nodes(
1040+
face_edge_nodes_xyz = _get_cartesian_face_edge_nodes_array(
10411041
uxgrid.face_node_connectivity.values,
10421042
uxgrid.n_face,
10431043
uxgrid.n_max_face_edges,

test/test_intersections.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,14 @@ def test_GCA_GCA_north_pole_angled():
161161

162162
def test_GCA_edge_intersection_count():
163163

164-
from uxarray.grid.utils import _get_cartesian_face_edge_nodes
164+
from uxarray.grid.utils import _get_cartesian_face_edge_nodes_array
165165

166166
# Generate a normal face that is not crossing the antimeridian or the poles
167167
vertices_lonlat = [[29.5, 11.0], [29.5, 10.0], [30.5, 10.0], [30.5, 11.0]]
168168
vertices_lonlat = np.array(vertices_lonlat)
169169

170170
grid = ux.Grid.from_face_vertices(vertices_lonlat, latlon=True)
171-
face_edge_nodes_cartesian = _get_cartesian_face_edge_nodes(
171+
face_edge_nodes_cartesian = _get_cartesian_face_edge_nodes_array(
172172
grid.face_node_connectivity.values,
173173
grid.n_face,
174174
grid.n_max_face_edges,

uxarray/core/zonal.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numpy as np
33

44
from uxarray.grid.integrate import _zonal_face_weights, _zonal_face_weights_robust
5-
from uxarray.grid.utils import _get_cartesian_face_edge_nodes
5+
from uxarray.grid.utils import _get_cartesian_face_edge_nodes_array
66

77

88
def _compute_non_conservative_zonal_mean(uxda, latitudes, use_robust_weights=False):
@@ -17,7 +17,7 @@ def _compute_non_conservative_zonal_mean(uxda, latitudes, use_robust_weights=Fal
1717
# Create a NumPy array for storing results
1818
result = np.zeros(shape, dtype=uxda.dtype)
1919

20-
faces_edge_nodes_xyz = _get_cartesian_face_edge_nodes(
20+
faces_edge_nodes_xyz = _get_cartesian_face_edge_nodes_array(
2121
uxgrid.face_node_connectivity.values,
2222
uxgrid.n_face,
2323
uxgrid.n_max_face_nodes,

uxarray/grid/area.py

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from numba import njit
33

44
from uxarray.constants import ERROR_TOLERANCE
5-
from uxarray.grid.coordinates import _lonlat_rad_to_xyz
65

76

87
@njit(cache=True)
@@ -12,7 +11,6 @@ def calculate_face_area(
1211
z,
1312
quadrature_rule="gaussian",
1413
order=4,
15-
coords_type="spherical",
1614
latitude_adjusted_area=False,
1715
):
1816
"""Calculate area of a face on sphere.
@@ -38,9 +36,6 @@ def calculate_face_area(
3836
- Gaussian Quadrature: 1 to 10
3937
- Triangular: 1, 4, 8, 10 and 12
4038
41-
coords_type : str, optional
42-
coordinate type, default is spherical, can be cartesian also.
43-
4439
latitude_adjusted_area : bool, optional
4540
If True, performs the check if any face consists of an edge that has constant latitude, modifies the area of that face by applying the correction term due to that edge. Default is False.
4641
@@ -64,24 +59,6 @@ def calculate_face_area(
6459

6560
# num triangles is two less than the total number of nodes
6661
num_triangles = num_nodes - 2
67-
68-
# TODO: Remove/clarify option for spherical coordinates
69-
if coords_type == "spherical":
70-
# Preallocate arrays for Cartesian coordinates
71-
n_points = len(x)
72-
x_cartesian = np.empty(n_points)
73-
y_cartesian = np.empty(n_points)
74-
z_cartesian = np.empty(n_points)
75-
76-
# Convert all points to Cartesian coordinates using an explicit loop
77-
for i in range(n_points):
78-
lon_rad = np.deg2rad(x[i])
79-
lat_rad = np.deg2rad(y[i])
80-
cartesian = _lonlat_rad_to_xyz(lon_rad, lat_rad)
81-
x_cartesian[i], y_cartesian[i], z_cartesian[i] = cartesian
82-
83-
x, y, z = x_cartesian, y_cartesian, z_cartesian
84-
8562
# Using tempestremap GridElements: https://github.com/ClimateGlobalChange/tempestremap/blob/master/src/GridElements.cpp
8663
# loop through all sub-triangles of face
8764
total_correction = 0.0
@@ -198,10 +175,8 @@ def get_all_face_area_from_coords(
198175
z,
199176
face_nodes,
200177
face_geometry,
201-
dim,
202178
quadrature_rule="triangular",
203179
order=4,
204-
coords_type="spherical",
205180
latitude_adjusted_area=False,
206181
):
207182
"""Given coords, connectivity and other area calculation params, this
@@ -222,18 +197,12 @@ def get_all_face_area_from_coords(
222197
face_nodes : 2D ndarray, required
223198
node ids of each face
224199
225-
dim : int, required
226-
dimension
227-
228200
quadrature_rule : str, optional
229201
"triangular" or "gaussian". Defaults to triangular
230202
231203
order : int, optional
232204
count or order for Gaussian or spherical resp. Defaults to 4 for spherical.
233205
234-
coords_type : str, optional
235-
coordinate type, default is spherical, can be cartesian also.
236-
237206
latitude_adjusted_area : bool, optional
238207
If True, performs the check if any face consists of an edge that has constant latitude, modifies the area of that face by applying the correction term due to that edge. Default is False.
239208
@@ -255,13 +224,7 @@ def get_all_face_area_from_coords(
255224
for face_idx, max_nodes in enumerate(face_geometry):
256225
face_x = x[face_nodes[face_idx, 0:max_nodes]]
257226
face_y = y[face_nodes[face_idx, 0:max_nodes]]
258-
259-
# check if z dimension
260-
261-
if dim > 2:
262-
face_z = z[face_nodes[face_idx, 0:max_nodes]]
263-
else:
264-
face_z = face_x * 0.0
227+
face_z = z[face_nodes[face_idx, 0:max_nodes]]
265228

266229
# After getting all the nodes of a face assembled call the cal. face area routine
267230
face_area, face_jacobian = calculate_face_area(
@@ -270,7 +233,6 @@ def get_all_face_area_from_coords(
270233
face_z,
271234
quadrature_rule,
272235
order,
273-
coords_type,
274236
latitude_adjusted_area,
275237
)
276238
# store current face area

0 commit comments

Comments
 (0)