[ncl-talk] Binning Data.

jbuzan jbuzan at purdue.edu
Tue Sep 23 09:04:42 MDT 2014


Thanks Arne!

-Jonathan


On Sep 23, 2014, at 11:00 AM, Arne Melsom <arne.melsom at met.no> wrote:

> ...I don't think ncl has a unique value function, so in case you want to get 'binvaluey' from 'y', try e.g.
> 
> z = y
> z at _FillValue = -999
> v = z
> m = -1
> k =  0
> do while (k .lt. dimsizes(z))
>   m = m + 1
>   v(m) = min(z)
>   indx = ind(z .eq. v(m))
>   z(indx) = z at _FillValue
>   k = k + dimsizes(indx)
>   delete(indx)
> end do
> binvaluey = v(0:m)
> 
> 
> ----- Original Message -----
>> Hi Jonathan,
>> There might be a simpler way, but here's a snippet to get you started:
>> 
>> x = (/2,3,4,5,6,7,2,1,3/)
>> y = (/1,1,1,1,3,3,2,2,2/)
>> binvaluey =(/1,2,3/)
>> do n=0,dimsizes(binvaluey)-1
>>   indx = ind(y .eq. binvaluey(n))
>>   print(x(indx))
>>   delete(indx)
>> end do
>> 
>> Good luck!
>> Arne
>> 
>> 
>> ----- Original Message -----
>>> Hello NCL-Talk,
>>> 
>>> I am attempting to find a function that will allow me to bin data in one
>>> array while using another array as the boundaries.
>>> 
>>> For ex.
>>> x = (/2,3,4,5,6,7,2,1,3/)
>>> y = (1,1,1,1,3,3,2,2,2/)
>>> 
>>> binvaluey = 1, 4 values: (/2,3,4,5/)
>>> binvaluey = 2, 3 values: (/2,1,3/)
>>> binvaluey = 3, 2 values: (/6,7/)
>>> 
>>> I tried to find a function that would do this, but I am not seeing anything
>>> in the function list.  The only thing I can think of is create an array for
>>> each bin range, and using masks to isolate the values in the other array.
>>> 
>>> -Jonathan
>>> _______________________________________________
>>> 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
>> 



More information about the ncl-talk mailing list