<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
There was one not insignificant thing I didn’t mention.
<div class=""><br class="">
</div>
<div class="">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 class="">So when it tries to save to that cell, there are two values for the @b and @b95. </div>
<div class=""><br class="">
</div>
<div class="">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 class=""><br class="">
</div>
<div class="">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 class="">But I don’t know how to keep only one value of those pair of calculated stats.</div>
<div class=""><br class="">
</div>
<div class="">Cheers,</div>
<div class="">Andreas</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div>
<blockquote type="cite" class="">
<div class="">On 5 Jun 2017, at 17:17, Adam Phillips <<a href="mailto:asphilli@ucar.edu" class="">asphilli@ucar.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class=""><font face="arial, helvetica, sans-serif" class="">Hi Andreas,</font>
<div class=""><font face="arial, helvetica, sans-serif" class="">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_<wbr class="">coeff. If you
<i class="">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 class=""><font face="arial, helvetica, sans-serif" class=""><br class="">
</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class="">finarr = new((/22,22,2/),typeof(value_test))</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class="">finarr!0 = "startyear"</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class="">finarr&startyear = ispan(1980,2001,1)</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class="">finarr!1 = "endyear"</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class="">finarr&endyear = ispan(1989,2010,1)</font></div>
<div class="">
<div class=""><font face="arial, helvetica, sans-serif" class="">finarrZ = new((/22,22,2,2/),</font><span style="font-family:arial,helvetica,sans-serif" class="">typeof(value_test))</span></div>
<div class=""><font face="arial, helvetica, sans-serif" class="">finarrZ!0 = "startyear"</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class="">finarrZ&startyear = ispan(1980,2001,1)</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class="">finarrZ!1 = "endyear"</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class="">finarrZ&endyear = ispan(1989,2010,1)</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""><br class="">
</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class="">do i=1980,2001,1</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> do j=1989,2010,1</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> ntimes=ispan(i,j,1)</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> if (j-i .ge. 9 ) then</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> test_rc=regline_stats(ntimes,<wbr class="">value_test({i:j}))</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> print(test_rc)</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> start_date=i</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> end_date=j</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> finarr({i},{j},0) = test_rc@b*10 ; prints slope of the linear trend for the selected range of years</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> finarr({i},{j},1) = test_rc@b95 ; prints 2.5% and 97.5% regression coefficient confidence intervals </font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> finarrZ(</font><span style="font-family:arial,helvetica,sans-serif" class="">{i},{j},0,0) = test_rc@b*10</span><span style="font-family:arial,helvetica,sans-serif" class=""> </span></div>
<div class=""><span style="font-family:arial,helvetica,sans-serif" class="">
</span><font face="arial, helvetica, sans-serif" class=""> finarrZ(</font><span style="font-family:arial,helvetica,sans-serif" class="">{i},{j},1,1) = </span><span style="font-family:arial,helvetica,sans-serif" class="">test_rc@b95 </span></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> else </font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> print(“this age range has not been selected, since its less than 9 years")</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> end if </font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> delete(ntimes)</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class=""> end do</font></div>
<div class=""><font face="arial, helvetica, sans-serif" class="">end do </font></div>
</div>
<div class=""><br class="">
</div>
<div class="">Hope that helps. If you have any further questions please respond to the ncl-talk email list.</div>
<div class="">Adam</div>
<div class=""><br class="">
</div>
</div>
<div class="gmail_extra"><br class="">
<div class="gmail_quote">On Mon, Jun 5, 2017 at 9:48 AM, Andreas Chrysanthou <span dir="ltr" class="">
<<a href="mailto:eeac@leeds.ac.uk" target="_blank" class="">eeac@leeds.ac.uk</a>></span> wrote:<br class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word" class="">
<div id="m_5767769911056133050divtagdefaultwrapper" dir="ltr" class="">
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
Hi NCL users,</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
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;" class="">
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 class="">
</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
(1980-1989, 1980-1990, 1980-1991,..., 1980-2010</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
1981-1990, 1981-1991, ..., 1981-2010</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
...</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
...</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
...</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
2000-2009, 2001-2010<br class="">
</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
2001-2010)</p>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt" class="">
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_<wbr class="">coeff)</div>
<div style="margin-top:0px;margin-bottom:0px;font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt" class="">
<span style="font-size:12pt" class="">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" class="">
<span style="font-size:12pt" class=""><br class="">
</span></div>
<div style="margin-top:0px;margin-bottom:0px" class=""><font face="Calibri, Arial, Helvetica, sans-serif" size="3" class="">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;" class="">
<br class="">
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
A snippet of the code follows:</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div class="">
<div class=""><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: inherit;" class="">do i=1980,2001,1</span></div>
<div class=""><font face="Calibri, Arial, Helvetica, sans-serif" size="3" class=""> </font><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: inherit;" class="">do j=1989,2010,1</span></div>
<div class=""><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: inherit;" class=""> ntimes=ispan(i,j,1)</span></div>
<div class=""><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: inherit;" class="">if (j-i .ge. 9 ) then</span></div>
<div class=""><font face="Calibri, Arial, Helvetica, sans-serif" size="3" class="">
</font><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: inherit;" class=""> test_rc=regline_stats(ntimes,<wbr class="">value_test({i:j}))</span></div>
<div class=""><font face="Calibri, Arial, Helvetica, sans-serif" size="3" class=""> print(test_rc)</font></div>
<div class=""><font face="Calibri, Arial, Helvetica, sans-serif" size="3" class=""> start_date=i</font></div>
<div class=""><font face="Calibri, Arial, Helvetica, sans-serif" size="3" class=""> end_date=j</font></div>
<div class=""><font face="Calibri, Arial, Helvetica, sans-serif" size="3" class=""> trend_slope=test_rc@b*10 ; prints slope of the linear trend for the selected range of years</font></div>
<div class=""><font face="Calibri, Arial, Helvetica, sans-serif" size="3" class=""> reg_coeff=test_rc@b95 ; prints 2.5% and 97.5% regression coefficient confidence intervals </font></div>
<div class=""><font face="Calibri, Arial, Helvetica, sans-serif" size="3" class="">else print(“this age range has not been selected, since its less than 9 years")</font></div>
<div class=""><font face="Calibri, Arial, Helvetica, sans-serif" size="3" class=""> end if </font></div>
<div class=""><font face="Calibri, Arial, Helvetica, sans-serif" size="3" class=""> delete(ntimes)</font></div>
<div class=""><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: inherit;" class="">end do</span></div>
<div class=""><span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: inherit;" class="">end do </span></div>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
Cheers,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
Andreas</div>
<span class="HOEnZb"><font color="#888888" class="">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</div>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</p>
<p style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<br class="">
</p>
<div id="m_5767769911056133050Signature" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt;" class="">
<div id="m_5767769911056133050divtagdefaultwrapper" dir="ltr" style="font-size: 12pt; font-family: Calibri, Arial, Helvetica, sans-serif;" class="">
<font face="HelveticaNeue-Light" size="1" class=""><span style="font-size:13px;font-weight:normal;text-transform:none" class="">
<div class="">
<div style="white-space:normal" class="">
<div style="white-space:normal" class="">
<div style="white-space:normal" class="">
<div style="white-space:normal" class="">
<div class="">Andreas</div>
<br class="">
</div>
</div>
</div>
</div>
</div>
</span></font>
<p class=""><br class="">
</p>
</div>
</div>
</font></span></div>
</div>
<br class="">
______________________________<wbr class="">_________________<br class="">
ncl-talk mailing list<br class="">
<a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">
List instructions, subscriber options, unsubscribe:<br class="">
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">http://mailman.ucar.edu/<wbr class="">mailman/listinfo/ncl-talk</a><br class="">
<br class="">
</blockquote>
</div>
<br class="">
<br clear="all" class="">
<div class=""><br class="">
</div>
-- <br class="">
<div class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div class="">
<div class="">
<div class=""><span class=""><font color="#888888" class="">Adam Phillips <br class="">
</font></span></div>
<span class=""><font color="#888888" class="">Associate Scientist, </font></span><span class=""><font color="#888888" class="">Climate and Global Dynamics Laboratory, NCAR<br class="">
</font></span></div>
</div>
<div class=""><span class=""><font color="#888888" class=""><a href="http://www.cgd.ucar.edu/staff/asphilli/" target="_blank" class="">www.cgd.ucar.edu/staff/asphilli/</a>
</font></span><span class=""><font color="#888888" class="">303-497-1726 </font></span></div>
<span class=""><font color="#888888" class=""></font></span>
<div class="">
<div class=""><span class=""><font color="#888888" class=""><br class="">
</font></span>
<div class=""><span class=""><font color="#888888" class=""><a href="http://www.cgd.ucar.edu/staff/asphilli" target="_blank" class=""></a></font></span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>