<div dir="ltr"><div>Prashanth,<br></div><div><br></div>I do not understand how NCL could get a 3 x 3 array from a 9 x 11 construction like that.  However, here is a complete smaller example of what I think you described, a weighted average on one dimension.  a1...a4 are simple 1-D arrays of length 5.  Does this do what you want?<div><div><br></div><div><div>ncl 37> b = (/ a1, a2, a3, a4 /)     </div><div><br></div><div>ncl 38> printVarSummary (b)          </div><div>Type: integer</div><div>Dimensions and sizes:<span class="gmail-Apple-tab-span" style="white-space:pre">        </span>[4] x [5]</div><div><br></div><div>ncl 39> print (w)                     </div><div>Type: float</div><div>Dimensions and sizes:   [4]</div><div>(0)     0.2</div><div>(1)     0.3</div><div>(2)     0.3</div><div>(3)     0.2</div><div><br></div><div>ncl 40> wsum = dim_avg_wgt_n (b, w, 0, 0)</div><div><br></div><div>ncl 41> print (wsum)</div><div>Type: float</div><div>Dimensions and sizes:   [5]</div><div>(0)     1.6</div><div>(1)     3.2</div><div>(2)     4.8</div><div>(3)     6.4</div><div>(4)      8</div><div><br></div><div>--Dave</div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 16, 2017 at 7:44 PM, Prashanth Bhalachandran <span dir="ltr"><<a href="mailto:prashanth.bhalachandran@gmail.com" target="_blank">prashanth.bhalachandran@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word">Hi Dave, <div>I tried this too initially. But it is giving erroneous results in terms of dimensionality. </div><div><br></div><div>If the initial arrays are : <span style="color:rgb(77,47,45);font-family:Courier;font-size:16px;background-color:rgb(237,234,212)">[lev_ | 11]</span></div><div>Then : <span style="color:rgb(77,47,45);font-family:Courier;font-size:16px;background-color:rgb(237,234,212)">arr = avg((/a1,a2,a3,a4,a5,a6,a7,a8,<wbr>a9/)) </span><span style="color:rgb(77,47,45);font-family:Courier;font-size:16px;background-color:rgb(237,234,212)">  </span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Courier;color:rgb(77,47,45);background-color:rgb(237,234,212)"><span style="font-variant-ligatures:no-common-ligatures">   printVarSummary(arr)</span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Courier;color:rgb(77,47,45);background-color:rgb(237,234,212)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;font-size:16px;line-height:normal;font-family:Courier;color:rgb(77,47,45);background-color:rgb(237,234,212)"><span style="font-variant-ligatures:no-common-ligatures"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">Variable: arr</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">Type: float</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">Total Size: 36 bytes</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">            9 values</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">Number of Dimensions: 2</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">Dimensions and sizes:<span class="gmail-m_3896431631027407673Apple-tab-span" style="white-space:pre-wrap"> </span>[3] x [3]</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">Coordinates: </span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">Number Of Attributes: 1</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">  _FillValue :<span class="gmail-m_3896431631027407673Apple-tab-span" style="white-space:pre-wrap">        </span>1e+30</span></div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div><span style="font-variant-ligatures:no-common-ligatures">My intent is that I take these 9 [11 dimensioned] vectors and apply a weighted average. </span></div><div><span style="font-variant-ligatures:no-common-ligatures">weights = (/0.0625,0.0625,0.0625,0.0625,<wbr>0.5,0.0625,0.0625,0.0625,0.<wbr>0625/)</span></div><div><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div>For example, if these a1..a9 were single values, I would do something like </div><div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">arr = (/ (/a1,a2,a3/), (/a4,a5,a6/), (/a7,a8,a9/)/)</span></div></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">weights = (/ (/0.0625,0.0625,0.0625/), (/0.0625,0.5,0.0625/), (/0.0625,0.0625,0.0625/)/)</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">output =  dim_avg_wgt(ndtooned(arr),<wbr>ndtooned(weights),1) </span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures">(I know I can avoid the ndtooned, but that’s besides the point). I am finding it hard to translate this procedure when a1 … a9 are vectors of 11 values each instead of one. </span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div></span></div><div><br><div><blockquote type="cite"><div>On Oct 16, 2017, at 6:10 PM, Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a>> wrote:</div><br class="gmail-m_3896431631027407673Apple-interchange-newline"><div><div dir="ltr">Prashanth,<div><br></div><div>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.</div><br>    result = avg ( (/ a1, a2, a3, a4, a5, a6, a7, a8, a9 /) )<div><br></div><div><div>--Dave</div><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 16, 2017 at 6:05 PM, Prashanth Bhalachandran <span dir="ltr"><<a href="mailto:prashanth.bhalachandran@gmail.com" target="_blank">prashanth.bhalachandran@gmail<wbr>.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><div><span style="font-size:14px"><font face="Palatino">Hello all, </font></span></div><div><span style="font-size:14px"><font face="Palatino">I am trying to take an average of nine 1D arrays that I have .. a1 to a9 all of them of the dimension <span class="gmail-m_3896431631027407673m_7541372335505251944gmail-m_6640485635884228427Apple-tab-span" style="white-space:pre-wrap">  </span><span style="background-color:rgb(237,234,212)">[lev | 11]</span></font></span></div><div><span style="font-size:14px"><font face="Palatino"><br></font></span></div><div><font face="Palatino"><span style="background-color:rgb(237,234,212);font-size:14px">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. </span></font></div><div><font face="Palatino"><span style="background-color:rgb(237,234,212);font-size:14px"><br></span></font></div><div><font face="Palatino"><span style="background-color:rgb(237,234,212);font-size:14px">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?</span></font></div><div><div style="margin:0px;line-height:normal;background-color:rgb(237,234,212)"><p style="font-variant-ligatures:normal;background-color:rgb(255,255,255)"><span style="font-size:14px"><font face="Palatino">function combine (x[*], y[*]) <br>begin <br>    nx = dimsizes(x) <br>    ny = dimsizes(y) <br>    if (<a href="http://nx.eq.my/" target="_blank">nx.eq.my</a>) then <br>         xy = new ( (/nx,2/), typeof(x)) ; (row,col) <br>         xy(:,0) = (/ x /) <br>         xy(:,1) = (/ y /) <br>         return (xy) <br>    end if <br></font></span></p><p style="font-variant-ligatures:normal;background-color:rgb(255,255,255)"><span style="font-size:14px"><font face="Palatino">    print("combine error") <br>    exit <br>end </font></span></p><div><br></div><div>Thank you, </div><span class="gmail-m_3896431631027407673m_7541372335505251944gmail-HOEnZb"><font color="#888888"><div>Prashanth</div></font></span></div></div></div></blockquote></div></div></div></div></div></div></blockquote></div></div></div></blockquote></div></div></div></div></div></div>