Skip to content

Commit

Permalink
Zonal face weights at constant lat (#555)
Browse files Browse the repository at this point in the history
* Initial Draft Algorithm

* Revert "Initial Draft Algorithm"

This reverts commit 99573b8.

* Initial Draft Algorithm

* Initial Draft Algorithm

* Updated documentation and comments, added test case, and updated index.rst

* updated function name

* Refactored function to get cartesian coords

* Merged main, fixed conflicts  updated doc string

* Added test, addressed review comments

* fixed pre-commit

* Updated docstring and variable names

* Initial commit, working in progress

* Codes Refractor and Docstring updates

* Update some layout

* update

* Fix the filled value case

* changes

* changes

* changes

* First draft of the function

* working on the test case

* commits

* add directed option for the gca constlat intersection

* working on it

* Change the `is_directed` default as false

* Change the `is_directed` default as false

* Fix testcase

* Finished `_get_zonal_face_weight_rad`

* Allow users to specify if the input is GCA or constLat

* Consider the equator case

* Draft complete

* structure refractor needed

* Initial commit

* Finished

* precommit

* Fix conflic

* Add docstring

* Abandon `pd.append`

* delete duplicate

* Fix testcases

* try fixing testcases

* try fixing testcases again

* try fixing testcases again

* try fixing testcases again again

* Add error-tolerence in `point_within_gca`

* pre-commit fix

* Add the `is_latlonface` flag

* Add the `is_latlonface` flag

* Try to consider about the concave face case

* WIP

* Update uxarray/grid/integrate.py

Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>

* working for merge conflict

* working for merge conflict

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* WIP

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Resolve TestFaceWeights cases

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Resolve All Testcases

* clean up

* Add doc

* fix doc

---------

Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
Co-authored-by: aazedwick <aazedwick@gmail.com>
Co-authored-by: Aaron Zedwick <95507181+aaronzedwick@users.noreply.github.com>
Co-authored-by: Orhan Eroglu <32553057+erogluorhan@users.noreply.github.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
6 people authored Apr 24, 2024
1 parent a85db05 commit dff3971
Show file tree
Hide file tree
Showing 7 changed files with 788 additions and 12 deletions.
13 changes: 13 additions & 0 deletions docs/internal_api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,19 @@ Accurate Computing Utils
utils.computing._acc_sqrt
utils.computing._split


Integration
-----------
.. autosummary::
:toctree: generated/

grid.integrate._get_zonal_faces_weight_at_constLat
grid.integrate._get_zonal_face_interval
grid.integrate._process_overlapped_intervals
grid.integrate._is_edge_gca
grid.integrate._get_faces_constLat_intersection_info


Remapping
=========

Expand Down
414 changes: 414 additions & 0 deletions test/test_integrate.py

Large diffs are not rendered by default.

10 changes: 3 additions & 7 deletions test/test_intersections.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ def test_GCA_constLat_intersections_antimeridian(self):
np.deg2rad(10.0)])
])

res = gca_constLat_intersection(GCR1_cart,
np.deg2rad(60.0),
verbose=True)
res = gca_constLat_intersection(GCR1_cart, np.sin(np.deg2rad(60.0)), verbose=True)
res_lonlat_rad = node_xyz_to_lonlat_rad(res[0].tolist())
self.assertTrue(
np.allclose(res_lonlat_rad,
Expand All @@ -119,9 +117,7 @@ def test_GCA_constLat_intersections_empty(self):
np.deg2rad(10.0)])
])

res = gca_constLat_intersection(GCR1_cart,
np.deg2rad(-10.0),
verbose=False)
res = gca_constLat_intersection(GCR1_cart, np.sin(np.deg2rad(-10.0)), verbose=False)
self.assertTrue(res.size == 0)

def test_GCA_constLat_intersections_two_pts(self):
Expand All @@ -135,5 +131,5 @@ def test_GCA_constLat_intersections_two_pts(self):

query_lat = (np.deg2rad(10.0) + max_lat) / 2.0

res = gca_constLat_intersection(GCR1_cart, query_lat, verbose=False)
res = gca_constLat_intersection(GCR1_cart, np.sin(query_lat), verbose=False)
self.assertTrue(res.shape[0] == 2)
2 changes: 2 additions & 0 deletions uxarray/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
INT_DTYPE = np.intp
INT_FILL_VALUE = np.iinfo(INT_DTYPE).min


# According to Ogita, Takeshi & Rump, Siegfried & Oishi, Shin’ichi. (2005). Accurate Sum and Dot Product.
# SIAM J. Scientific Computing. 26. 1955-1988. 10.1137/030601818.
# half of the working precision is already the most optimal value for the error tolerance,
# more tailored values will be used in the future.

ERROR_TOLERANCE = 1.0e-8

ENABLE_JIT_CACHE = True
Expand Down
2 changes: 1 addition & 1 deletion uxarray/grid/arcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def point_within_gca(pt, gca_cart, is_directed=False):

if np.isclose(GCRv0_lonlat[0], GCRv1_lonlat[0], rtol=0, atol=ERROR_TOLERANCE):
# If the pt and the GCA are on the same longitude (the y coordinates are the same)
if GCRv0_lonlat[0] == pt_lonlat[0]:
if np.isclose(GCRv0_lonlat[0], pt_lonlat[0], rtol=0, atol=ERROR_TOLERANCE):
# Now use the latitude to determine if the pt falls between the interval
return in_between(GCRv0_lonlat[1], pt_lonlat[1], GCRv1_lonlat[1])
else:
Expand Down
Loading

0 comments on commit dff3971

Please sign in to comment.