<div dir="ltr"><div><div>Hi Dave,<br><br></div><div>I have fixed NCL-2656: calculate monthly/daily_values. The updates will be part of the 6.5.0 release.<br></div><div>You can test if you want.<br></div><div><br></div><div>load "./calculate_monday_values.ncl"<br><br></div><div>[... your code ...]<br><br>=====<br></div><div>Cheers<br></div><div>Dennis<br></div><div><br></div><div><br></div>P.S. We are having a nice 'British Isle' day: 3.5C and heavy rain.  :-(<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 12, 2017 at 9:38 AM, Adam Phillips <span dir="ltr"><<a href="mailto:asphilli@ucar.edu" target="_blank">asphilli@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Dave,<div>Thanks for reporting this and for investigating the root cause. I have filed a JIRA ticket: NCL-2656. </div><div>Thanks again,</div><div>Adam</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, Sep 12, 2017 at 7:43 AM, Dave Macleod <span dir="ltr"><<a href="mailto:David.Macleod@physics.ox.ac.uk" target="_blank">David.Macleod@physics.ox.ac.<wbr>uk</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">




<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt">Hi,<br>
<div style="font-family:Times New Roman;color:#000000;font-size:16px">
<div>
<div style="direction:ltr;font-family:Tahoma;color:#000000;font-size:10pt"><br>
Long time user, first time emailer ... thanks for all the hard work on NCL! FYI, I believe I have found a bug in calculate_daily_values.<br>
<br>
The argument "nDim" is meant to identify the time dimension, but in fact the function only works correctly when nDim=0 (in the case of 2,3,4-dimensional data), and nDim=1 (in the case of 5D data).<br>
<br>
I have copied a MWE below to demonstrate. But I have traced the problem to point of the statistical operation in the function (e.g. line 18402 in /contributed.ncl, NCL v 6.4.0):<br>
<br>
> xStat(:,nt,:,:,:)  = dim_avg_n( x(:,it,:,:,:), nDim)<br>
<br>
Here "nDim" specifies the dimension on which to carry out the averaging and "it" is the index corresponding to day "nt" . Since "it" is hard-coded on dimension #1, any value of nDim not equal to 1 will not produce the correct result.
<br>
<br>
Similarly for the 2,3,4D case, <br>
> xStat(nt,:,:,:)  = dim_avg_n( x(it,:,:,:), nDim)<br>
<br>
...requires nDim=0.<br>
<br>
A quick fix would be to modify the 5D case such that it require nDim=0, then add a error condition that nDim=0. Or something more clever to preserve the functionality of nDim! (I think there is also an issue where the xStat is defined according to dimx).<br>
<br>
NB, from the code I think the same error may affect calculate_monthly_values and possibly calculate_segment_values, though I haven't tested this.<br>
<br>
All the best,<br>
Dave MacLeod<br>
------------------------------<wbr>-------<br>
Postdoctoral Research Scientist<br>
Atmospheric Oceanic and Planetary Physics, University of Oxford<br>
<br>
<br>
MWE demonstrating the problem described above:<br>
<div><font size="2" color="000000"><br>
</font>
<div style="font-family:Tahoma;font-size:13px"><font size="2" color="000000"></font>
<div style="font-family:Tahoma;font-size:13px"><font size="2" color="000000"></font>
<div style="font-family:Tahoma;font-size:13px"><font size="2" color="000000"></font>
<div style="font-family:Tahoma;font-size:13px"><font size="2" color="000000"></font>
<div style="font-family:Tahoma;font-size:13px"><font size="2" color="000000"></font>
<div style="font-family:Tahoma;font-size:13px"><font size="2" color="000000"></font>
<div style="font-family:Tahoma;font-size:13px"><font size="2" color="000000">load "$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/contributed.ncl"<br>
begin<br>
<br>
; 2D, 3D, 4D data: only works if nDim=0<br>
x4D=random_uniform(-1.0,1.0,(/<wbr>4,4,4,4/))        ; dummy data<br>
nDim=0                        <wbr>                  ; choose a dimension to be 'time' - CHANGE
<font color="000000">FROM A <font color="000000">V<font color="000000">ALUE DIFFERENT
<font color="000000">FROM </font></font></font>ZERO TO BREAK</font></font><br>
x4D!nDim="time"               <wbr>          ; add metadata; 4 points, over 2 days<br>
x4D&time=fspan(0.25,1.75,4)<br>
x4D&time@units="days since 2017-09-12"<br>
printVarSummary(x4D)<br>
x4DDay = calculate_daily_values (x4D, "avg",nDim, False)<br>
printVarSummary(x4DDay)<br>
<br>
<br>
; 5D data: only works if nDim=1<br>
x5D=random_uniform(-1.0,1.0,(/<wbr>4,4,4,4,4/))      ; dummy data<br>
nDim=1                        <wbr>                  ; choose a dimension to be 'time'<font size="2" color="000000"><font size="2" color="000000"><font color="000000">
</font>- CHANGE <font color="000000">T<font color="000000">O A VALUE <font color="000000">
DIFFERENT</font></font><font color="000000"> FROM ONE</font> TO BREAK<br>
</font></font>x5D!nDim="time"               <wbr>          ; add metadata; 4 points, over 2 days<br>
x5D&time=fspan(0.25,1.75,4)<br>
x5D&time@units="days since 2017-09-12"<br>
printVarSummary(x5D)<br>
x5DDay = calculate_daily_values (x5D, "avg",nDim, False)<br>
printVarSummary(x5DDay)<br>
end</font><br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

<br></div></div><span class="">______________________________<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></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div class="m_3477741275224888400gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div><div><span><font color="#888888">Adam Phillips <br></font></span></div><span><font color="#888888">Associate Scientist,  </font></span><span><font color="#888888">Climate and Global Dynamics Laboratory, NCAR<br></font></span></div></div><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank">www.cgd.ucar.edu/staff/<wbr>asphilli/</a>   </font></span><span><font color="#888888"><a href="tel:(303)%20497-1726" value="+13034971726" target="_blank">303-497-1726</a> </font></span></div><span><font color="#888888"></font></span><div><div><span><font color="#888888"><br></font></span><div><span><font color="#888888"><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank"></a></font></span></div></div></div></div></div></div></div></div></div></div></div>
</font></span></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>