[ncl-talk] local_max and missing values

Teresa Parker tess.parker at monash.edu
Fri Jun 5 02:33:05 MDT 2015


Hi - I'm using the local_max function to find local maxima in a variable
field. The variable covers all longitudes, but is calculated for a 30 deg
latitude band only. All values outside this latitude band are set to the
@_FillValue for the variable.

Where the local maximum for the variable is located well within the
latitude band, there is no problem However, when the local maximum is
located on the edge of the latitude band (i.e. at either the minimum or
maximum latitude of the band), the function fails. This seems to be because
the immediately neighbouring points are all "missing" values. However, the
function documentation states that missing values are ignored.

This can be seen from a simple example:
*************************************************
begin

myvar = new((/3,3/),float)
myvar at _FillValue = -999.
myvar = (/ (/-999.0,-999.0,-999.0/),(/60,70,55/),(/43,45,23/)/)
print(myvar)
mymax = local_max(myvar, False, 0.0)
print(mymax)

mymaxval = mymax at maxval
print(mymaxval)

end

However, if the missing values are set to e.g. zero, the function works:
*********************************************************************
begin

myvar = new((/3,3/),float)
myvar at _FillValue = -999.
myvar = (/ (/0.0,0.0,0.0/),(/60,70,55/),(/43,45,23/)/)
print(myvar)
mymax = local_max(myvar, False, 0.0)
print(mymax)

mymaxval = mymax at maxvalmymaxval = mymax at maxval
print(mymaxval)

end

While it might seem to be an easy workaround to set the next highest and
lowest latitude band values to some miniscule value, this shouldn't really
be necessary for the function to work. Can anyone help?

-- 
Tess Parker
PhD Candidate
School of Earth, Atmosphere and Environment
Room 225, Building 28
9 Rainforest Walk
Monash University, Clayton VIC 3800
Phone: +61 3 9905 4458
http://users.monash.edu.au/~tess/index.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150605/c5373d8b/attachment.html 


More information about the ncl-talk mailing list