Hi Michael,
There appears to be a bug in "int2flt", which is part of
contributed.ncl.
Assuming "i" is the integer array you want to convert, the "int2flt"
is doing this:
dimi = dimsizes(i)
fi = new( dimi, "float")
fi = i ; values + meta data
What's happening here is that when "fi" gets created,
it has a default _FillValue of -999. Then when you do:
fi = i
this is going to cause any -999's in the array to be considered
missing, because "fi" sees its own missing value, and not "i"'s
missing value.
Then, the code goes on to reset the _FillValue to -9999.
However, the original -999 is still consider missing, so
it gets changed to -9999, and the original -9999 values
are now also considered missing.
The fix is to set the float missing value when you call "new".
Here's a new version of "int2flt" that you can try:
function int2flt(i:integer)
local dimi, fi
begin
dimi = dimsizes(i)
if (isatt(i,"_FillValue")) then
fi = new( dimi, "float", i@_FillValue)
else
fi = new( dimi, "float","No_FillValue")
end if
fi = i ; values + meta data
return (fi)
end
On Fri, 20 Mar 2009, Michael Notaro wrote:
> I seem to be encountering a bug. Imagine I have an array, a, with
> 6 values. And I specify that -9999 is the FillValue. Then a value
> of -999 should not be considered missing. However, after using
> int2flt on a, then it converts the -999 into -9999, missing.
>
> a=(/123,345,678,-9999,-999,246/)
> a@_FillValue=-9999
> b=int2flt(a)
> print(b)
>
> (0) 123
> (1) 345
> (2) 678
> (3) -9999
> (4) -9999
> (5) 246
>
> This is a work-around:
>
> a=(/123,345,678,-9999,-999,246/)
> a@_FillValue=-9999
> b=a*1.
> print(b)
>
> (0) 123
> (1) 345
> (2) 678
> (3) -9999
> (4) -999
> (5) 246
>
> Any idea what's wrong here?
> Mike
> _______________________________________________
> 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 Fri Mar 20 2009 - 09:21:32 MDT
This archive was generated by hypermail 2.2.0 : Fri Mar 20 2009 - 10:31:52 MDT