[ncl-talk] Binning Data.

Dennis Shea shea at ucar.edu
Tue Sep 23 09:27:43 MDT 2014


A minor bit of information.
>From 6.1.1 onward the 'reassignment operator' ( := )could be used. This
avoids the need for delete(indx).

https://www.ncl.ucar.edu/prev_releases.shtml#NewOperator6.1.1
-----------------------------
do while (k .lt. dimsizes(z))
   m = m + 1
   v(m) = min(z)
   indx := ind(z .eq. v(m))      ; <--- reassignment operator  :=
   z(indx) = z at _FillValue
   k = k + dimsizes(indx)
 end do

On Tue, Sep 23, 2014 at 9: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
> >
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20140923/07d7bfcd/attachment.html 


More information about the ncl-talk mailing list