<div dir="ltr"><div><div><div><div><div><div><div>When posting to ncl-talk, it is best to always include a printVarSummary(...) of pertinent variables. EG:<br><br></div><div>printVarSummary(data)<br></div>printVarSummary(<span style="line-height:1.5">datareverse)<br><br>--<br></span></div><div><span style="line-height:1.5">This is wrong:<br> </span>data&month=(/6,7,8,9,10,11,12,<wbr>1,2,3,4,5/)<br><br></div><div>The & means a "coordinate variable" (CV). By definition, a CV is monotonic. Your assignment is not monotonic.<br><br></div><div>Given the way you have done things, I think the following should work<br><br><span style="line-height:1.5"> data!0="index"</span><br> data&index=ispan(1,12,1)<br></div><div> datareverse = data(la|:,index|:)<br></div><div><span style="line-height:1.5">--<br></span></div><span style="line-height:1.5">Why are you manually specifying the years?<br><br></span>year1=(/1980,1981,1982,1983,19<wbr>84,1985,1986,1987,1988,1989,19<wbr>90,1991,1992,1993,1994,1995,19<wbr>96,1997,1998,1999,2000/)<br><br></div><div>Use the ispan function<br></div><div><br></div>year1 = ispan(1980, 2000,1)<br><br></div>or, better programming practice<br><br></div>yrStrt = 1980<br></div>yrLast = 2000<br>year1 = ispan(yrStrt,yrLast,1)<br><br>===<br></div><div>Use a function to make your code cleaner. <br>Use _n and _n_Wrap, if possible.<br><br></div><div>undef("rc_month")<br></div><div>function rc_month(file_name[1]:string, var_name[1]:string, yrStrt[1]:integer, yrLast[1]:yrLast)<br></div><div>local f, t, year, t1new, rc<br></div><div>begin<br></div><div><div> f = addfile(file_name,"r")</div><div> t = short2flt( f1->$var_name$ )</div><div> year = ispan(yrStrt, yrLast,1)<br></div><div><br></div><div> tZon = dim_avg_n_Wrap(t,2)</div><div> rc = regCoef_n(year, tZon, 0, 0)<br></div><div> return(rc)<br></div><div>end<br><br></div><div>then use<br><br></div><div>rc1 = rc_month("JanTmon.nc", "t", yrStrt, yrLast)<br></div><div>rc2 = rc_month("FebTmon.nc", "t", yrStrt, yrLast)<br><br></div><div>Please read the NCL manuals about procedures and functions.<br><br><a href="http://www.ncl.ucar.edu/Document/Manuals/">http://www.ncl.ucar.edu/Document/Manuals/</a><br><br></div><div>In particular, the DKRZ tutorials<br><br>===<br></div><div>Respond only to ncl-talk ... not directly to me.<br></div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Sep 27, 2016 at 6:18 AM, WIND <span dir="ltr"><<a href="mailto:954051157@qq.com" target="_blank">954051157@qq.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Hi all,</div><div>I'm working on a latitude v.s. month contour plot. But it's hard for me to change the xArray and says irregular coordinate array sfXArray non-monotonic: defaulting sfXArray . It's appreciate if you could help me check my script. Thanks a lot!</div><div><br></div><div><div>f1 = addfile("JanTmon.nc","r")</div><div>t1 = short2flt( f1->t )</div><div>year1=(/1980,1981,1982,1983,<wbr>1984,1985,1986,1987,1988,1989,<wbr>1990,1991,1992,1993,1994,1995,<wbr>1996,1997,1998,1999,2000/)</div><div>tt1=t1(:,:,0)</div><div>ttt1=dim_avg_n(t1,2)</div><div>copy_VarMeta(tt1,ttt1)</div><div>t1new=ttt1(latitude|:,time|:)</div><div>rc1 = regCoef(year1,t1new)</div><div><span style="line-height:1.5">f2 = addfile("FebTmon.nc","r")</span></div><div>t2 = short2flt( f2->t )</div><div>year2=(/1980,1981,1982,1983,<wbr>1984,1985,1986,1987,1988,1989,<wbr>1990,1991,1992,1993,1994,1995,<wbr>1996,1997,1998,1999,2000/)</div><div>tt2=t2(:,:,0)</div><div>ttt2=dim_avg_n(t2,2)</div><div>copy_VarMeta(tt2,ttt2)</div><div>t2new=ttt2(latitude|:,time|:)</div><div>rc2 = regCoef(year2,t2new)</div><div><span style="line-height:1.5">f3 = addfile("MarTmon.nc","r")</span></div><div>t3 = short2flt( f3->t )</div><div>year=(/1980,1981,1982,1983,<wbr>1984,1985,1986,1987,1988,1989,<wbr>1990,1991,1992,1993,1994,1995,<wbr>1996,1997,1998,1999,2000/)</div><div>tt3=t3(:,:,0)</div><div>ttt3=dim_avg_n(t3,2)</div><div>copy_VarMeta(tt3,ttt3)</div><div>t3new=ttt3(latitude|:,time|:)</div><div>rc3 = regCoef(year,t3new)</div><div><span style="line-height:1.5">f4 = addfile("AprTmon.nc","r")</span></div><div>t4 = short2flt( f4->t )</div><div>year=(/1980,1981,1982,1983,<wbr>1984,1985,1986,1987,1988,1989,<wbr>1990,1991,1992,1993,1994,1995,<wbr>1996,1997,1998,1999,2000/)</div><div>tt4=t4(:,:,0)</div><div>ttt4=dim_avg_n(t4,2)</div><div>copy_VarMeta(tt4,ttt4)</div><div>t4new=ttt4(latitude|:,time|:)</div><div>rc4 = regCoef(year,t4new)</div><div><span style="line-height:1.5">f5 = addfile("MayTmon.nc","r")</span></div><div>t5 = short2flt( f5->t )</div><div>year=(/1980,1981,1982,1983,<wbr>1984,1985,1986,1987,1988,1989,<wbr>1990,1991,1992,1993,1994,1995,<wbr>1996,1997,1998,1999,2000/)</div><div>tt5=t5(:,:,0)</div><div>ttt5=dim_avg_n(t5,2)</div><div>copy_VarMeta(tt5,ttt5)</div><div>t5new=ttt5(latitude|:,time|:)</div><div>rc5 = regCoef(year,t5new)</div><div><span style="line-height:1.5">f6 = addfile("JunTmon.nc","r")</span></div><div>t6 = short2flt( f6->t )</div><div>year=(/1980,1981,1982,1983,<wbr>1984,1985,1986,1987,1988,1989,<wbr>1990,1991,1992,1993,1994,1995,<wbr>1996,1997,1998,1999,2000/)</div><div>tt6=t6(:,:,0)</div><div>ttt6=dim_avg_n(t6,2)</div><div>copy_VarMeta(tt6,ttt6)</div><div>t6new=ttt6(latitude|:,time|:)</div><div>rc6 = regCoef(year,t6new)</div><div><span style="line-height:1.5">f7 = addfile("JlyTmon.nc","r")</span></div><div>t7 = short2flt( f7->t )</div><div>year=(/1980,1981,1982,1983,<wbr>1984,1985,1986,1987,1988,1989,<wbr>1990,1991,1992,1993,1994,1995,<wbr>1996,1997,1998,1999,2000/)</div><div>tt7=t7(:,:,0)</div><div>ttt7=dim_avg_n(t7,2)</div><div>copy_VarMeta(tt7,ttt7)</div><div>t7new=ttt7(latitude|:,time|:)</div><div>rc7 = regCoef(year,t7new)</div><div><span style="line-height:1.5">f8 = addfile("AugTmon.nc","r")</span></div><div>t8 = short2flt( f8->t )</div><div>year=(/1980,1981,1982,1983,<wbr>1984,1985,1986,1987,1988,1989,<wbr>1990,1991,1992,1993,1994,1995,<wbr>1996,1997,1998,1999,2000/)</div><div>tt8=t8(:,:,0)</div><div>ttt8=dim_avg_n(t8,2)</div><div>copy_VarMeta(tt8,ttt8)</div><div>t8new=ttt8(latitude|:,time|:)</div><div>rc8 = regCoef(year,t8new)</div><div><span style="line-height:1.5">f9 = addfile("SepTmon.nc","r")</span></div><div>t9 = short2flt( f9->t )</div><div>year=(/1980,1981,1982,1983,<wbr>1984,1985,1986,1987,1988,1989,<wbr>1990,1991,1992,1993,1994,1995,<wbr>1996,1997,1998,1999,2000/)</div><div>tt9=t9(:,:,0)</div><div>ttt9=dim_avg_n(t9,2)</div><div>copy_VarMeta(tt9,ttt9)</div><div>t9new=ttt9(latitude|:,time|:)</div><div>rc9 = regCoef(year,t9new)</div><div><span style="line-height:1.5">f10 = addfile("OctTmon.nc","r")</span></div><div>t10 = short2flt( f10->t )</div><div>year=(/1980,1981,1982,1983,<wbr>1984,1985,1986,1987,1988,1989,<wbr>1990,1991,1992,1993,1994,1995,<wbr>1996,1997,1998,1999,2000/)</div><div>tt10=t10(:,:,0)</div><div>ttt10=dim_avg_n(t10,2)</div><div>copy_VarMeta(tt10,ttt10)</div><div>t10new=ttt10(latitude|:,time|:<wbr>)</div><div>rc10 = regCoef(year,t10new)</div><div><span style="line-height:1.5">f11 = addfile("NovTmon.nc","r")</span></div><div>t11 = short2flt( f11->t )</div><div>year=(/1980,1981,1982,1983,<wbr>1984,1985,1986,1987,1988,1989,<wbr>1990,1991,1992,1993,1994,1995,<wbr>1996,1997,1998,1999,2000/)</div><div>tt11=t11(:,:,0)</div><div>ttt11=dim_avg_n(t11,2)</div><div>copy_VarMeta(tt11,ttt11)</div><div>t11new=ttt11(latitude|:,time|:<wbr>)</div><div>rc11 = regCoef(year,t11new)</div><div><span style="line-height:1.5">f12 = addfile("DecTmon.nc","r")</span></div><div>t12 = short2flt( f12->t )</div><div>year=(/1980,1981,1982,1983,<wbr>1984,1985,1986,1987,1988,1989,<wbr>1990,1991,1992,1993,1994,1995,<wbr>1996,1997,1998,1999,2000/)</div><div>tt12=t12(:,:,0)</div><div>ttt12=dim_avg_n(t12,2)</div><div>copy_VarMeta(tt12,ttt12)</div><div>t12new=ttt12(latitude|:,time|:<wbr>)</div><div>rc12 = regCoef(year,t12new)</div><div><br></div><div><span style="line-height:1.5">data=new((/12,dimsizes(rc12)/)<wbr>,float)</span></div><div>data(0,:)=rc6</div><div>data(1,:)=rc7</div><div>data(2,:)=rc8</div><div>data(3,:)=rc9</div><div>data(4,:)=rc10</div><div>data(5,:)=rc11</div><div>data(6,:)=rc12</div><div>data(7,:)=rc1</div><div>data(8,:)=rc2</div><div>data(9,:)=rc3</div><div>data(10,:)=rc4</div><div>data(11,:)=rc5</div><div>data=data*10</div><div><span style="line-height:1.5">lat=f1->latitude</span></div><div><span style="line-height:1.5">data!1="la"</span></div><div><span style="line-height:1.5">lat=f1->latitude</span></div><div>data&la=lat</div><div><span style="line-height:1.5">data!0="month"</span></div><div>data&month=(/6,7,8,9,10,11,12,<wbr>1,2,3,4,5/)</div><div>datareverse=data(la|:,month|:)</div><div>wks = gsn_open_wks("eps" ,"12") </div><div><span style="line-height:1.5">res = True </span></div><div><span style="line-height:1.5">res@cnLevelSelectionMode = "ManualLevels"</span></div><div>resources@tmXBMode = "Explicit" </div><div>resources@tmXBValues = ispan(0,12,1); Values from 0 to 12.</div><div>resources@tmXBLabels = (/"J","J","A","S","O","N","D",<wbr>"J","F","M","A","M"/)</div><div><span style="line-height:1.5">res@cnMinLevelValF = -4</span></div><div>res@cnMaxLevelValF = 4</div><div>res@cnLevelSpacingF = 0.5 </div><div><span style="line-height:1.5">plot = gsn_csm_contour(wks,<wbr>datareverse,res) </span></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>