[ncl-talk] irregular coordinate array sfXArray non-monotonic: defaulting sfXArray

Dennis Shea shea at ucar.edu
Tue Sep 27 07:52:50 MDT 2016


When posting to ncl-talk, it is best to always include a
printVarSummary(...) of pertinent variables. EG:

printVarSummary(data)
printVarSummary(datareverse)

--
This is wrong:
    data&month=(/6,7,8,9,10,11,12,1,2,3,4,5/)

The & means a "coordinate variable" (CV). By definition, a CV is monotonic.
Your assignment is not monotonic.

Given the way you have done things, I think the following should work

   data!0="index"
   data&index=ispan(1,12,1)
   datareverse = data(la|:,index|:)
--
Why are you manually specifying the years?

year1=(/1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,19
90,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000/)

Use the ispan function

year1 = ispan(1980, 2000,1)

or, better programming practice

yrStrt = 1980
yrLast = 2000
year1 = ispan(yrStrt,yrLast,1)

===
Use a function to make your code cleaner.
Use _n and _n_Wrap, if possible.

undef("rc_month")
function rc_month(file_name[1]:string, var_name[1]:string,
yrStrt[1]:integer, yrLast[1]:yrLast)
local f, t, year, t1new, rc
begin
   f      = addfile(file_name,"r")
   t      = short2flt( f1->$var_name$ )
   year = ispan(yrStrt, yrLast,1)

   tZon = dim_avg_n_Wrap(t,2)
   rc     = regCoef_n(year, tZon, 0, 0)
   return(rc)
end

then use

rc1 = rc_month("JanTmon.nc", "t", yrStrt, yrLast)
rc2 = rc_month("FebTmon.nc", "t", yrStrt, yrLast)

Please read the NCL manuals about procedures and functions.

http://www.ncl.ucar.edu/Document/Manuals/

In particular, the DKRZ tutorials

===
Respond only to ncl-talk ... not directly to me.


On Tue, Sep 27, 2016 at 6:18 AM, WIND <954051157 at qq.com> wrote:

