Repository: UXARRAY/uxarray

Issue:
Parse Face Areas from MPAS Grids 
Most MPAS grid datasets already contain face areas, parse them at the I/O step.

Hints from issue comments:

Solution patch:
diff --git a/uxarray/io/_mpas.py b/uxarray/io/_mpas.py
index af155967e..d9f83142b 100644
--- a/uxarray/io/_mpas.py
+++ b/uxarray/io/_mpas.py
@@ -59,6 +59,9 @@ def _primal_to_ugrid(in_ds, out_ds):
     if "cellsOnCell" in in_ds:
         _parse_face_faces(in_ds, out_ds)
 
+    if "areaCell" in in_ds:
+        _parse_face_areas(in_ds, out_ds, mesh_type="primal")
+
     # set global attributes
     _parse_global_attrs(in_ds, out_ds)
 
@@ -121,6 +124,9 @@ def _dual_to_ugrid(in_ds, out_ds):
     if "dcEdge" in in_ds:
         _parse_edge_face_distances(in_ds, out_ds)
 
+    if "areaTriangle" in in_ds:
+        _parse_face_areas(in_ds, out_ds, mesh_type="dual")
+
     # set global attributes
     _parse_global_attrs(in_ds, out_ds)
 
@@ -489,6 +495,21 @@ def _parse_face_faces(in_ds, out_ds):
     )
 
 
+def _parse_face_areas(in_ds, out_ds, mesh_type):
+    """Parses the face area for either a primal or dual grid."""
+
+    if mesh_type == "primal":
+        face_area = in_ds["areaCell"].data
+    else:
+        face_area = in_ds["areaTriangle"].data
+
+    out_ds["face_areas"] = xr.DataArray(
+        data=face_area,
+        dims=descriptors.FACE_AREAS_DIMS,
+        attrs=descriptors.FACE_AREAS_ATTRS,
+    )
+
+
 def _replace_padding(verticesOnCell, nEdgesOnCell):
     """Replaces the padded values in verticesOnCell defined by nEdgesOnCell
     with a fill-value.


Test patch:
diff --git a/test/test_mpas.py b/test/test_mpas.py
index a4a678de7..5833e0f85 100644
--- a/test/test_mpas.py
+++ b/test/test_mpas.py
@@ -132,8 +132,11 @@ def test_set_attrs(self):
         for mpas_attr in expected_attrs:
             assert mpas_attr in uxgrid._ds.attrs
 
-    def test_face_mask(self):
-        primal_uxgrid = ux.open_grid(self.mpas_ocean_mesh, use_dual=False)
-        dual_uxgrid = ux.open_grid(self.mpas_ocean_mesh, use_dual=True)
+    def test_face_area(self):
+        """Tests the parsing of face areas for MPAS grids."""
 
-        pass
+        uxgrid_primal = ux.open_grid(self.mpas_grid_path, use_dual=False)
+        uxgrid_dual = ux.open_grid(self.mpas_grid_path, use_dual=True)
+
+        assert "face_areas" in uxgrid_primal._ds
+        assert "face_areas" in uxgrid_dual._ds