<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="">Alan,<div class=""><br class=""></div><div class="">That is how it should be, and I agree that people should consider concise and efficient approach in coding. However, I wasn’t sure what such changes(rewriting the entire code) would mean to Thierno and the original aim.</div><div class=""><br class=""></div><div class="">Jack</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 29 Sep 2015, at 21:18, Alan Brammer &lt;<a href="mailto:abrammer@albany.edu" class="">abrammer@albany.edu</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_default" style="font-family:verdana,sans-serif">Looks like You got things sorted with Jack pretty well.&nbsp;</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:verdana,sans-serif">I went through and cleaned up your code a little, to make it a little more concise in my opinion.&nbsp; Functionally it will be the same, but if you go through and understand my changes here it may help you in the future.&nbsp;</div><div class="gmail_default" style="font-family:verdana,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:verdana,sans-serif"><div class="gmail_default">f1 = "Europe_bis_ncl.txt"</div><div class="gmail_default"><br class=""></div><div class="gmail_default">EU &nbsp; &nbsp; = readAsciiTable(f1,7,"float",1)</div><div class="gmail_default">EU@_FillValue = -9999</div><div class="gmail_default">EU!0 = "time"</div><div class="gmail_default">EU!1 = "variable"</div><div class="gmail_default">;; if the dimeensions are named they can be reordered very easily.&nbsp;<br class=""></div><div class="gmail_default"><br class=""></div><div class="gmail_default">;************************************************</div><div class="gmail_default">; to plot multiple lines, you must put them into</div><div class="gmail_default">; a mulidimensional array</div><div class="gmail_default">;************************************************</div><div class="gmail_default"><br class=""></div><div class="gmail_default">nraw = 8</div><div class="gmail_default">ncol = 276</div><div class="gmail_default">nmax = ncol/12 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;</div><div class="gmail_default"><br class=""></div><div class="gmail_default">EU_plot &nbsp; &nbsp; &nbsp;= new((/nraw,ncol/),float, EU@_FillValue)</div><div class="gmail_default">EU_plot(:6,:) = EU(variable|:, time|120:395) &nbsp;; name the dimensions and reorder easily.&nbsp;</div><div class="gmail_default">EU_plot(7,:) = dim_avg_n(EU_plot(0:6,:),0)</div><div class="gmail_default">&nbsp;</div><div class="gmail_default">EUmax := new((/nraw,nmax/),float, EU_plot@_FillValue)</div><div class="gmail_default"><br class=""></div><div class="gmail_default"><br class=""></div><div class="gmail_default">;; rather than having 3 different iterable integers, simplify things with an array up front.&nbsp;</div><div class="gmail_default">;;;;</div><div class="gmail_default">t_lbd = ispan(0, ncol-12, 12) &nbsp; ; &nbsp;lower bounds to find max over.</div><div class="gmail_default">t_ubd = t_lbd + 11 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;; &nbsp;upper bounds to find max over.&nbsp;</div><div class="gmail_default"><br class=""></div><div class="gmail_default"><br class=""></div><div class="gmail_default">do t=0,dimsizes(t_lbd)-1</div><div class="gmail_default">&nbsp; EUmax(:,t) = dim_max_n(EU_plot(:,t_lbd(t):t_ubd(t)),1) &nbsp; ;; use the array based functions where possible.</div><div class="gmail_default">end do</div><div class="gmail_default"><br class=""></div><div class="gmail_default">print(EUmax)</div><div class=""><br class=""></div></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br class=""></div><div class="gmail_default" style="font-family:verdana,sans-serif"><br class=""></div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Sep 29, 2015 at 12:22 PM, Doumbia <span dir="ltr" class="">&lt;<a href="mailto:thiernodoumbia@yahoo.fr" target="_blank" class="">thiernodoumbia@yahoo.fr</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I add some thing in your code and it gives me the good results.<br class="">
yr = i would be yr = i+1.<br class="">
<br class="">
The new script is:<br class="">
<span class="">do n=0,7<br class="">
&nbsp; &nbsp; yr=0<br class="">
&nbsp; &nbsp; k =0<br class="">
&nbsp; &nbsp; do i = 11,275,12<br class="">
&nbsp; &nbsp; &nbsp; &nbsp;EUmax(n,k) = max(EU_plot(n,yr:i))<br class="">
&nbsp; &nbsp; &nbsp; &nbsp;k=k+1<br class="">
</span>&nbsp; &nbsp; &nbsp; &nbsp;yr=i+1<br class="">
&nbsp; &nbsp; end do<br class="">
&nbsp;end do<br class="">
<br class="">
Jack, thank again.<br class="">
Thierno<br class="">
<div class="HOEnZb"><div class="h5"><br class="">
&gt; Le 29 Sep 2015 à 18:02, Doumbia &lt;<a href="mailto:thiernodoumbia@yahoo.fr" class="">thiernodoumbia@yahoo.fr</a>&gt; a écrit :<br class="">
&gt;<br class="">
&gt; Hi Jack,<br class="">
&gt; I really appreciate your teaching skills.<br class="">
&gt;<br class="">
&gt; I recognize that there’s weird things in my script but I apologize for that, I am new in NCL.<br class="">
&gt;<br class="">
&gt; Unfortunately, your suggestions don’t give the good results i.e. the maximum of monthly NO2 data for each year. I compared these results with those obtained from excel.<br class="">
&gt;<br class="">
&gt; You are right, the "EU(120:395,0)” is for 1990 to 2012 (23 years).<br class="">
&gt;<br class="">
&gt; Thank you for your help.<br class="">
&gt;<br class="">
&gt; Thierno<br class="">
&gt;<br class="">
&gt;<br class="">
&gt;&gt;<br class="">
&gt;&gt; ...<br class="">
&gt;&gt; “The results I’ve obtained aren’t what I expected.”<br class="">
&gt;&gt; ...<br class="">
&gt;&gt; Well, even Aristotle would struggle to figure out what you expected if you didn't tell him…<br class="">
&gt;&gt;<br class="">
&gt;&gt; Your script still got visible mistakes though. For example the loop is quite extravagant:<br class="">
&gt;&gt; …<br class="">
&gt;&gt; k = ispan(0,11,1)<br class="">
&gt;&gt; do n=0,7<br class="">
&gt;&gt;&nbsp; do i = 0,275,12<br class="">
&gt;&gt;&nbsp; &nbsp;do j=0,11<br class="">
&gt;&gt;&nbsp; &nbsp; &nbsp;EUmax(n,:) = max(EU_plot(n,i+k(j))) &lt;== “j” will always be the same type as, and equal to “k(j)”?<br class="">
&gt;&gt;&nbsp; &nbsp;end do<br class="">
&gt;&gt;&nbsp; end do<br class="">
&gt;&gt; end do<br class="">
&gt;&gt; …<br class="">
&gt;&gt; and since the left side of your equation has a free dimension, the variable will always be overwritten up to the end of the loop.<br class="">
&gt;&gt;<br class="">
&gt;&gt; You can clean the loop and do something like,<br class="">
&gt;&gt; do n=0,7<br class="">
&gt;&gt;&nbsp; &nbsp; yr=0<br class="">
&gt;&gt;&nbsp; &nbsp; k =0<br class="">
&gt;&gt;&nbsp; &nbsp; do i = 11,275,12<br class="">
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;EUmax(n,k) = max(EU_plot(n,yr:i))<br class="">
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;k=k+1<br class="">
&gt;&gt;&nbsp; &nbsp; &nbsp; &nbsp;yr=i<br class="">
&gt;&gt;&nbsp; &nbsp; end do<br class="">
&gt;&gt; end do<br class="">
&gt;&gt;<br class="">
&gt;&gt; I was also wondering whether from your file “EU(120:395,0)” will give you information from 2000 to 2012(12 years)? Probably that is the unexpected result you mentioned. Who knows?<br class="">
&gt;&gt;<br class="">
&gt;&gt; I hope that helps.<br class="">
&gt;&gt;<br class="">
&gt;&gt; Jack<br class="">
&gt;&gt;<br class="">
&gt;&gt;&gt; On 29 Sep 2015, at 15:02, Doumbia &lt;<a href="mailto:thiernodoumbia@yahoo.fr" class="">thiernodoumbia@yahoo.fr</a>&gt; wrote:<br class="">
&gt;&gt;&gt;<br class="">
&gt;&gt;&gt; Dear ncl users,<br class="">
&gt;&gt;&gt;<br class="">
&gt;&gt;&gt; I am trying to compute the monthly maximum NO2 in a yearly basis.<br class="">
&gt;&gt;&gt;<br class="">
&gt;&gt;&gt; My input file contains 7 columns representing different variables and 396 lines (monthly mean NO2 data from 1980 to 2012). I am only interested by the 2000-2012 period .<br class="">
&gt;&gt;&gt;<br class="">
&gt;&gt;&gt; The results I’ve obtained aren’t what I expected.<br class="">
&gt;&gt;&gt; &lt;max_of_monthly_data.ncl&gt;&lt;Europe_bis_ncl.txt&gt;<br class="">
&gt;&gt;&gt; I will appreciate any help to resolve this.<br class="">
&gt;&gt;&gt;<br class="">
&gt;&gt;&gt; Please find attached my script as well as my input file.<br class="">
&gt;&gt;&gt;<br class="">
&gt;&gt;&gt; Thank you in advance,<br class="">
&gt;&gt;&gt; Thierno<br class="">
&gt;&gt;&gt;<br class="">
&gt;&gt;&gt; _______________________________________________<br class="">
&gt;&gt;&gt; ncl-talk mailing list<br class="">
&gt;&gt;&gt; <a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">
&gt;&gt;&gt; List instructions, subscriber options, unsubscribe:<br class="">
&gt;&gt;&gt; <a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br class="">
&gt;&gt;<br class="">
&gt;<br class="">
<br 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/mailman/listinfo/ncl-talk</a><br class="">
</div></div></blockquote></div><br class=""></div>
_______________________________________________<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="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk<br class=""></div></blockquote></div><br class=""></div></body></html>