-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
How to avoid the auto convert variable dtype from float32 to float64 when read netCDF file use open_dataset? #1008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Some of your variables probably have You can disable the scaling by writing |
Thanks for your reply. Variables dbz, vr and sw have the _FillValue attribute, whose value is equal to _FillValue: -999.0
It seems that xarray will convert the dtype from float32 to float64, while the variable in netCDF4 file has the attribute Using |
OK, that makes sense. I agree, we could keep such arrays as float32. We don't need to guard against overflow when only decoding a If you're interested in taking a look at a fix, this is where the current logic is: Lines 795 to 802 in 551a7bc
|
OK & Thanks |
I stumbled across the same problem in xarray 0.9.1 and updating to 0.10.2 solved it. Perhaps this issue may be closed? |
Use xarry.open_dataset
will yield output as follow
Variables dtype of dbz, vr and sw in this file have been convert to float64, which actually is float32.
Use netCDF4.Dataset
will yield output as follow
The netCDF4.Dataset produce the right variable type, while the xarray.open_dataset not.
The text was updated successfully, but these errors were encountered: