Version
v2026.06.0
How did you install UXarray?
Conda
What happened?
Currently, the SCRIP reader does not respect units attached to relevant lat/lon vars. That is, it assumes degrees. For 90% of grids, this is probably the case. MPAS, by default, writes SCRIP files internally in radians, which are easily convertible using NCO or other external scripts, but it breaks uxarray currently (well, uxarray runs fine since |radians| < |degrees| but then projects fields in a very small location near 0, 0).
What did you expect to happen?
UXarray should read the units attribute and act accordingly. Since the current infrastructure is centered around degrees, it should read "radians" and convert the relevant arrays to "degrees" before progressing in the stack.
Can you provide a MCVE to repoduce the bug?
import uxarray as ux
import numpy as np
import xarray as xr
import os
# Define a tiny 2-cell grid in degrees
center_lon_deg = np.array([10.0, 20.0])
center_lat_deg = np.array([30.0, 40.0])
corner_lon_deg = np.array([[5., 15., 15., 5.], [15., 25., 25., 15.]])
corner_lat_deg = np.array([[25., 25., 35., 35.], [35., 35., 45., 45.]])
# Build a SCRIP dataset with coordinates stored in rad
ds = xr.Dataset()
ds["grid_center_lon"] = xr.DataArray(np.deg2rad(center_lon_deg), dims=["grid_size"], attrs={"units": "radians"})
ds["grid_center_lat"] = xr.DataArray(np.deg2rad(center_lat_deg), dims=["grid_size"], attrs={"units": "radians"})
ds["grid_corner_lon"] = xr.DataArray(np.deg2rad(corner_lon_deg), dims=["grid_size", "grid_corners"], attrs={"units": "radians"})
ds["grid_corner_lat"] = xr.DataArray(np.deg2rad(corner_lat_deg), dims=["grid_size", "grid_corners"], attrs={"units": "radians"})
ds["grid_imask"] = xr.DataArray(np.ones(2, dtype=np.int32), dims=["grid_size"])
ds["grid_area"] = xr.DataArray(np.ones(2), dims=["grid_size"])
ds["grid_dims"] = xr.DataArray(np.array([2], dtype=np.int32), dims=["grid_rank"])
# Write to a small test file to mimic reading a SCRIP nc
out_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "scrip_radians.nc")
ds.to_netcdf(out_path)
grid = ux.open_grid(out_path)
print("face_lon (got): ", grid.face_lon.values)
print("face_lon (expected):", center_lon_deg)
# Bug: without the fix, face_lon will be ~[0.17, 0.35] (radian values treated as degrees)
# With fix: face_lon will be ~[10.0, 20.0]
Version
v2026.06.0
How did you install UXarray?
Conda
What happened?
Currently, the SCRIP reader does not respect units attached to relevant lat/lon vars. That is, it assumes degrees. For 90% of grids, this is probably the case. MPAS, by default, writes SCRIP files internally in radians, which are easily convertible using NCO or other external scripts, but it breaks uxarray currently (well, uxarray runs fine since |radians| < |degrees| but then projects fields in a very small location near 0, 0).
What did you expect to happen?
UXarray should read the units attribute and act accordingly. Since the current infrastructure is centered around degrees, it should read "radians" and convert the relevant arrays to "degrees" before progressing in the stack.
Can you provide a MCVE to repoduce the bug?