Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute Grid Centerpoint using Welzl's algorithm #811

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
60a2cbb
o #803 initial implementation of Welzl's algorithm to calculate grid …
rajeeja Jun 11, 2024
3c41af3
o Update grid class and add asserts for test
rajeeja Jun 18, 2024
5307806
Merge branch 'main' into rajeeja/welzl
aaronzedwick Jun 19, 2024
33c445f
o typo fix
rajeeja Jun 19, 2024
571986a
Merge branch 'rajeeja/welzl' of github.com:UXARRAY/uxarray into rajee…
rajeeja Jun 19, 2024
f926928
Merge branch 'main' into rajeeja/welzl
rajeeja Jun 25, 2024
9b3f066
o overhaul to not use tuples and go with numpy array, document and fi…
rajeeja Jun 26, 2024
cb5b380
Merge branch 'main' into rajeeja/welzl
rajeeja Jun 26, 2024
504bc08
o Conform to formatting standards
rajeeja Jun 26, 2024
9462e49
Merge branch 'main' into rajeeja/welzl
rajeeja Jun 27, 2024
c62d2b7
o fix bugs that reversed the coordinate ordering
rajeeja Jun 29, 2024
d117413
Merge branch 'main' into rajeeja/welzl
rajeeja Jul 2, 2024
d9a0823
Merge branch 'main' into rajeeja/welzl
philipc2 Jul 2, 2024
81710ba
Merge branch 'main' into rajeeja/welzl
philipc2 Jul 3, 2024
d09499c
o Move some fns from coordinates.py to utils as they caused circular …
rajeeja Jul 9, 2024
8ffbe93
Merge branch 'main' into rajeeja/welzl
rajeeja Jul 9, 2024
3962433
Merge branch 'rajeeja/welzl' of github.com:UXARRAY/uxarray into rajee…
rajeeja Jul 9, 2024
030f9f8
Merge branch 'main' into rajeeja/welzl
rajeeja Jul 17, 2024
cbb2c37
Merge branch 'main' into rajeeja/welzl
philipc2 Aug 1, 2024
478f99f
add benchmark for faceLatLon construction
philipc2 Aug 2, 2024
277b1ce
fix face nodes typo
philipc2 Aug 2, 2024
68edd31
fix face nodes typo
philipc2 Aug 2, 2024
c580465
o Remove new properties _ctrpt infavor of using regular face lat/lon …
rajeeja Aug 6, 2024
02472db
Merge branch 'main' into rajeeja/welzl
philipc2 Aug 6, 2024
d59248f
o Fix conflicts and use utils to avoid circular dependencies
rajeeja Aug 26, 2024
b73fb31
o precommit
rajeeja Aug 26, 2024
4f65cb8
o reduce some python-level loop overhead, use zip and some list compr…
rajeeja Aug 26, 2024
f5bd37b
o Fix structure, numba causes issues with recursive functions, but th…
rajeeja Aug 27, 2024
0be7cfd
o Modify the recursion logic for Numba compatibility, works 3-10x faster
rajeeja Aug 27, 2024
d77e726
o Try to get the codecov higher, add internal function tests
rajeeja Aug 27, 2024
f5d514d
Merge branch 'main' into rajeeja/welzl
philipc2 Aug 28, 2024
5baa0e0
Merge branch 'main' into rajeeja/welzl
rajeeja Aug 28, 2024
50cff16
Merge branch 'main' into rajeeja/welzl
philipc2 Aug 28, 2024
4d0bb17
Merge branch 'main' into rajeeja/welzl
rajeeja Aug 30, 2024
b263cb6
Merge branch 'main' into rajeeja/welzl
rajeeja Sep 2, 2024
80de6bd
Merge branch 'main' into rajeeja/welzl
philipc2 Sep 4, 2024
1a18530
o Try to include inside funcs
rajeeja Sep 4, 2024
38b559d
Merge branch 'main' into rajeeja/welzl
rajeeja Sep 10, 2024
67e3de3
o call cartesian average instead of average add more doc
rajeeja Sep 10, 2024
0b9f5b1
o Fix conflicts
rajeeja Sep 12, 2024
fcc22c1
o Add return doc
rajeeja Sep 12, 2024
ac8e099
o Add return test for doc
rajeeja Sep 13, 2024
6cac65b
Merge branch 'main' into rajeeja/welzl
erogluorhan Sep 15, 2024
dba53dc
o fix text
rajeeja Sep 16, 2024
ecc0fa0
o Introduce circular dependency issue
rajeeja Sep 16, 2024
3531d5c
Merge branch 'main' into rajeeja/welzl
rajeeja Sep 17, 2024
4d6014a
Merge branch 'main' into rajeeja/welzl
philipc2 Sep 18, 2024
cc330d4
Update benchmarks/mpas_ocean.py
rajeeja Sep 19, 2024
1744a30
Update benchmarks/mpas_ocean.py
rajeeja Sep 19, 2024
0fc7b3f
Merge branch 'main' into rajeeja/welzl
rajeeja Sep 19, 2024
57e3112
o Fix imports and benchmarks
rajeeja Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion test/test_centroids.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import numpy.testing as nt
import uxarray as ux
from pathlib import Path
from uxarray.grid.coordinates import _populate_face_centroids, _populate_edge_centroids, _normalize_xyz
from uxarray.grid.coordinates import _populate_face_centroids, _populate_edge_centroids, _populate_face_centerpoints
from uxarray.grid.utils import _normalize_xyz

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

