Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc2 committed Aug 8, 2024
1 parent fd1d2f8 commit 9cf7ce7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
7 changes: 0 additions & 7 deletions test/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,13 +952,6 @@ def test_populate_bounds_GCA_mix(self):
face_bounds = bounds_xarray.values
nt.assert_allclose(grid.bounds.values, expected_bounds, atol=ERROR_TOLERANCE)

def test_populate_bounds_MPAS(self):
xrds = xr.open_dataset(self.gridfile_mpas)
uxgrid = ux.Grid.from_dataset(xrds, use_dual=True)
bounds_xarray = uxgrid.bounds
pass


def test_opti_bounds(self):
uxgrid = ux.open_grid(gridfile_CSne8)
bounds = uxgrid.bounds
4 changes: 2 additions & 2 deletions uxarray/grid/arcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# from uxarray.grid.coordinates import node_xyz_to_lonlat_rad, normalize_in_place

from uxarray.grid.coordinates import _xyz_to_lonlat_rad_no_norm
from uxarray.grid.coordinates import _xyz_to_lonlat_rad_no_norm, _normalize_xyz_scalar
from uxarray.constants import ERROR_TOLERANCE

from uxarray.utils.computing import isclose, cross, dot
Expand Down Expand Up @@ -309,7 +309,7 @@ def extreme_gca_latitude(gca_cart, extreme_type):

if 0 < d_a_max < 1:
node3 = (1 - d_a_max) * n1 + d_a_max * n2
# node3 = np.array(_normalize_xyz(node3[0], node3[1], node3[2]))
node3 = np.array(_normalize_xyz_scalar(node3[0], node3[1], node3[2]))
d_lat_rad = np.arcsin(np.clip(node3[2], -1, 1))

return (
Expand Down
9 changes: 9 additions & 0 deletions uxarray/grid/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ def _normalize_xyz(
return x_norm, y_norm, z_norm


@njit
def _normalize_xyz_scalar(x: float, y: float, z: float):
denom = np.linalg.norm(np.asarray(np.array([x, y, z]), dtype=np.float64), ord=2)
x_norm = x / denom
y_norm = y / denom
z_norm = z / denom
return x_norm, y_norm, z_norm


def _populate_node_latlon(grid) -> None:
"""Populates the latitude and longitude coordinates of a Grid (`node_lon`,
`node_lat`)"""
Expand Down

0 comments on commit 9cf7ce7

Please sign in to comment.