> Hi all,
> 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!
>
> f1     = addfile("JanTmon.nc","r")
> t1  = short2flt( f1->t )
> year1=(/1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,
> 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000/)
> tt1=t1(:,:,0)
> ttt1=dim_avg_n(t1,2)
> copy_VarMeta(tt1,ttt1)
> t1new=ttt1(latitude|:,time|:)
> rc1          = regCoef(year1,t1new)
> f2     = addfile("FebTmon.nc","r")
> t2  = short2flt( f2->t )
> year2=(/1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,
> 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000/)
> tt2=t2(:,:,0)
> ttt2=dim_avg_n(t2,2)
> copy_VarMeta(tt2,ttt2)
> t2new=ttt2(latitude|:,time|:)
> rc2          = regCoef(year2,t2new)
> f3     = addfile("MarTmon.nc","r")
> t3   = short2flt( f3->t )
> year=(/1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,
> 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000/)
> tt3=t3(:,:,0)
> ttt3=dim_avg_n(t3,2)
> copy_VarMeta(tt3,ttt3)
> t3new=ttt3(latitude|:,time|:)
> rc3         = regCoef(year,t3new)
> f4    = addfile("AprTmon.nc","r")
> t4   = short2flt( f4->t )
> year=(/1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,
> 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000/)
> tt4=t4(:,:,0)
> ttt4=dim_avg_n(t4,2)
> copy_VarMeta(tt4,ttt4)
> t4new=ttt4(latitude|:,time|:)
> rc4         = regCoef(year,t4new)
> f5    = addfile("MayTmon.nc","r")
> t5   = short2flt( f5->t )
> year=(/1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,
> 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000/)
> tt5=t5(:,:,0)
> ttt5=dim_avg_n(t5,2)
> copy_VarMeta(tt5,ttt5)
> t5new=ttt5(latitude|:,time|:)
> rc5        = regCoef(year,t5new)
> f6    = addfile("JunTmon.nc","r")
> t6   = short2flt( f6->t )
> year=(/1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,
> 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000/)
> tt6=t6(:,:,0)
> ttt6=dim_avg_n(t6,2)
> copy_VarMeta(tt6,ttt6)
> t6new=ttt6(latitude|:,time|:)
> rc6        = regCoef(year,t6new)
> f7    = addfile("JlyTmon.nc","r")
> t7   = short2flt( f7->t )
> year=(/1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,
> 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000/)
> tt7=t7(:,:,0)
> ttt7=dim_avg_n(t7,2)
> copy_VarMeta(tt7,ttt7)
> t7new=ttt7(latitude|:,time|:)
> rc7        = regCoef(year,t7new)
> f8    = addfile("AugTmon.nc","r")
> t8   = short2flt( f8->t )
> year=(/1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,
> 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000/)
> tt8=t8(:,:,0)
> ttt8=dim_avg_n(t8,2)
> copy_VarMeta(tt8,ttt8)
> t8new=ttt8(latitude|:,time|:)
> rc8        = regCoef(year,t8new)
> f9    = addfile("SepTmon.nc","r")
> t9   = short2flt( f9->t )
> year=(/1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,
> 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000/)
> tt9=t9(:,:,0)
> ttt9=dim_avg_n(t9,2)
> copy_VarMeta(tt9,ttt9)
> t9new=ttt9(latitude|:,time|:)
> rc9       = regCoef(year,t9new)
> f10     = addfile("OctTmon.nc","r")
> t10   = short2flt( f10->t )
> year=(/1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,
> 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000/)
> tt10=t10(:,:,0)
> ttt10=dim_avg_n(t10,2)
> copy_VarMeta(tt10,ttt10)
> t10new=ttt10(latitude|:,time|:)
> rc10          = regCoef(year,t10new)
> f11    = addfile("NovTmon.nc","r")
> t11  = short2flt( f11->t )
> year=(/1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,
> 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000/)
> tt11=t11(:,:,0)
> ttt11=dim_avg_n(t11,2)
> copy_VarMeta(tt11,ttt11)
> t11new=ttt11(latitude|:,time|:)
> rc11       = regCoef(year,t11new)
> f12    = addfile("DecTmon.nc","r")
> t12  = short2flt( f12->t )
> year=(/1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,
> 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000/)
> tt12=t12(:,:,0)
> ttt12=dim_avg_n(t12,2)
> copy_VarMeta(tt12,ttt12)
> t12new=ttt12(latitude|:,time|:)
> rc12       = regCoef(year,t12new)
>
> data=new((/12,dimsizes(rc12)/),float)
> data(0,:)=rc6
> data(1,:)=rc7
> data(2,:)=rc8
> data(3,:)=rc9
> data(4,:)=rc10
> data(5,:)=rc11
> data(6,:)=rc12
> data(7,:)=rc1
> data(8,:)=rc2
> data(9,:)=rc3
> data(10,:)=rc4
> data(11,:)=rc5
> data=data*10
> lat=f1->latitude
> data!1="la"
> lat=f1->latitude
> data&la=lat
> data!0="month"
> data&month=(/6,7,8,9,10,11,12,1,2,3,4,5/)
> datareverse=data(la|:,month|:)
> wks  = gsn_open_wks("eps" ,"12")
> res                  = True
> res at cnLevelSelectionMode = "ManualLevels"
> resources at tmXBMode      = "Explicit"
> resources at tmXBValues    = ispan(0,12,1); Values from 0 to 12.
> resources at tmXBLabels    = (/"J","J","A","S","O","N","D",
> "J","F","M","A","M"/)
> res at cnMinLevelValF       = -4
> res at cnMaxLevelValF       =  4
> res at cnLevelSpacingF      =  0.5
> plot = gsn_csm_contour(wks,datareverse,res)
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160927/206b1581/attachment.html 


More information about the ncl-talk mailing list