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

DRAFT: Bilinear Remapping #1016

Draft
wants to merge 110 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
5a4e46d
Added dual mesh initial support
aaronzedwick Jul 17, 2024
058662b
Updated Mesh Construction Method
aaronzedwick Jul 19, 2024
c2d2ab7
Merge branch 'main' into zedwick/dual_mesh
aaronzedwick Jul 19, 2024
5890270
Removed Old Files
aaronzedwick Jul 19, 2024
96a61b8
Merge branch 'zedwick/dual_mesh' of https://github.com/UXARRAY/uxarra…
aaronzedwick Jul 19, 2024
6b2468b
Updated API added comprehensive test
aaronzedwick Jul 22, 2024
5d1f918
Fixed pre-commit
aaronzedwick Jul 22, 2024
cd2f643
Merge branch 'main' into zedwick/dual_mesh
philipc2 Jul 23, 2024
8d61fe9
optimize code
philipc2 Jul 24, 2024
39a0902
update dual mesh construction and duplicate node validation
philipc2 Jul 25, 2024
09efe64
progress on migrating implementation to Grid
philipc2 Jul 25, 2024
fe221f7
Testing Notebook
aaronzedwick Jul 26, 2024
eea2157
Update Untitled.ipynb
aaronzedwick Jul 26, 2024
39d43b1
Updated Notebook
aaronzedwick Jul 26, 2024
366a5f7
Update dual-mesh.ipynb
aaronzedwick Jul 26, 2024
098ef2b
Update Notebook
aaronzedwick Jul 26, 2024
f223941
Update docs
aaronzedwick Jul 26, 2024
75b6f65
Update dual-mesh.ipynb
aaronzedwick Jul 26, 2024
b628c8e
Merge branch 'main' into zedwick/dual_mesh
philipc2 Jul 29, 2024
1dffe37
Updated Merge Duplicate Nodes and cleaned up code
aaronzedwick Jul 29, 2024
62291c5
Added Duplicate Nodes Test
aaronzedwick Aug 2, 2024
24a7ece
Merge branch 'main' into zedwick/dual_mesh
aaronzedwick Aug 2, 2024
914db53
Duplicate nodes error, updated index, fix codecov,
aaronzedwick Aug 2, 2024
b01756a
Merge branch 'zedwick/dual_mesh' of https://github.com/UXARRAY/uxarra…
aaronzedwick Aug 2, 2024
2494008
Fixed pre-commit
aaronzedwick Aug 2, 2024
7c91d52
fixed duplicate check
aaronzedwick Aug 2, 2024
9d880f9
Merge branch 'main' into zedwick/dual_mesh
aaronzedwick Aug 6, 2024
abf7556
Moved to dual.py remove duplication merge
aaronzedwick Aug 6, 2024
fe909af
Updated API and Benchmarks
aaronzedwick Aug 6, 2024
dbb935c
Updated face construction and ordering
aaronzedwick Aug 6, 2024
314e877
Optimization and clean up
aaronzedwick Aug 6, 2024
558f871
Update dual-mesh.ipynb
aaronzedwick Aug 7, 2024
0b22e4f
Updated userguide.rst
aaronzedwick Aug 7, 2024
5dd4f81
Merge branch 'main' into zedwick/dual_mesh
aaronzedwick Aug 9, 2024
dd354e3
Fixed pre-commit
aaronzedwick Aug 9, 2024
7cbecdf
Update docs/userguide.rst
aaronzedwick Aug 12, 2024
c87554b
Added docstrings
aaronzedwick Aug 16, 2024
7f8c50e
Update dual.py
aaronzedwick Aug 16, 2024
692cb03
Merge branch 'main' into zedwick/dual_mesh
aaronzedwick Aug 16, 2024
8778b80
Merge branch 'main' into zedwick/dual_mesh
philipc2 Aug 16, 2024
cbfdb74
Added dual mesh support of DataArrays
aaronzedwick Aug 20, 2024
7a02c55
Fixed asv config file
aaronzedwick Aug 20, 2024
65c7b5a
Added name to data array
aaronzedwick Aug 21, 2024
e3bdd6a
Fixed constructed node face connectivity error
aaronzedwick Aug 21, 2024
374770e
Updated user guide
aaronzedwick Aug 22, 2024
acc4a42
Fixed docs
aaronzedwick Aug 22, 2024
a73a2de
Removed method parameter
aaronzedwick Sep 3, 2024
68a082d
Added support for UxDatasets
aaronzedwick Sep 4, 2024
9219579
Update dual user guide
aaronzedwick Sep 4, 2024
9657d8e
Update index.rst
aaronzedwick Sep 4, 2024
4e039bc
Updated Test Cases
aaronzedwick Sep 4, 2024
c0feb34
Merge branch 'main' into zedwick/dual_mesh
aaronzedwick Sep 4, 2024
cda5e96
Update test_grid.py
aaronzedwick Sep 4, 2024
0667e0d
Merge branch 'zedwick/dual_mesh' of https://github.com/UXARRAY/uxarra…
aaronzedwick Sep 4, 2024
f690a3e
Updated colormaps
aaronzedwick Sep 4, 2024
25ee56e
pre-commit fix
aaronzedwick Sep 4, 2024
bdadd23
Notebook Update
aaronzedwick Sep 5, 2024
4ff128d
Update dual-mesh.ipynb
aaronzedwick Sep 5, 2024
c1bd224
Merge branch 'main' into zedwick/dual_mesh
aaronzedwick Sep 10, 2024
2db6390
Update dual-mesh.ipynb
aaronzedwick Sep 10, 2024
e1d9621
Fixed Dimension Bug
aaronzedwick Sep 10, 2024
a870c20
Merge branch 'main' into zedwick/dual_mesh
aaronzedwick Sep 10, 2024
3dcc6f5
Added bilinear.py
aaronzedwick Sep 10, 2024
eeb6c62
Fixed pre-commit
aaronzedwick Sep 10, 2024
dd13f3c
Merge branch 'zedwick/dual_mesh' into zedwick/bilinear-remapping
aaronzedwick Sep 10, 2024
4645083
Added bilinear weights function
aaronzedwick Sep 11, 2024
72de87a
Working on fixing errors
aaronzedwick Sep 17, 2024
324d043
Fixed bilinear weights calculation error
aaronzedwick Sep 17, 2024
12e2f1c
Pre-commit run
aaronzedwick Sep 19, 2024
d1c5c92
Added cartesian support and node edge support
aaronzedwick Sep 19, 2024
9bdce8a
Update bilinear.py
aaronzedwick Sep 20, 2024
cb3c9e8
Testing Notebook
aaronzedwick Sep 20, 2024
a4f5cbc
initial code for finding polygon containing point
aaronzedwick Sep 28, 2024
5e12a05
Added `get_max_face_radius`
aaronzedwick Oct 9, 2024
6a21586
Updated tolerance
aaronzedwick Oct 10, 2024
9f06371
Updated support for mesh with holes and spherical coords
aaronzedwick Oct 14, 2024
786c914
pre-commit
aaronzedwick Oct 14, 2024
1db878a
Initial point in triangle
aaronzedwick Oct 17, 2024
1ffc62c
Merge branch 'main' into zedwick/bilinear-remapping
aaronzedwick Oct 17, 2024
95b481f
Fixed merge issues
aaronzedwick Oct 17, 2024
3b79afb
Remove leftover checkpoint
aaronzedwick Oct 17, 2024
1c85080
Updated test cases
aaronzedwick Oct 17, 2024
e16e25a
Merge branch 'zedwick/bilinear-remapping' of https://github.com/UXARR…
aaronzedwick Oct 17, 2024
c0587f4
Fixed notebook, added numba speedup
aaronzedwick Oct 17, 2024
18a6e30
Update remapping.ipynb
aaronzedwick Oct 17, 2024
bee4b5c
Merge branch 'main' into zedwick/bilinear-remapping
philipc2 Oct 23, 2024
75b88e8
Initial work
aaronzedwick Oct 24, 2024
a3fbad5
Testing point in polygon
aaronzedwick Oct 29, 2024
2e296d4
Merge branch 'zedwick/point-in-polygon' into zedwick/bilinear-remapping
aaronzedwick Oct 29, 2024
998aa99
Switched to projection method
aaronzedwick Nov 5, 2024
7d7be67
Merge branch 'main' into zedwick/point-in-polygon
aaronzedwick Nov 5, 2024
e38ca24
Updated test cases, fixed spherical bug
aaronzedwick Nov 6, 2024
92bab4a
Added test cases
aaronzedwick Nov 6, 2024
354f821
Increased performance
aaronzedwick Nov 6, 2024
5fc59aa
Update test_geometry.py
aaronzedwick Nov 7, 2024
c4a4979
Merge branch 'main' into zedwick/point-in-polygon
aaronzedwick Nov 7, 2024
3b09973
updated api
aaronzedwick Nov 7, 2024
f7cb51c
Merge branch 'zedwick/point-in-polygon' of https://github.com/UXARRAY…
aaronzedwick Nov 7, 2024
3518e91
Merge branch 'main' into zedwick/bilinear-remapping
aaronzedwick Nov 7, 2024
140fa95
Merge branch 'zedwick/bilinear-remapping' of https://github.com/UXARR…
aaronzedwick Nov 7, 2024
4baf718
Update bilinear.py
aaronzedwick Nov 7, 2024
f1e36e9
Merge branch 'zedwick/point-in-polygon' into zedwick/bilinear-remapping
aaronzedwick Nov 7, 2024
b4b73d7
Updating search
aaronzedwick Nov 12, 2024
9302919
Update geometry.py
aaronzedwick Nov 19, 2024
e411553
Fixed bilinear calculation
aaronzedwick Nov 21, 2024
4d009d6
Added edge case checks
aaronzedwick Nov 27, 2024
634f92e
Delete leftover file
aaronzedwick Nov 27, 2024
856451f
Merge branch 'main' into zedwick/bilinear-remapping
aaronzedwick Dec 16, 2024
02f44a8
Updated polygon search handling
aaronzedwick Dec 16, 2024
6fae82d
Added support for non triangular dual mesh faces
aaronzedwick Dec 16, 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
3 changes: 3 additions & 0 deletions docs/internal_api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ Geometry
grid.geometry._populate_face_latlon_bound
grid.geometry._populate_bounds
grid.geometry._construct_hole_edge_indices
grid.geometry._point_to_plane
grid.geometry._point_to_sphere
grid.geometry._ray_casting_plane

