Skip to content

Commit 483e7f7

Browse files
committed
o Fix errors found in new test_ugrid changes, bug was in _ugrid.py - shouldn't add face/edge coordinates when they don't exist
1 parent f7ff1ba commit 483e7f7

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

uxarray/io/_exodus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,15 @@ def _encode_exodus(ds, outfile=None):
150150
now = datetime.now()
151151
date = now.strftime("%Y:%m:%d")
152152
time = now.strftime("%H:%M:%S")
153-
fp_word = np.int32(8) # Assuming INT_DTYPE is int32 based on usage
153+
fp_word = INT_DTYPE(8)
154154
exo_version = np.float32(5.0)
155155
api_version = np.float32(5.0)
156156

157157
exo_ds.attrs = {
158158
"api_version": api_version,
159159
"version": exo_version,
160160
"floating_point_word_size": fp_word,
161-
"file_size": 0, # Will be 0 for an in-memory representation
161+
"file_size": 0,
162162
}
163163

164164
if outfile:

uxarray/io/_ugrid.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ def _read_ugrid(ds):
2020
node_lon_name: ugrid.NODE_COORDINATES[0],
2121
node_lat_name: ugrid.NODE_COORDINATES[1],
2222
}
23-
24-
if "edge_coordinates" in ds["grid_topology"].attrs:
25-
# get the names of edge_lon and edge_lat, if they exist
26-
edge_lon_name, edge_lat_name = ds["grid_topology"].edge_coordinates.split()
27-
coord_dict[edge_lon_name] = ugrid.EDGE_COORDINATES[0]
28-
coord_dict[edge_lat_name] = ugrid.EDGE_COORDINATES[1]
29-
30-
if "face_coordinates" in ds["grid_topology"].attrs:
31-
# get the names of face_lon and face_lat, if they exist
32-
face_lon_name, face_lat_name = ds["grid_topology"].face_coordinates.split()
33-
coord_dict[face_lon_name] = ugrid.FACE_COORDINATES[0]
34-
coord_dict[face_lat_name] = ugrid.FACE_COORDINATES[1]
23+
if "edge_lon" in ds and "edge_lat" in ds:
24+
if "edge_coordinates" in ds["grid_topology"].attrs:
25+
# get the names of edge_lon and edge_lat, if they exist
26+
edge_lon_name, edge_lat_name = ds["grid_topology"].edge_coordinates.split()
27+
coord_dict[edge_lon_name] = ugrid.EDGE_COORDINATES[0]
28+
coord_dict[edge_lat_name] = ugrid.EDGE_COORDINATES[1]
29+
if "face_lon" in ds and "face_lat" in ds:
30+
if "face_coordinates" in ds["grid_topology"].attrs:
31+
# get the names of face_lon and face_lat, if they exist
32+
face_lon_name, face_lat_name = ds["grid_topology"].face_coordinates.split()
33+
coord_dict[face_lon_name] = ugrid.FACE_COORDINATES[0]
34+
coord_dict[face_lat_name] = ugrid.FACE_COORDINATES[1]
3535

3636
ds = ds.rename(coord_dict)
3737

0 commit comments

Comments
 (0)