<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Dave, <div class="">I tried this too initially. But it is giving erroneous results in terms of dimensionality. </div><div class=""><br class=""></div><div class="">If the initial arrays are : <span style="color: rgb(77, 47, 45); font-family: Courier; font-size: 16px; background-color: rgb(237, 234, 212);" class="">[lev_ | 11]</span></div><div class="">Then : <span style="color: rgb(77, 47, 45); font-family: Courier; font-size: 16px; background-color: rgb(237, 234, 212);" class="">arr = avg((/a1,a2,a3,a4,a5,a6,a7,a8,a9/)) </span><span style="color: rgb(77, 47, 45); font-family: Courier; font-size: 16px; background-color: rgb(237, 234, 212);" class="">  </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);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">   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);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></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);" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Variable: arr</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Type: float</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Total Size: 36 bytes</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">            9 values</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Number of Dimensions: 2</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Dimensions and sizes:<span class="Apple-tab-span" style="white-space:pre">        </span>[3] x [3]</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Coordinates: </span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Number Of Attributes: 1</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">  _FillValue :<span class="Apple-tab-span" style="white-space:pre">       </span>1e+30</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">My intent is that I take these 9 [11 dimensioned] vectors and apply a weighted average. </span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class="">weights = (/0.0625,0.0625,0.0625,0.0625,0.5,0.0625,0.0625,0.0625,0.0625/)</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class="">For example, if these a1..a9 were single values, I would do something like </div><div class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">arr = (/ (/a1,a2,a3/), (/a4,a5,a6/), (/a7,a8,a9/)/)</span></div></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">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;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">output =  dim_avg_wgt(ndtooned(arr),ndtooned(weights),1) </span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">(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;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></span></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 16, 2017, at 6:10 PM, Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov" class="">dave.allured@noaa.gov</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Prashanth,<div class=""><br class=""></div><div class="">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 class="">    result = avg ( (/ a1, a2, a3, a4, a5, a6, a7, a8, a9 /) )<div class=""><br class=""></div><div class=""><div class="">--Dave</div><div class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Mon, Oct 16, 2017 at 6:05 PM, Prashanth Bhalachandran <span dir="ltr" class=""><<a href="mailto:prashanth.bhalachandran@gmail.com" target="_blank" class="">prashanth.bhalachandran@<wbr class="">gmail.com</a>></span> wrote:<br class=""><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" class=""><div class=""><span style="font-size:14px" class=""><font face="Palatino" class="">Hello all, </font></span></div><div class=""><span style="font-size:14px" class=""><font face="Palatino" class="">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="m_7541372335505251944gmail-m_6640485635884228427Apple-tab-span" style="white-space:pre-wrap">      </span><span style="background-color:rgb(237,234,212)" class="">[lev | 11]</span></font></span></div><div class=""><span style="font-size:14px" class=""><font face="Palatino" class=""><br class=""></font></span></div><div class=""><font face="Palatino" class=""><span style="background-color:rgb(237,234,212);font-size:14px" class="">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 class=""><font face="Palatino" class=""><span style="background-color:rgb(237,234,212);font-size:14px" class=""><br class=""></span></font></div><div class=""><font face="Palatino" class=""><span style="background-color:rgb(237,234,212);font-size:14px" class="">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 class=""><div style="margin:0px;line-height:normal;background-color:rgb(237,234,212)" class=""><p style="font-variant-ligatures:normal;background-color:rgb(255,255,255)" class=""><span style="font-size:14px" class=""><font face="Palatino" class="">function combine (x[*], y[*]) <br class="">begin <br class="">    nx = dimsizes(x) <br class="">    ny = dimsizes(y) <br class="">    if (<a href="http://nx.eq.my/" target="_blank" class="">nx.eq.my</a>) then <br class="">         xy = new ( (/nx,2/), typeof(x)) ; (row,col) <br class="">         xy(:,0) = (/ x /) <br class="">         xy(:,1) = (/ y /) <br class="">         return (xy) <br class="">    end if <br class=""></font></span></p><p style="font-variant-ligatures:normal;background-color:rgb(255,255,255)" class=""><span style="font-size:14px" class=""><font face="Palatino" class="">    print("combine error") <br class="">    exit <br class="">end </font></span></p><div class=""><br class=""></div><div class="">Thank you, </div><span class="m_7541372335505251944gmail-HOEnZb"><font color="#888888" class=""><div class="">Prashanth</div></font></span></div></div></div></blockquote></div></div></div></div></div>
</div></blockquote></div><br class=""></div></body></html>