<div dir="ltr">Thank you all. It solved my problems.<div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Thanks &amp; Regards</div><div dir="ltr">Arun Kumar Dwivedi,<br><br></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Tue, Aug 1, 2017 at 8:27 PM, Dennis Shea <span dir="ltr">&lt;<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>There can&#39;t be a function for everything. <br><br></div><div>A generalization of Guido&#39;s suggestion<br></div><div><br></div><div>  X      = where(x.ne.0, x, x@_FillValue)<br>   xavg = dim_avg_n_Wrap(X, nDim)   ; read documentation<br></div><div>  printVarSummary(xavg)<br></div><div>  printMinMax(xavg, 0)<br></div><div>  delete(X)<br><br></div><div>or, less clear but without a temporary array<br><br></div>  xavg = dim_avg_n_Wrap(where(x.ne.0, x, x@_FillValue), nDim)<br></div>  printVarSummary(xavg)<br>  printMinMax(xavg, 0)</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 1, 2017 at 8:47 AM, Guido Cioni <span dir="ltr">&lt;<a href="mailto:guidocioni@gmail.com" target="_blank">guidocioni@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">No, there is officially no function, but you can define a new one that does the job pretty well.<div><br></div><div>Here is the prototype that goes before the program &quot;begin&quot;.<br><div><br></div><div><div><font face="Menlo">function avg_zeros(x:numeric)</font></div><div><font face="Menlo">; compute average not considering zeros,</font></div><div><font face="Menlo">; --&gt; in:  rain rate</font></div><div><font face="Menlo">; &lt;-- out: average rain rate</font></div><div><font face="Menlo">local N</font></div><div><font face="Menlo">begin</font></div><div><font face="Menlo"> N=num(x .ne. 0)</font></div><div><font face="Menlo"> return(sum(x)/ N)</font></div><div><font face="Menlo">end</font></div></div><div><br></div><div>Example of a function call</div><div><br></div><div><font face="Menlo">rain=avg_zeros(ts-&gt;precp_r)</font></div><div><font face="Menlo"><br></font></div><div><font face="Menlo">Cheers </font></div><div><br><div><blockquote type="cite"><div><div class="m_-4516264528878265902h5"><div>On 1. Aug 2017, at 08:32, Arun Kumar Dwivedi &lt;<a href="mailto:dwivedi.arunkumar@gmail.com" target="_blank">dwivedi.arunkumar@gmail.com</a>&gt; wrote:</div><br class="m_-4516264528878265902m_574036251888529089Apple-interchange-newline"></div></div><div><div><div class="m_-4516264528878265902h5"><div dir="ltr"><span style="font-size:12.8px">Hello All,</span><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">In NCL ,how to calculate average of any array or data while ignoring all the zeros </div><div style="font-size:12.8px">If there is any command or function, kindly let me know.</div><div style="font-size:12.8px"><br><div><div class="m_-4516264528878265902m_574036251888529089gmail-m_-7886533120381905182gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Thanks &amp; Regards</div></div></div></div></div></div></div><div><div class="m_-4516264528878265902m_574036251888529089gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Arun Kumar Dwivedi,<br></div><div dir="ltr"><br></div></div></div></div></div></div></div>
</div></div></div>
______________________________<wbr>_________________<br>ncl-talk mailing list<br><a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>List instructions, subscriber options, unsubscribe:<br><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><span class="m_-4516264528878265902HOEnZb"><font color="#888888"><br></font></span></div></blockquote></div><span class="m_-4516264528878265902HOEnZb"><font color="#888888"><br><div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br class="m_-4516264528878265902m_574036251888529089Apple-interchange-newline">Guido Cioni</div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="http://guidocioni.altervista" target="_blank">http://guidocioni.altervista</a>.o<wbr>rg</div>

</div>
<br></font></span></div></div></div><br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>