uxarray
uxarray copied to clipboard
Support Face area calculations for sphere radius > 1
Discussed in https://github.com/UXARRAY/uxarray/discussions/1214
Originally posted by st-ncar April 18, 2025
I work with MPAS data on a sphere of radius $r_E > 1$ and look for ways to compute integrals of quantities defined at the cell centers of the primal mesh. This requires computing the face areas (either explicitly or implicitly as part of UxDataArray.integrate()) and I am not sure I fully understand the behavior of uxarray. There seem to be at least two ways to obtain the face areas:
Grid.compute_face_areas(): computes the face area from the node coordinates (spherical or Cartesian).Grid.face_areas: returnsface_areasif contained inGrid, otherwise calls the function above
Intuitively, I would expect that both methods (with either coordinate system) give the same answer. When I tested this, I got a different answer in each case:
Grid.compute_face_areas(latlon=True)seems to give the face areas on the unit sphere ($r = 1$)Grid.compute_face_areas(latlon=False)gives very small face areas (1e-16or smaller). I wasn't sure how to interpret this.Grid.face_areasseems to give the face area on the sphere with radius $r = r_E$ (perhaps these areas are read from the grid file directly?)
I can rescale the result of method 1 to recover method 3. It also seems that UxDataArray.integrate() uses method 1 internally and I have to rescale the result to get the expected integral value on a sphere with radius $r_E$.
I was wondering if someone can help me interpret the result of the 3 methods above (what I wrote are just my guesses). Also, do you have a recommendation for which method I should use? And in case the above interpretation is correct, would it be possible to make Grid.compute_face_areas() aware of Grid.attrs['sphere_radius'] so that there is no need for rescaling between method 1 and 3?