<div dir="ltr"><div>THX. The fix will be in NCL v6.3.0<br><br>==<br></div><div>[1] The simplest fix is the to take the sqrt of the 1-th element upon return<br></div><div>          statd = stat_dispersion(x, False)<br></div><div>          statd(1) = sqrt( statd(1) )<br><br></div><div>[2] IMHO ... a better solution is to use an editor to extract the stat_dispersion function from contributed.ncl<br><br></div><div>     vi  $NCARG_ROOT/lib/ncarg/nclscripts/csm/<a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/contrib.shtml">contributed.ncl</a></div><div><br></div><div>     Save the extracted code as a file named stat_dispersion.ncl<br><br></div><div>     Edit the stat_dispersion.ncl file:<br><br></div><div>       Change:  statx(1) = moment(1)      <br></div><div>       To:           statx(1) = sqrt(moment(1)) <br><br></div><div>     Save the file,<br><br></div><div>[3] explicitly load the corrected file<br><br></div><div>     load &quot;./stat_dispersion.ncl&#39;<br><br></div><div>D<br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 16, 2014 at 4:12 PM, Colin Zarzycki <span dir="ltr">&lt;<a href="mailto:zarzycki@umich.edu" target="_blank">zarzycki@umich.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">There appears to be a small (but potentially problematic!) bug in stat_dispersion.<div><br></div><div>The second index returned in the stats array (ex: stat(1)) should be standard deviation per the site documentation and function&#39;s internal print routine. However, the function actually appears to return the variance under the index.</div><div><br></div><div>in the actual function in contributed.ncl</div><div><br></div><div>&lt;snip&gt;</div><div><div>   if (nwork.gt.1) then</div><div>      ;statx(0) = avg(x)                ; mean</div><div>      ;statx(1) = stddev(x)             ; std. deviation</div><div>       moment   = dim_stat4( work )</div><div>       statx(0) = moment(0)             ; mean</div><div>       statx(1) = moment(1)             ; std. deviation &lt;---------------</div><div><br></div><div>       qsort( work )                    ; sort into ascending order</div><div>       statx(2) = work(0)               ; min ( work )</div></div><div><div>&lt;snip&gt;</div><div><br></div><div>dim_stat4 should return variance in the (1) index, not stddev<br></div><div><br></div><div>This can be reproduced with the below code snippet:</div><div><br></div><div><div>;========================================================</div><div>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl&quot;</div><div>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl&quot;</div><div>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl&quot;</div><div>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl&quot;</div><div>;========================================================</div><div>begin</div><div><br></div><div>a = new(10,&quot;float&quot;,-999)</div><div>a = (/1,2,3,4,5,6,7,8,9,10/)</div><div>;a(3) = a@_FillValue</div><div><br></div><div>opt = True</div><div>opt@PrintStat = True</div><div>statb = stat_dispersion(a, opt )</div><div><br></div><div>print(&quot;stdev = &quot;+stddev(a))</div><div>print(&quot;variance = &quot;+variance(a))</div><div><br></div><div>end</div><div><br></div><div>;========================================================</div></div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Colin</div><div><br></div>-- <br><div dir="ltr"><div dir="ltr" style="font-family:arial;font-size:small">Colin M. Zarzycki, ASP postdoctoral fellow</div><div dir="ltr" style="font-family:arial;font-size:small">Atmospheric Modeling and Predictability<br>National Center for Atmospheric Research<br><a href="http://www.colinzarzycki.com/" style="color:rgb(17,85,204)" target="_blank">http://www.colinzarzycki.com</a></div></div>
</font></span></div></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>