Skip to content

Error checks for area calculation #425

Closed

Description

@rajeeja

Describe the bug
Area calculation is incorrect?
For mesh gridfile_fesom = current_path / "meshfiles" / "ugrid" / "fesom" / "fesom.mesh.diag.nc"

To Reproduce
Steps to reproduce the behavior:
sum of area comes to be 9776.665489773564

Expected behavior
Some message and more checks might be needed.

Activity

  1. added
    bug
    on Aug 29, 2023
  2. self-assigned this
    on Aug 29, 2023
  3. added this to the Testing milestone on Sep 12, 2023
  4. erogluorhan commented on Feb 25, 2026

    @erogluorhan
    Member

    Is this still the case or somehow fixed in the meantime?

  5. Sevans711 commented on Jul 13, 2026

    @Sevans711
    Collaborator

    This seems fine now? On uxarray 2026.6.0, I am getting:

    import uxarray as ux
    gridpath = ... # path to `"uxarray/test/meshfiles/ugrid/fesom/fesom.mesh.diag.nc"` on my machine
    grid = ux.open_grid(gridpath)
    area = grid.calculate_total_face_area()  # area in steradians
    print(area)

    Gives 8.378036745330922. This seems reasonable to me; grid.plot() looks like this:

    Image

    I can certainly believe this grid covers roughly 67% (== area / (4 * np.pi)) of the surface.

    If this makes sense to you too please mark as closed!

  6. moved this from 📚 Backlog to 📝 To-Do in UXarray Developmenton Jul 17, 2026
  7. rajeeja commented on Jul 17, 2026

    @rajeeja
    ContributorAuthor

    @Sevans711 Confirmed — the bad value is fixed; the FESOM mesh now gives ~8.38 sr, which is correct. I'll still add the error check this issue asked for: a warning when total face area exceeds the unit-sphere area (4π), so a malformed grid can't return garbage silently. That's in #1577, which will close this issue.

  8. Sevans711 commented on Jul 20, 2026

    @Sevans711
    Collaborator

    Clarifying: the error check proposed to be added to #1577 was removed, because it was originally added in a way that does not respect grid.sphere_radius (when not on unit sphere, area can easily be larger than 4π), and in a way that adds inefficiency to every face_areas computation since face_areas doesn't otherwise require summing across all faces.

    So, what remains to close this issue? I think doing both of the following would be sufficient:

    • open a separate PR (sometime after Clean up and vectorize the face_areas API #1577 merges into main), check inside grid.calculate_total_face_areas() (which is already doing a sum across all faces) whether the result is too large, and make warning if it is. This check should compute "too large" as "larger than 4 * np.pi * grid.sphere_radius**2" not just 4π.
    • add a regression test for this fesom grid in particular, which will crash if the total area isn't close to ~8.38 sr.
  9. self-assigned this
    on Jul 20, 2026
  10. moved this from 📝 To-Do to 🏗 In progress in UXarray Developmenton Jul 22, 2026
  11. moved this from 🏗 In progress to 👀 In review in UXarray Developmenton Aug 5, 2026
  12. moved this from 👀 In review to ✅ Done in UXarray Developmenton Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bug

Type

No type

Fields

Priority

None yet

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions