-
Notifications
You must be signed in to change notification settings - Fork 172
Description
I encountered an issue when using the vertcross function from the wrf-python package to perform vertical interpolation on data stored in a .npy file. Specifically, when I load the .npy file , the data is stored in Fortran-order (column-major) format by default.
The vertcross function seems to require C-order (row-major) data storage format to work correctly. When passing Fortran-order data, I received a ValueError: invalid shape for argument 1 (got (38,), expected (360,)), which suggests a misinterpretation of the data shape due to the storage format mismatch.
Steps to Reproduce:
-
Load vorticity data counted by wrfout (e.g., vorticity) from a
.npyfile:vorticity = np.load("vorticity.npy")
-
Attempt to use vertcross to perform vertical interpolation:
vs_cross = vertcross(vorticity, z, ...)
-
Encounter the error: ValueError: invalid shape for argument 1 (got (38,), expected (360,))
The vertcross function should work correctly when the data is in Fortran-order (which is the default when reading .npy files). If the function requires C-order, it would be helpful to include a clear message in the documentation or provide an automatic conversion inside the function.
solution:
Manually converting the data to C-order format using np.ascontiguousarray() resolves the issue:
vorticity = np.ascontiguousarray(vorticity)
vs_cross = vertcross(vorticity, z, ...)It would be helpful if the vertcross function could automatically handle Fortran-order data or provide better error handling or documentation related to data format expectations.