Hi Brooke,
I think the easiest thing to do is to use the ind function:
http://www.ncl.ucar.edu/Document/Functions/Built-in/ind.shtml
ncl 0> data = (/4,7,3,7,0,9,1,2/)
ncl 1> aind = ind(data.ge.5)
ncl 2> print(aind)
Variable: aind
Type: integer
Total Size: 12 bytes
3 values
Number of Dimensions: 1
Dimensions and sizes: [3]
Coordinates:
(0) 1
(1) 3
(2) 5
ncl 3> print(sum(data(aind)))
(0) 23
Note that the syntax data(aind) will only select those indices stored in
aind. Thus, sum(data(aind)) will sum up the values associated with the
1st, 3rd, and 5th indices of the array data... Finally, ind only accepts
1D arrays, so you will have to use ndtooned before you do any of this...
Adam
Brooke A. Halvorson wrote:
> I am attempting to take a 2D array and extract each of the values and sum them
> up (if they meet a certain threshold) to give me one,single integer. It
> ultimately does not matter if I keep the location (as the 2D array values are
> associated with gridpoints, not latitude/longitude) since all I want to do is
> sum up the values to give me one number.
>
> This seems like a relatively easy thing to do yet I have been struggling. Is
> NCL capable of this procedure and if so, how? Thank you, in advance, for any
> suggestions.
>
> Brooke
>
-- -------------------------------------------------------------- Adam Phillips asphilli_at_ucar.edu National Center for Atmospheric Research tel: (303) 497-1726 ESSL/CGD/CAS fax: (303) 497-1333 P.O. Box 3000 Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli _______________________________________________ ncl-talk mailing list ncl-talk_at_ucar.edu http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Wed Apr 05 2006 - 15:39:39 MDT
This archive was generated by hypermail 2.2.0 : Thu Apr 06 2006 - 08:48:34 MDT