Proposed new feature or change:
The public-facing API for Grid face areas is now inconsistent in its support for quadrature kwargs like quadrature_rule and order. The calculate_total_face_area() method supports these kwargs, but the only public way to get face areas (Grid.face_areas property) does not support them. Related: #1567, #1568.
Suggested fix: un-deprecate and improve the public-facing compute_face_areas() method. This would provide public support for quadrature kwargs. The public method was originally deprecated in #1379; pinging @rajeeja and @erogluorhan who worked on that PR. More thoughts here:
- Currently, that method returns (face_areas, jacobian); I would suggest to instead just return face_areas by default, since the method name does not mention jacobian. We could adopt numpy style (e.g. see docstring for np.unique) by adding an optional kwarg like
def compute_face_areas(..., return_jacobian=False).
- (new feature) Maybe promote the return type to be UxDataArray (with self as the result.uxgrid) by default, or at least provide a flag to enable that, instead of returning numpy array? This would make it easy to visualize the result!
- Remove
_compute_face_areas() (use public method instead) or rename it to _compute_face_areas_and_jacobian() since it also returns the jacobian.
Additional suggestions / questions:
- Keep the note in
compute_face_areas() docstring suggesting to use the face_areas property instead for caching; clarify this note is only relevant if using default kwargs.
- Clarify in
face_areas property docstring that compute_face_areas() can be used to get result with adjusted quadrature behavior.
- Improve documentation for kwargs:
quadrature_rule, order, and latitude_adjusted_area. Minimum: quadrature_rule and order should specify what options are supported. Ideal: explain what each of these things actually means, either directly or by linking to a paper or online documentation somewhere. E.g., what is a quadrature rule? What does "corrects the area of the faces accounting for lines of constant latitude" actually mean?
- Why do we provide
calculate_total_face_area() when it is just np.sum(grid.compute_face_areas()) (or np.sum(grid.face_areas) if using default kwargs)? For me personally, the easiest thought process goes like: "I want total face area --> I should get face areas, then sum them." The existence of calculate_total_face_area() adds work, because when I see it I also think "wait, should I be using that method instead? Is there some quirk to getting the total area such that np.sum() isn't good enough?" until I inspect and see it really is just sum(). I would suggest to remove this method, or at least add near the top of its docstring something like "equivalent to grid.compute_face_areas().sum()"
- Should the method
get_all_face_area_from_coords be marked as private (i.e., leading underscore)? It doesn't seem to appear on the public uxarray docs, and it seems to be very low-level (inputs are x, y, z, face_nodes, face_geometry). Similarly, should the other methods in grid/area.py by marked as private?
Proposed new feature or change:
The public-facing API for Grid face areas is now inconsistent in its support for quadrature kwargs like
quadrature_ruleandorder. Thecalculate_total_face_area()method supports these kwargs, but the only public way to get face areas (Grid.face_areasproperty) does not support them. Related: #1567, #1568.Suggested fix: un-deprecate and improve the public-facing
compute_face_areas()method. This would provide public support for quadrature kwargs. The public method was originally deprecated in #1379; pinging @rajeeja and @erogluorhan who worked on that PR. More thoughts here:def compute_face_areas(..., return_jacobian=False)._compute_face_areas()(use public method instead) or rename it to_compute_face_areas_and_jacobian()since it also returns the jacobian.Additional suggestions / questions:
compute_face_areas()docstring suggesting to use theface_areasproperty instead for caching; clarify this note is only relevant if using default kwargs.face_areasproperty docstring thatcompute_face_areas()can be used to get result with adjusted quadrature behavior.quadrature_rule,order, andlatitude_adjusted_area. Minimum: quadrature_rule and order should specify what options are supported. Ideal: explain what each of these things actually means, either directly or by linking to a paper or online documentation somewhere. E.g., what is a quadrature rule? What does "corrects the area of the faces accounting for lines of constant latitude" actually mean?calculate_total_face_area()when it is justnp.sum(grid.compute_face_areas())(ornp.sum(grid.face_areas)if using default kwargs)? For me personally, the easiest thought process goes like: "I want total face area --> I should get face areas, then sum them." The existence ofcalculate_total_face_area()adds work, because when I see it I also think "wait, should I be using that method instead? Is there some quirk to getting the total area such that np.sum() isn't good enough?" until I inspect and see it really is just sum(). I would suggest to remove this method, or at least add near the top of its docstring something like "equivalent togrid.compute_face_areas().sum()"get_all_face_area_from_coordsbe marked as private (i.e., leading underscore)? It doesn't seem to appear on the public uxarray docs, and it seems to be very low-level (inputs are x, y, z, face_nodes, face_geometry). Similarly, should the other methods ingrid/area.pyby marked as private?