Dear Ivanna,
This warning is likely occuring because your data variable is one type (say float), but your "missing_value" attribute is a higher type (say double).
When NCL sees a "missing_value" attribute and not a "_FillValue" attribute, it tries to create a "_FillValue" attribute for you, based on "missing_value". If "missing_value" is a higher type than your data, then it can't safely be coerced to the lower type, and you get a warning.
You can get rid of this warning by adding the following line before your "addfile" statement:
setfileoption("nc","MissingToFillValue",False)
Really, the best thing to do is to find out why "missing_value" is a higher type than your data, and try to fix this.
Here's a code snippet that creates a dummy file with float data and double "missing_value" attribute.
You'll see the warning the first time you open the file for reading.
This code then fixes the "missing_value" to be a float, and the warning goes away:
;---Generate some dummy float data with a double "missing_value"
x = random_uniform(0,100,(/10,20/))
x@missing_value = 1d20
;---Write array to NetCDF file
filename = "testout.nc"
if(isfilepresent(filename)) then
system("/bin/rm " + filename)
end if
fout = addfile(filename,"c")
fout->x = x
; setfileoption("nc","MissingToFillValue",False)
;---Simply opening the file will generate a warning
fin = addfile(filename,"w") ; open for reading and writing
xin = fin->x
printVarSummary(xin)
print(" typeof(xin@missing_value) = " + typeof(xin@missing_value))
;---Fix the "missing_value" on the file to be a "float"
missing_value = tofloat(xin@missing_value)
delete(fin->x@missing_value)
fin->x@missing_value = missing_value
;---Close the file
delete(fin)
;
; Reopen the file. Note there's no warning this time, and
; this time a _FillValue attribute is added
;
fin = addfile(filename,"r")
xin = fin->x
printVarSummary(xin)
print(" typeof(xin@missing_value) = " + typeof(xin@missing_value))
--Mary
On Oct 23, 2011, at 11:24 PM, Ivanna Mo wrote:
> Hi,
> When I run my ncl script, I got a warning:NetOpenFile: MissingToFillValue option set True, but missing_value attribute and data variable (air) types differ: not adding virtual _FillValue attribute
> I wonder how can I eliminate this warning.
>
> Thanks in advance.
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Oct 24 09:00:59 2011
This archive was generated by hypermail 2.1.8 : Mon Oct 24 2011 - 09:29:35 MDT