Skip to content

Commit

Permalink
Preserve attributes when setting desired longitude range (#874)
Browse files Browse the repository at this point in the history
* preserve attributes when setting desired longitude range

* update grid to have correct attributes
  • Loading branch information
philipc2 authored Aug 5, 2024
1 parent 8a51db9 commit 1790e0e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 10 deletions.
Binary file modified test/meshfiles/ugrid/quad-hexagon/grid.nc
Binary file not shown.
10 changes: 1 addition & 9 deletions uxarray/conventions/ugrid.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from uxarray.constants import INT_FILL_VALUE, INT_DTYPE
from uxarray.constants import INT_FILL_VALUE

CONVENTIONS_ATTR = "UGRID-v1.0"

Expand Down Expand Up @@ -144,7 +144,6 @@
"long name": "Maps every face to its corner nodes.",
"start_index": 0,
"_FillValue": INT_FILL_VALUE,
"dtype": INT_DTYPE,
}
FACE_NODE_CONNECTIVITY_DIMS = ["n_face", "n_max_face_nodes"]

Expand All @@ -153,7 +152,6 @@
"long name": "Maps every face to its edges.",
"start_index": 0,
"_FillValue": INT_FILL_VALUE,
"dtype": INT_DTYPE,
}
FACE_EDGE_CONNECTIVITY_DIMS = [
"n_face",
Expand All @@ -165,7 +163,6 @@
"long name": "Faces that neighbor each face.",
"start_index": 0,
"_FillValue": INT_FILL_VALUE,
"dtype": INT_DTYPE,
}
FACE_FACE_CONNECTIVITY_DIMS = [
"n_face",
Expand All @@ -177,7 +174,6 @@
"cf_role": "edge_node_connectivity",
"long name": "Maps every edge to the two nodes that it connects.",
"start_index": 0,
"dtype": INT_DTYPE,
}
EDGE_NODE_CONNECTIVITY_DIMS = ["n_edge", "two"]

Expand All @@ -198,7 +194,6 @@
"long name": "Faces that neighbor each edge",
"start_index": 0,
"_FillValue": INT_FILL_VALUE,
"dtype": INT_DTYPE,
}
EDGE_FACE_CONNECTIVITY_DIMS = ["n_edge", "two"]

Expand All @@ -208,7 +203,6 @@
"long name": "Edges that neighbor each node",
"start_index": 0,
"_FillValue": INT_FILL_VALUE,
"dtype": INT_DTYPE,
}

NODE_EDGE_CONNECTIVITY_DIMS = ["n_node", "n_max_node_edges"]
Expand All @@ -218,7 +212,6 @@
"long name": "Faces that neighbor each node",
"start_index": 0,
"_FillValue": INT_FILL_VALUE,
"dtype": INT_DTYPE,
}

NODE_FACE_CONNECTIVITY_DIMS = ["n_node", "n_max_node_faces"]
Expand All @@ -227,7 +220,6 @@
N_NODES_PER_FACE_ATTRS = {
"cf_role": "n_nodes_per_face",
"long name": "Number of nodes per face",
"dtype": INT_DTYPE,
}

N_NODES_PER_FACE_DIMS = ["n_face"]
Expand Down
2 changes: 1 addition & 1 deletion uxarray/grid/coordinates.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,4 @@ def _set_desired_longitude_range(ds):
for lon_name in ["node_lon", "edge_lon", "face_lon"]:
if lon_name in ds:
if ds[lon_name].max() > 180:
ds[lon_name] = (ds[lon_name] + 180) % 360 - 180
ds[lon_name].data = (ds[lon_name].data + 180) % 360 - 180

0 comments on commit 1790e0e

Please sign in to comment.