Expand Down Expand Up @@ -107,3 +108,18 @@ def test_edge_centroids_from_mpas(self):

nt.assert_array_almost_equal(expected_edge_lon, computed_edge_lon)
nt.assert_array_almost_equal(expected_edge_lat, computed_edge_lat)

def test_face_centerpoint(self):
"""Use points from an actual spherical face and get the centerpoint."""

points = np.array([(-35.26438968, -45.0), (-36.61769496, -42.0), (-33.78769181, -42.0), (-32.48416571, -45.0)])
uxgrid = ux.open_grid(points, latlon=True)
_populate_face_centerpoints(uxgrid)

# the expected centerpoint should be close to centroid for this case
ctr_lon = uxgrid.face_lon.values[0]
ctr_lat = uxgrid.face_lat.values[0]

# Test the values of the calculated centerpoint, giving high tolerance of one decimal place
nt.assert_array_almost_equal(ctr_lon, uxgrid.face_lon_ctrpt.values[0], decimal=1)
nt.assert_array_almost_equal(ctr_lat, uxgrid.face_lat_ctrpt.values[0], decimal=1)
2 changes: 1 addition & 1 deletion test/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from uxarray.grid.connectivity import _replace_fill_values
from uxarray.constants import INT_DTYPE, INT_FILL_VALUE

from uxarray.grid.coordinates import _lonlat_rad_to_xyz, _normalize_xyz, _xyz_to_lonlat_rad
from uxarray.grid.utils import _lonlat_rad_to_xyz, _normalize_xyz, _xyz_to_lonlat_rad
from uxarray.grid.arcs import point_within_gca, _angle_of_2_vectors, in_between
from uxarray.grid.utils import _get_cartesian_face_edge_nodes, _get_lonlat_rad_face_edge_nodes
from uxarray.grid.geometry import _pole_point_inside_polygon
Expand Down
2 changes: 1 addition & 1 deletion 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, _normalize_xyz
from uxarray.grid.utils import _xyz_to_lonlat_rad, _normalize_xyz
from uxarray.constants import ERROR_TOLERANCE


Expand Down
2 changes: 1 addition & 1 deletion uxarray/grid/area.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from uxarray.grid.coordinates import _lonlat_rad_to_xyz
from uxarray.grid.utils import _lonlat_rad_to_xyz

from numba import njit, config
from uxarray.constants import ENABLE_JIT_CACHE, ENABLE_JIT
Expand Down
Loading
Loading