-
Notifications
You must be signed in to change notification settings - Fork 265
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
Inconsistent Loading Results for netCDF4 version #1232
Comments
Looks to me like they are all masked because they are outside the range of [valid_min,valid_max]. If you don't want any values to be masked, you can use set_auto_mask. |
Oh - I see your point, the value in the file is actually -64 but it is apparently being interpreted as an unsigned int8 and given a value of 192. This is because the _Unsigned attribute exists - even though it is set to 'false' the module only checks for it's existence, not it's value. There is a discussion of this at #656. |
This could be considered a bug - we should probably check to see if it is set to "false" or "False" (or alternatively, only treat variable as unsigned if _Unsigned is "true" or "True"). |
Thank you for the followup. Unfortunately, I just did a quick test and cloned the issue1232 branch, but I couldn't get it to compile (due to the script not generating src/netCDF4/_netCDF4.c). I'll try to work through the compilation issue and test out the fix. |
In addition to turning the masking off, you could use the numpy view method to construct a view of the data as a signed int8. |
Thank you, yes, the view will indeed cast it, but first the scale_factor and add_offset must be removed: Extending the original code snippet from the first message:
This results in the proper values. For the life of me (on both Linux and macOS), I cannot get issue1232 to 'build'. It never generates the _netCDF4.c file. Everything seems to work except that it doesn't generate the c-language file. I found an issue from years ago about disabling cython; however, looking at the I apologize for the hassle.
|
can you run cython manually on src/netCDF4/_netCDF4.pyx? |
I realized that the environment I was building in didn't have cython installed. I built the |
I am trying to load a variable of data from a THREDDS URL; however, I get different results depending on the netCDF4/Python version.
The code is simply:
On Linux with Python 3.6.3 and netCDF4 1.2.4, this results in a masked array with valid entries:
However, running this same code on several instances of Linux and macOS configurations installed via condaforge (each using Python 3.10.8/netCDF4 1.6.2 and Python 3.11.0/netCDF4 1.6.2 in different virtual environments) produce invalid results. The
err
variable is entirely masked with invalid entries.The variable of interest is defined as an
int8
with a scale_factor of 0.01. Entries outside of ±127 would be invalid for a signed 8-bit number.nc.variables["sses_standard_deviation"]
is:Examining
err.data
in the non-working cases all reveal values greater than 127 that would imply netCDF4 is not treating this as asigned int8
; however, since all values listed below are greater than 127, it would also mean every standard deviation is negative. As shown by the working version at the top, theint8
values for this dataset should typically be in the 30-40 range prior toscale_factor
.Is it possible that there is an issue in 1.6.2 that mishandles type
int8
?The text was updated successfully, but these errors were encountered: