when I try to read in a netcdf file that I have generated using python netCDF4 class, I get a message like:
UserWarning: WARNING: missing_value not used since it cannot be safely cast to variable data type
if I try to read in the data Q2_daily, here from my nc file is the dump text:
float Q2_daily(time, lev, lat, lon) ;
Q2_daily:_FillValue = 1.e+20f ;
Q2_daily:missing_value = 1.e+20 ;
Q2_daily:long_name = "Q2_daily" ;
Q2_daily:units = "various" ;
So, python netCDF4 puts a "f" at the end of the 20, however, when I specify 1e20 as my missing_value variable, it doesn't appear. I can overwrite this with ncatted, however, I would like to get them consistent. I understand that _FillValue and missing_value are often for different things, however, I would like to have them equal the same value.
I suspect that netCDF4 should automatically set the type for the missing value to be equivalent to the variable that it could represent?
Thanks, Mark.
I've tried doing a few simple things like putting float()
around the scalar or np.float()
but it doesn't appear to make a difference.
The code that writes out the attribute and value is:
variable_name_ids[cnt].setncattr(variable_meta[0],variable_meta[1])
I have tried forcing the type without success.
I would like to see: Q2_daily:missing_value = 1.e+20f ;
in the ncdump.