Coordinates
-----------
Expand Down
1,094 changes: 1,086 additions & 8 deletions docs/user-guide/remapping.ipynb

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions test/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from uxarray.grid.coordinates import _populate_node_latlon, _lonlat_rad_to_xyz, _normalize_xyz, _xyz_to_lonlat_rad
from uxarray.grid.arcs import extreme_gca_latitude, _extreme_gca_latitude_cartesian
from uxarray.grid.utils import _get_cartesian_face_edge_nodes, _get_lonlat_rad_face_edge_nodes
from uxarray.grid.geometry import _populate_face_latlon_bound, _populate_bounds, _pole_point_inside_polygon_cartesian, stereographic_projection, inverse_stereographic_projection

from uxarray.grid.geometry import _populate_face_latlon_bound, _populate_bounds, _pole_point_inside_polygon_cartesian, stereographic_projection, inverse_stereographic_projection


current_path = Path(os.path.dirname(os.path.realpath(__file__)))
Expand All @@ -30,6 +30,7 @@
grid_quad_hex = current_path / "meshfiles" / "ugrid" / "quad-hexagon" / "grid.nc"
grid_geoflow = current_path / "meshfiles" / "ugrid" / "geoflow-small" / "grid.nc"
grid_mpas = current_path / "meshfiles" / "mpas" / "QU" / "oQU480.231010.nc"
grid_mpas_2 = current_path / "meshfiles" / "mpas" / "QU" / "mesh.QU.1920km.151026.nc"

