Skip to content

Commit

Permalink
remove left-over TODO and slight cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc2 committed Sep 15, 2023
1 parent 5ecdb1d commit 063375e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
1 change: 0 additions & 1 deletion uxarray/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ def parsed_attrs(self) -> dict:
"""Dictionary of parsed attributes from the source grid."""
return self._ds.attrs

# TODO: deprecate
@property
def Mesh2(self) -> xr.DataArray:
"""UGRID Attribute ``Mesh2``, which indicates the topology data of a 2D
Expand Down
7 changes: 3 additions & 4 deletions uxarray/io/_mpas.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,10 +396,9 @@ def _read_mpas(ext_ds, use_dual=False):

# convert dual-mesh to UGRID
if use_dual:
ugrid_mapping = _dual_to_ugrid(ext_ds, ds)
source_dim_map = _dual_to_ugrid(ext_ds, ds)
# convert primal-mesh to UGRID
else:
ugrid_mapping = _primal_to_ugrid(ext_ds, ds)
source_dim_map = _primal_to_ugrid(ext_ds, ds)

# TODO: Return Original Variable Mapping to UGRID
return ds, ugrid_mapping
return ds, source_dim_map
6 changes: 3 additions & 3 deletions uxarray/io/_scrip.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def _read_scrip(ext_ds):

try:
# If not ugrid compliant, translates scrip to ugrid conventions
unq_inv = _to_ugrid(ext_ds, ds)
source_dims_dict = _to_ugrid(ext_ds, ds)

# Add necessary UGRID attributes to new dataset
ds["Mesh2"] = xr.DataArray(
Expand All @@ -146,8 +146,8 @@ def _read_scrip(ext_ds):
"Variables not in recognized SCRIP form. Please refer to",
"https://earthsystemmodeling.org/docs/release/ESMF_6_2_0/ESMF_refdoc/node3.html#SECTION03024000000000000000",
"for more information on SCRIP Grid file formatting")
# TODO: Original Variable Names
return ds, unq_inv

return ds, source_dims_dict


def _encode_scrip(mesh2_face_nodes, mesh2_node_x, mesh2_node_y, face_areas):
Expand Down
22 changes: 10 additions & 12 deletions uxarray/io/_ugrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@ def _read_ugrid(xr_ds):
"""

source_dims_dict = {}

# TODO: Standardized UGRID Variable Names (Mesh2_node_x, etc)

# TODO: obtain and change to Mesh2 construct, see Issue #27

# get the data variable name that has attribute "cf_role" set to "mesh_topology"
# this is the base xarray.DataArray name
base_xarray_var = list(
xr_ds.filter_by_attrs(cf_role="mesh_topology").keys())[0]
# TODO: Dataset includes more than just coordinates and face nodes, handle
# TODO: Allow for parsing datasets with more than just coordinates and face nodes

xr_ds = xr_ds.rename({base_xarray_var: "Mesh2"})

Expand Down Expand Up @@ -50,14 +47,15 @@ def _read_ugrid(xr_ds):
xr_ds["Mesh2_face_nodes"].dims[1]: "nMaxMesh2_face_nodes"
})

if len(coord_names) == 2:
# set coordinates
xr_ds = xr_ds.set_coords(["Mesh2_node_x", "Mesh2_node_y"])
else:
xr_ds = xr_ds.set_coords(
[["Mesh2_node_x", "Mesh2_node_y",
"Mesh2_node_z"] # TODO: remove Mesh2_node_z
])
xr_ds = xr_ds.set_coords(["Mesh2_node_x", "Mesh2_node_y"])
# if len(coord_names) == 2:
# # set coordinates
# xr_ds = xr_ds.set_coords(["Mesh2_node_x", "Mesh2_node_y"])
# else:
# xr_ds = xr_ds.set_coords(
# [["Mesh2_node_x", "Mesh2_node_y",
# "Mesh2_node_z"] # TODO: remove Mesh2_node_z
# ])

# standardize fill values and data type for face nodes
xr_ds = _standardize_fill_values(xr_ds)
Expand Down

0 comments on commit 063375e

Please sign in to comment.