<div dir="ltr"><div><div>I am not sure what is meant by: "There was one not insignificant thing I didn’t mention"<br><br>---<br></div>As you note:<br><br>"the regline_stats function for the b calculates both the b(0)
+b(1*)x of the linear regression, while the b95 calculates both the 2.5%
and 97.5% regression coefficient confidence intervals. So when it tries to save to that cell, there are two values for the @b and @b95."<br><br></div>Change: <br><div><div><div><font size="3" face="Calibri, Arial, Helvetica, sans-serif"> trend_slope=test_rc@b*10 ; prints slope of the linear trend for the selected range of years</font></div>
<div><font size="3" face="Calibri, Arial, Helvetica, sans-serif"> reg_coeff=test_rc@b95 ; prints 2.5% and 97.5% regression coefficient confidence intervals <br><br></font></div><div><font size="3" face="Calibri, Arial, Helvetica, sans-serif">To extract only one value<br></font></div>
<div><font size="3" face="Calibri, Arial, Helvetica, sans-serif"> trend_slope=test_rc@b(1) *10 ; prints slope of the linear trend for the selected range of years</font></div>
<font size="3" face="Calibri, Arial, Helvetica, sans-serif"> reg_coeff=test_rc@b95(1) ; prints 2.5% and 97.5% regression coefficient confidence intervals <br><br>---<br><br>"</font>4 different columns (start_date, end_date,trend_slope,reg_<wbr>coeff)<br><br>---<br></div><div>The following create 4 (well 3) different columns. I may give you an idea how to proceed. <br></div><div>Also, good programming practice is to use variables and not constants.<br></div><div><br>nyrSpan = 10<br>nyrCrit = 10<br>nyrStrt1 = 1980<br>nyrStrt2 = 2001<br>nyrLast1 = nyrStrt1+nyrSpan-1<br>nyrLast2 = 2010<br><br>NTIM = 1000 ; arbitrary max possible # elements<br>strtYear = new( NTIM, "integer")<br>lastYear = new( NTIM, "integer")<br>trend = new( NTIM, "float")<br>rc = new( NTIM, "float")<br><br>nt = -1<br>do nyrStrt=nyrStrt1,nyrStrt2<br> do nyrLast=nyrLast1,nyrLast2<br> nyrs = nyrLast-nyrStrt+1<br> if (nyrs.ge.nyrCrit) then<br> test_rc = regline_stats(tofloat(ispan(1,nyrSpan,1)),random_normal(-1,1,nyrSpan))<br> nt = nt+1<br> strtYear(nt) = nyrStrt<br> lastYear(nt) = nyrLast<br> spanYear = nyrLast-nyrStrt+1<br> rc(nt) = (/ test_rc /) ; (/.../) no meta data ; same as b(1)<br> ;trend(nt) = ?????<br> print(strtYear(nt)+" "+lastYear(nt)+" "+spanYear+" "+rc(nt))<br> end if<br> end do<br>end do<br><br> print("=================================================")<br> ntim = nt+1 ; # of elements<br> print("ntim="+ntim)<br><br></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 5, 2017 at 11:10 AM, Andreas Chrysanthou <span dir="ltr"><<a href="mailto:eeac@leeds.ac.uk" target="_blank">eeac@leeds.ac.uk</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">
There was one not insignificant thing I didn’t mention.
<div><br>
</div>
<div>the regline_stats function for the b calculates both the b(0) +b(1*)x of the linear regression, while the b95 calculates both the 2.5% and 97.5% regression coefficient confidence intervals.</div>
<div>So when it tries to save to that cell, there are two values for the @b and @b95. </div>
<div><br>
</div>
<div>That’s why I got the error of : "fatal:Dimension sizes on right hand side of assignment do not match dimension sizes of left hand side"</div>
<div><br>
</div>
<div>I only want the slope of the liner trend (b(1)) and my criterion if I need to save these values is that the confidence intervals should not be negative (that would probably need to be included in the if loop). </div>
<div>But I don’t know how to keep only one value of those pair of calculated stats.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>Andreas</div><div><div class="h5">
<div><br>
</div>
<div><br>
</div>
<div>
<div>
<blockquote type="cite">
<div>On 5 Jun 2017, at 17:17, Adam Phillips <<a href="mailto:asphilli@ucar.edu" target="_blank">asphilli@ucar.edu</a>> wrote:</div>
<br class="m_-1930109600680038890Apple-interchange-newline">
<div>
<div dir="ltr"><font face="arial, helvetica, sans-serif">Hi Andreas,</font>
<div><font face="arial, helvetica, sans-serif">As there are singular values for reg_coef and trend_slope for each start and end time, I think it would be best to simply create a 3D array dimensioned (start_date, end_date,2), with the last
dimension (0) = trend_slope and (1) representing reg_coeff. If you
<i>must</i> have a 4-dimensional array then you should create an array that is dimensioned 22 x 22 x 2 x 2, but (:,:,1,0) and (:,:,0,1) will be missing. In the example below I show how to create both types of arrays:</font></div>
<div><font face="arial, helvetica, sans-serif"><br>
</font></div>
<div><font face="arial, helvetica, sans-serif">finarr = new((/22,22,2/),typeof(value_<wbr>test))</font></div>
<div><font face="arial, helvetica, sans-serif">finarr!0 = "startyear"</font></div>
<div><font face="arial, helvetica, sans-serif">finarr&startyear = ispan(1980,2001,1)</font></div>
<div><font face="arial, helvetica, sans-serif">finarr!1 = "endyear"</font></div>
<div><font face="arial, helvetica, sans-serif">finarr&endyear = ispan(1989,2010,1)</font></div>
<div>
<div><font face="arial, helvetica, sans-serif">finarrZ = new((/22,22,2,2/),</font><span style="font-family:arial,helvetica,sans-serif">typeof(<wbr>value_test))</span></div>
<div><font face="arial, helvetica, sans-serif">finarrZ!0 = "startyear"</font></div>
<div><font face="arial, helvetica, sans-serif">finarrZ&startyear = ispan(1980,2001,1)</font></div>
<div><font face="arial, helvetica, sans-serif">finarrZ!1 = "endyear"</font></div>
<div><font face="arial, helvetica, sans-serif">finarrZ&endyear = ispan(1989,2010,1)</font></div>
<div><font face="arial, helvetica, sans-serif"><br>
</font></div>
<div><font face="arial, helvetica, sans-serif">do i=1980,2001,1</font></div>
<div><font face="arial, helvetica, sans-serif"> do j=1989,2010,1</font></div>
<div><font face="arial, helvetica, sans-serif"> ntimes=ispan(i,j,1)</font></div>
<div><font face="arial, helvetica, sans-serif"> if (j-i .ge. 9 ) then</font></div>
<div><font face="arial, helvetica, sans-serif"> test_rc=regline_stats(ntimes,<wbr>value_test({i:j}))</font></div>
<div><font face="arial, helvetica, sans-serif"> print(test_rc)</font></div>
<div><font face="arial, helvetica, sans-serif"> start_date=i</font></div>
<div><font face="arial, helvetica, sans-serif"> end_date=j</font></div>
<div><font face="arial, helvetica, sans-serif"> finarr({i},{j},0) = test_rc@b*10 ; prints slope of the linear trend for the selected range of years</font></div>
<div><font face="arial, helvetica, sans-serif"> finarr({i},{j},1) = test_rc@b95 ; prints 2.5% and 97.5% regression coefficient confidence intervals </font></div>
<div><font face="arial, helvetica, sans-serif"> finarrZ(</font><span style="font-family:arial,helvetica,sans-serif">{i},{j},0,0) = test_rc@b*10</span><span style="font-family:arial,helvetica,sans-serif"> </span></div>
<div><span style="font-family:arial,helvetica,sans-serif">
</span><font face="arial, helvetica, sans-serif"> finarrZ(</font><span style="font-family:arial,helvetica,sans-serif">{i},{j},1,1) = </span><span style="font-family:arial,helvetica,sans-serif">test_rc@b95 </span></div>
<div><font face="arial, helvetica, sans-serif"> else </font></div>
<div><font face="arial, helvetica, sans-serif"> print(“this age range has not been selected, since its less than 9 years")</font></div>
<div><font face="arial, helvetica, sans-serif"> end if </font></div>
<div><font face="arial, helvetica, sans-serif"> delete(ntimes)</font></div>
<div><font face="arial, helvetica, sans-serif"> end do</font></div>
<div><font face="arial, helvetica, sans-serif">end do </font></div>
</div>
<div><br>
</div>
<div>Hope that helps. If you have any further questions please respond to the ncl-talk email list.</div>
<div>Adam</div>
<div><br>
</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Jun 5, 2017 at 9:48 AM, Andreas Chrysanthou <span dir="ltr">
<<a href="mailto:eeac@leeds.ac.uk" target="_blank">eeac@leeds.ac.uk</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">
<div id="m_-1930109600680038890m_5767769911056133050divtagdefaultwrapper" dir="ltr">
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
Hi NCL users,</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
I created a loop for calculating a linear trend sensitivity for different start and end dates. </p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
My timeseries span over 1980-2010 and I want to calculate the linear trend of the timeseries for when the start - end date are more than >= 9years.
<br>
</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
(1980-1989, 1980-1990, 1980-1991,..., 1980-2010</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
1981-1990, 1981-1991, ..., 1981-2010</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
...</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
...</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
...</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
2000-2009, 2001-2010<br>
</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
2001-2010)</p>
<div><br>
</div>
<div><br>
</div>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
I’ve created the loops that calculate those values but I need to save them in an array as 4 different columns (start_date, end_date,trend_slope,reg_coeff<wbr>)</div>
<div style="margin-top:0px;margin-bottom:0px;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-size:12pt">My aim is to plot those as a a contour box plot with x axis the start date and y axis the end date, and the calculated (i’m gonna filter out those values with some criteria) trend values based on a colormap.</span></div>
</div>
<div style="margin-top:0px;margin-bottom:0px;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<span style="font-size:12pt"><br>
</span></div>
<div style="margin-top:0px;margin-bottom:0px"><font size="3" face="Calibri, Arial, Helvetica, sans-serif">Can you help me in order to save the values to that new array so I can plot it?</font></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
A snippet of the code follows:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</div>
<div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:inherit">do i=1980,2001,1</span></div>
<div><font size="3" face="Calibri, Arial, Helvetica, sans-serif"> </font><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:inherit">do j=1989,2010,1</span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:inherit"> ntimes=ispan(i,j,1)</span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:inherit">if (j-i .ge. 9 ) then</span></div>
<div><font size="3" face="Calibri, Arial, Helvetica, sans-serif">
</font><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:inherit"> test_rc=regline_stats(ntimes,v<wbr>alue_test({i:j}))</span></div>
<div><font size="3" face="Calibri, Arial, Helvetica, sans-serif"> print(test_rc)</font></div>
<div><font size="3" face="Calibri, Arial, Helvetica, sans-serif"> start_date=i</font></div>
<div><font size="3" face="Calibri, Arial, Helvetica, sans-serif"> end_date=j</font></div>
<div><font size="3" face="Calibri, Arial, Helvetica, sans-serif"> trend_slope=test_rc@b*10 ; prints slope of the linear trend for the selected range of years</font></div>
<div><font size="3" face="Calibri, Arial, Helvetica, sans-serif"> reg_coeff=test_rc@b95 ; prints 2.5% and 97.5% regression coefficient confidence intervals </font></div>
<div><font size="3" face="Calibri, Arial, Helvetica, sans-serif">else print(“this age range has not been selected, since its less than 9 years")</font></div>
<div><font size="3" face="Calibri, Arial, Helvetica, sans-serif"> end if </font></div>
<div><font size="3" face="Calibri, Arial, Helvetica, sans-serif"> delete(ntimes)</font></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:inherit">end do</span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:inherit">end do </span></div>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
Cheers,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
Andreas</div>
<span class="m_-1930109600680038890HOEnZb"><font color="#888888">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</div>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</p>
<p style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<br>
</p>
<div id="m_-1930109600680038890m_5767769911056133050Signature" style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt">
<div id="m_-1930109600680038890m_5767769911056133050divtagdefaultwrapper" dir="ltr" style="font-size:12pt;font-family:Calibri,Arial,Helvetica,sans-serif">
<font size="1" face="HelveticaNeue-Light"><span style="font-size:13px;font-weight:normal;text-transform:none">
<div>
<div style="white-space:normal">
<div style="white-space:normal">
<div style="white-space:normal">
<div style="white-space:normal">
<div>Andreas</div>
<br>
</div>
</div>
</div>
</div>
</div>
</span></font>
<p><br>
</p>
</div>
</div>
</font></span></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>
<br clear="all">
<div><br>
</div>
-- <br>
<div class="m_-1930109600680038890gmail_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>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</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>