[ncl-talk] Question regarding array averaging

Dave Allured - NOAA Affiliate dave.allured at noaa.gov
Mon Oct 16 19:10:15 MDT 2017


Prashanth,

All of the original arrays have exactly the same dimensions.  This means
you can easily combine them into a single 2-D virtual array, using array
constructors (/ ... /).  See the NCL user manual for details.  See if this
works.

    result = avg ( (/ a1, a2, a3, a4, a5, a6, a7, a8, a9 /) )

--Dave


On Mon, Oct 16, 2017 at 6:05 PM, Prashanth Bhalachandran <
prashanth.bhalachandran at gmail.com> wrote:

> Hello all,
> I am trying to take an average of nine 1D arrays that I have .. a1 to a9
> all of them of the dimension  [lev | 11]
>
> If my understanding is right, the average functions in NCL doesn’t simply
> allow you to do avg(a1….a9). Please correct me if I am wrong.
>
> The other way around is that I combine the 9 arrays in to a 11x9 array
> using a function that Dennis have posted out in the past. Is this the way
> around it? Or is there a simpler/less computationally intensive way of
> doing it?
>
> function combine (x[*], y[*])
> begin
>     nx = dimsizes(x)
>     ny = dimsizes(y)
>     if (nx.eq.my) then
>          xy = new ( (/nx,2/), typeof(x)) ; (row,col)
>          xy(:,0) = (/ x /)
>          xy(:,1) = (/ y /)
>          return (xy)
>     end if
>
>     print("combine error")
>     exit
> end
>
> Thank you,
> Prashanth
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171016/8e0c9687/attachment.html>


More information about the ncl-talk mailing list