Re: picking off negative values

From: Dennis Shea (shea@XXXXXX)
Date: Fri Aug 24 2001 - 12:02:41 MDT


> If I have an array;
>
    
No loop required. NCL's utility functions can be used.
NCL's utility (array) functions are, IMHO, a key to using NCL efficiently.

Remember _FillValue is 'special' and is exempt from most functions.
You must explicitly test for "missing"

(1) If what you want is to set all locations where ad=-999 (=ad@_FillValue)
    to zero then:
        
    indMsg = ind(ismissing(ad)) ; indices where ad = _FillValue
    ad(indMsg) = 0.0 ; set all _FillValue to 0.0
    
    ad still has ad@_FillValue = -999.
    
(2) if "ad" has values less than zero but not equal to _FillValue
    and you want to set them to 0.0 then
    
    indLt = ind(ad.lt.0.0) ; indices where ad < 0.0
    ad(indLt) = 0.0 ; set these to 0.0
        
(3) if u want to do both (1) and (2)

    IND = ind(ismissing(ad) .or. ad.lt.0.0)
    ad(IND) = 0.0



This archive was generated by hypermail 2b29 : Tue Feb 19 2002 - 09:06:06 MST