<div dir="ltr"><div><div>There can't be a function for everything. <br><br></div><div>A generalization of Guido'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="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 1, 2017 at 8:47 AM, Guido Cioni <span dir="ltr"><<a href="mailto:guidocioni@gmail.com" target="_blank">guidocioni@gmail.com</a>></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 "begin".<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">; --> in: rain rate</font></div><div><font face="Menlo">; <-- 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->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="h5"><div>On 1. Aug 2017, at 08:32, Arun Kumar Dwivedi <<a href="mailto:dwivedi.arunkumar@gmail.com" target="_blank">dwivedi.arunkumar@gmail.com</a>> wrote:</div><br class="m_574036251888529089Apple-interchange-newline"></div></div><div><div><div class="h5"><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_574036251888529089gmail-m_-7886533120381905182gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Thanks & Regards</div></div></div></div></div></div></div><div><div class="m_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/<wbr>mailman/listinfo/ncl-talk</a><span class="HOEnZb"><font color="#888888"><br></font></span></div></blockquote></div><span class="HOEnZb"><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_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>.<wbr>org</div>
</div>
<br></font></span></div></div></div><br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">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/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>