feat: add vectorized 3D cartesian utils and polar pytests#107
feat: add vectorized 3D cartesian utils and polar pytests#107Riteesh-NITT wants to merge 1 commit intomllam:mainfrom
Conversation
|
Hi @leifdenby and @joeloskarsson, just putting this up as a Draft! This implements the vectorized spherical-to-cartesian conversions and the polar edge-case tests we discussed in #76 and #77. Hey @mandeepsingh2007, here is the math bridge for the icosahedral mesh generation. Feel free to pull this branch locally if you need to test the grid-to-mesh (g2m) mappings with your trimesh output! |
|
Hey @Riteesh-NITT , I just pulled the logic locally and ran some integration tests against the current NumPy g2m geometry we built in PR #76. The outputs from your torch implementation match the current numpy pipeline outputs down to the exact floating-point precision (max difference ~1e-8). This confirms that your PyTorch vectorization is a perfect drop-in replacement. Once we move to the HeteroData native graph loading, we can safely swap the NumPy processing out for this without breaking any downstream spatial alignments.
|
|
since this functionality is a utility being added for icosahedral meshes, which in turn was decide in today's dev meeting has gone on the roadmap for |

Describe your changes
Summary of the changes:$(x, y, z)$ . It also includes a
This PR introduces vectorized PyTorch utilities (
spherical_utils.py) to convert 2D geographic coordinates (latitude/longitude) into 3D Cartesian coordinatespytestsuite specifically validating mathematical stability at the North Pole singularity and across the anti-meridian (Date Line).Note: Hi @leifdenby and @mandeepsingh2007, following up on our thread in #76/#77! I know we are waiting on the
load_graphshim (Issue #385) to be merged before fully hooking this up, but I wanted to get these utilities up for early review. Let me know if the tensor shapes align with the native PyG pipeline you are building. I'll keep this as a Draft until the base branch is ready!Motivation and context:
When mapping 2D weather grid data to a 3D icosahedral mesh, flat lat-lon grids suffer from severe spatial distortion at the poles. This utility provides the mathematical bridge to project grid nodes onto a unit sphere in 3D space, which is an architectural prerequisite for accurate Grid-to-Mesh (g2m) distance calculations and connectivity.
Dependencies:
torchpytest(for the test suite)Issue Link
Addresses #76 and #77
Type of change
Checklist before requesting a review
pullwith--rebaseoption if possible).