Skip to content

warn if calculate_total_face_area() too large; add FESOM areas regression test - #1649

Open
Sevans711 wants to merge 2 commits into
mainfrom
sevans/area-error-checks
Open

warn if calculate_total_face_area() too large; add FESOM areas regression test#1649
Sevans711 wants to merge 2 commits into
mainfrom
sevans/area-error-checks

Conversation

@Sevans711

Copy link
Copy Markdown
Collaborator

Closes #425

Overview

As discussed in thread in #425, the issue initially reported there has since been fixed by other changes. This PR adds a regression test (ensuring the total area for this FESOM grid is close to ~8.38 sr).

It also adds a warning to calculate_total_face_areas() if the result is larger than the total area of the sphere, to avoid silently returning wrong answers on malformed grids. It also updates the docstring for that function to clarify the warning might be raised.

Finally, a slight addition beyond just solving 425: updates the calculate_total_face_areas() docstring to clarify the actual behavior: it is not actually always equivalent to compute_face_areas().sum(). Specifically, for HEALPix grids, when using default values for all arguments, it is equivalent to face_areas.sum() (which respects HEALPix equal areas) instead.

Did not add any CI tests for this warning… please let me know if you think a regression test is necessary for it. Tested locally by temporarily locally adding result = result * 1.5 near the end of calculate_total_face_areas(), to ensure bad results actually lead to raising warning and failing FESOM area regression test.

PR Checklist

General

  • An issue is created and linked
  • Added appropriate labels (if your uxarray repo permissions allow it)
  • Filled out Overview and Expected Usage (if applicable) sections

Testing & Benchmarking

  • [N/A] Adequate tests are created if there is new functionality
  • Tests are not too basic (such as simply calling a function and nothing else)
  • Tests cover all major paths in your new functions
  • [N/A] If this PR could affect performance, ran ASV benchmarks and confirmed they show expected behavior (add a new benchmark if necessary)

Documentation

  • [N/A] Docstrings have been added to all new functions
  • Docstrings have been updated with any function changes
  • [N/A] User (public) functions have been added to docs/api.rst
  • [N/A] Internal (private) function names start with an underscore (_)

@Sevans711 Sevans711 added the testing Test Cases label Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Test Cases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error checks for area calculation

1 participant