-
Notifications
You must be signed in to change notification settings - Fork 264
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
Masking not working properly with _Unsigned #794
Comments
I'm traveling so I won't be able to look at this till next week. Have you tried the latest master? |
The valid range is assumed to be of the same type as the netcdf variable (signed short integer) and the conversion to unsigned short is considered to be part of the scale/offset operation (a numpy view is created after the mask is created). |
In this case, |
Yes, but isn't the We are currently treating the |
Hmmm...I just found this in the netCDF User's Guide under Best Practices:
@lesserwhirls Does netCDF-java handle |
@dopplershift - yes, netCDF-java tries to deal with |
Yes it does. First, it widens Then, it applies scale and offset. The result will be a |
Does netCDF-java do the same with |
@jswhit Yes, And to be clear, short s = -6;
System.out.println((int) s); // Cast: -6
System.out.println(s & 0xffff); // Widen: 65530 The problem that I see with |
With the changes in pull request #797, the following script from netCDF4 import Dataset
import matplotlib.pyplot as plt
nc=Dataset('OR_ABI-L2-RRQPEF-M3_G16_s20181072300427_e20181072311194_c20181072311280.nc')
data = nc['RRQPE'][:]
print data.dtype, data.min(), data.max()
plt.imshow(data,cmap=plt.cm.jet,vmin=0,vmax=100)
plt.colorbar()
plt.show() produces
and the attached png file. Can someone try this with netcdf-java and see if they get the same? |
That's what I get using |
pull request #797 merged |
I have tried to output the valid_range of the dataset, and still got [0, -6]. Are they supposed to be [0, 100] or [0.0, 100.0] ? from netCDF4 import Dataset
nc=Dataset('OR_ABI-L2-RRQPEF-M3_G16_s20181072300427_e20181072311194_c20181072311280.nc')
data = nc['RRQPE'][:]
print data.dtype, data.min(), data.max()
print nc['RRQPE'].getncattr('valid_range') float32 0.0 100.00009 [ 0, -6] |
The fix does not have the library change the |
I have a Level 2 QPE product from GOES-16 that caused some support issues. The relevant CDL is:
Note the values in
valid_range
; the values themselves are appropriate for a signed data type, but they only make sense as a range if you convert signed (-6) to unsigned (65530). The values invalid_range
are not incorrect though, as the standards specify that the values need to be the same type as the variable.The current out of the box behavior is that netCDF4-python returns an entirely masked variable. The work-around is to disable masking.
The correct behavior IMO is to have valid_range and friends be handled like the data values for unsigned purposes.
I've included the sample file.
The text was updated successfully, but these errors were encountered: