Skip to content

Commit 8fe4143

Browse files
authored
Add additional variable check to SCRIP reader (#1233)
* o Fix SCRIP reader to use grid_rank, bug found while reading a SCRIP grid provided in ESMPy ll1deg_grid.nc * o Use imask instead of rank as our test cases have grids that don't have grid_rank * o Add multiple options for checking SCRIP * o Fix formatting * o Use any construct for better performance and redability
1 parent 30a534b commit 8fe4143

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

uxarray/io/_scrip.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ def _to_ugrid(in_ds, out_ds):
1515

1616
source_dims_dict = {}
1717

18-
if in_ds["grid_area"].all():
18+
# Check if any of imask, area or rank are present
19+
if any(key in in_ds for key in ["grid_imask", "grid_rank", "grid_area"]):
1920
# Create node_lon & node_lat variables from grid_corner_lat/lon
2021
# Turn latitude and longitude scrip arrays into 1D
2122
corner_lat = in_ds["grid_corner_lat"].values.ravel()
@@ -131,7 +132,7 @@ def _encode_scrip(face_node_connectivity, node_lon, node_lat, face_areas):
131132
Currently, supports creating unstructured SCRIP grid files following traditional
132133
SCRIP naming practices (grid_corner_lat, grid_center_lat, etc).
133134
134-
Unstructured grid SCRIP files will have ``grid_rank=1`` and include variables
135+
Unstructured grid SCRIP files typically have ``grid_rank=1`` and include variables
135136
``grid_imask`` and ``grid_area`` in the dataset.
136137
137138
More information on structured vs unstructured SCRIP files can be found here on the `Earth System Modeling Framework <https://earthsystemmodeling.org/docs/release/ESMF_6_2_0/ESMF_refdoc/node3.html>`_ website.

0 commit comments

Comments
 (0)