Closed TimothyCera-NOAA closed 3 months ago
Thanks for opening your first issue here at xarray! Be sure to follow the issue template! If you have an idea for a solution, we would really welcome a Pull Request with proposed changes. See the Contributing Guide for more. It may take us a while to respond here, but we really value your contribution. Contributors like you help make xarray better. Thank you!
Thanks for the issue. We should definitely have a try/except for the bytes given that can fail...
as far as I can tell, the reason for this is that grib2io
defines a OnDiskArray
, where the dtype
is a string. Which is unexpected, but since dtypes are opaque objects in the array API we might have to figure out how to deal with that at some point.
I tried to fix in grib2io replacing "float32"
with np.float32
but didn't help, but what did work was enforcing np.dtype
in xarray as shown in #9191
you'd have to replace it with the dtype instance, np.dtype("float32")
. It looks like attribute
descriptors like itemsize
return self
instead of the result of __get__
if called from the class object (np.float32
) instead of the instance object.
This issue was supposed to be closed when I closed the #9191, but it wasn't. So closing...
As mentioned in the pull request, comments here and in the pull request were helpful to me tracking down how to fix in grib2io.
What happened?
We use the grib2io backend to read GRIB2 formatted files. Started to have problem printing the summary of the dataset to the screen with the v2024.02.0 release. I suspect the problem is from #8702
Trying to print a dataset will fail trying to find nbytes.
The grib2io backend opens the file lazily, which means you are printing the summary of a MemoryCachedArray which doesn't have nbytes, nor is able to calculate.
Loading the data into memory and then the print(ds1) works fine.
You can force loading the data and then printing works:
What did you expect to happen?
Want print(ds1) to print the summary of the dataset.
Minimal Complete Verifiable Example
MVCE confirmation
Relevant log output
No response
Anything else we need to know?
No response
Environment