# List of grid files to test
grid_files_latlonBound = [grid_quad_hex, grid_geoflow, gridfile_CSne8, grid_mpas]
Expand Down Expand Up @@ -81,7 +82,7 @@ def test_pole_point_inside_polygon_from_vertice_north(self):
[vertices[1], vertices[2]],
[vertices[2], vertices[3]],
[vertices[3], vertices[0]]])

print(face_edge_cart)
# Check if the North pole is inside the polygon
result = _pole_point_inside_polygon_cartesian(
'North', face_edge_cart)
Expand Down
12 changes: 11 additions & 1 deletion test/test_remap.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
dsfile_v2_geoflow = current_path / "meshfiles" / "ugrid" / "geoflow-small" / "v2.nc"
dsfile_v3_geoflow = current_path / "meshfiles" / "ugrid" / "geoflow-small" / "v3.nc"
mpasfile_QU = current_path / "meshfiles" / "mpas" / "QU" / "mesh.QU.1920km.151026.nc"
mpasfile_QU_2 = current_path / "meshfiles" / "mpas" / "QU" / "oQU480.231010.nc"


class TestNearestNeighborRemap(TestCase):
Expand Down Expand Up @@ -224,7 +225,6 @@ def test_preserve_coordinates(self):
assert "time" in res.coords



class TestInverseDistanceWeightedRemapping(TestCase):
"""Testing for inverse distance weighted remapping."""

Expand Down Expand Up @@ -429,3 +429,13 @@ def test_value_errors(self):
destination_grid=destination_grid,
remap_to="nodes", power=6
)


class TestBilinearRemapping(TestCase):

def test_uxda_remap(self):
source_uxds = ux.open_dataset(mpasfile_QU, mpasfile_QU)
destination = ux.open_dataset(mpasfile_QU_2, mpasfile_QU_2)

bilinear_remap = source_uxds['latVertex'].remap.bilinear(destination.uxgrid, remap_to='face centers',
coord_type='spherical')
3 changes: 3 additions & 0 deletions uxarray/grid/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
)
from uxarray.grid.arcs import extreme_gca_latitude, point_within_gca
from uxarray.grid.coordinates import _xyz_to_lonlat_rad

from uxarray.grid.intersections import gca_gca_intersection
from uxarray.grid.utils import (
_get_cartesian_face_edge_nodes,
Expand Down Expand Up @@ -1236,11 +1237,13 @@ def _populate_face_latlon_bound(
face_latlon_array = insert_pt_in_latlonbox(
face_latlon_array, np.array([lat_min, node1_lon_rad])
)

face_latlon_array[0, 1] = math.pi / 2 # Upper latitude bound
else:
face_latlon_array = insert_pt_in_latlonbox(
face_latlon_array, np.array([lat_max, node1_lon_rad])
)

face_latlon_array[0, 0] = -math.pi / 2 # Lower latitude bound

# Adjust longitude bounds globally if the pole is centrally inside the polygon
Expand Down
Loading
Loading