On Thu, 15 Feb 2007, Dennis Shea wrote:
> > Is there any function to calculate cumulative sum of variable. I would like
> > to avoid the following loop.
> >
> > ; loop to compute cumulative sum of number of days
> > tm=new(dimsizes(month),"integer")
> > a=0
> > do i=0,nmonth-1
> > tm(i)=month(i)+a
> > a=tm(i)
> > end do
> >------------------------------
>
> sum, dim_sum
>
> http://www.ncl.ucar.edu/Document/Functions/Built-in/sum.shtml
> http://www.ncl.ucar.edu/Document/Functions/Built-in/dim_sum.shtml
>
> ----
> If you are looking for a function that does "something" [eg, sum]
> type sum in the Search box in the upper left of all NCL web pages.
>
Dennis,
I don't think sum and dim_sum do what the original poster is asking for.
He is looking for a cumulative sum, which is sometimes called an
indefinite or running sum. At times I have wanted the same
functionality. In matlab you can use cumsum and in ferret you can use
the @rsu transformation. I have not come across a way to do it in NCL
without resorting to a loop. If someone knows how to do this and avoid
the loop, I'd love to hear about it as well.
Keith
-- ****************************************************************** Keith Lindsay http://www.cgd.ucar.edu/oce/klindsay/ email: klindsay_at_ucar.edu phone: 303-497-1722 fax: 303-497-1700 _______________________________________________ ncl-talk mailing list ncl-talk_at_ucar.edu http://mailman.ucar.edu/mailman/listinfo/ncl-talkReceived on Thu Feb 15 2007 - 09:09:34 MST
This archive was generated by hypermail 2.2.0 : Thu Feb 22 2007 - 14:54:01 MST