# Re: time

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Jul 31 2013 - 20:40:03 MDT

You didn't follow my previous email stating that you *must* convert "year" to an integer before you pass subsets of it to yyyymm_time.

You have this code highlighted:

yyyymm = f->time
printVarSummary(yyyymm)
ntime = dimsizes(yyyymm)
year = yyyymm/100
yrs= year(0)
yrl = year (ntime-1)
yyyymm = yyyymm_time(yrs,yrl,"double")
yrfrac = (/ yyyymm_to_yyyyfrac(yyyymm, 0.0) /)

This code must be changed to this:

yyyymm = f->time
printVarSummary(yyyymm)
ntime = dimsizes(yyyymm)
year = yyyymm/100
yrs= toint(year(0)) ; NOTE THE DIFFERENCE ON THIS LINE
yrl = toint(year (ntime-1)) ; NOTE THE DIFFERENCE ON THIS LINE
yyyymm = yyyymm_time(yrs,yrl,"double")
yrfrac = (/ yyyymm_to_yyyyfrac(yyyymm, 0.0) /)

Do you see what I did with "yrs" and "yrl"? I had to use the "toint" function to convert "year(0)" to an integer and "year(ntime-1)" to an integer.

However, I'm not what your "time" values look like, so I'm not sure that simply doing this:

yyyymm = f->time
printVarSummary(yyyymm)
ntime = dimsizes(yyyymm)
year = yyyymm/100

is enough to give you just the years.

and make sure you have the correct time values before you post any more questions about this.

--Mary

On Jul 31, 2013, at 2:02 PM, Setareh Rahimi <setareh.rahimi@gmail.com> wrote:

> The codes I run are below.
>
>
> begin
>
> prc2 = f->precip(:,{-35:37},{344:50})
> yyyymm = f->time
> printVarSummary(yyyymm)
> ntime = dimsizes(yyyymm)
> year = yyyymm/100
> yrs= year(0)
> yrl = year (ntime-1)
> yyyymm = yyyymm_time(yrs,yrl,"double")
> yrfrac = (/ yyyymm_to_yyyyfrac(yyyymm, 0.0) /)
> printVarSummary(prc2)
> dimp = dimsizes(prc2)
> ntim = dimp(0)
> nlat = dimp(1)
> mlon = dimp(2)
>
> len = (/3,6,12,24/)
> klen = dimsizes(len)
> spi = new((/klen,ntim,nlat,mlon/),float)
>
> do k=0,klen-1
> spi(k,:,:,:) = dim_spi_n(prc2, len(k), False, 0)
> end do
>
> print(yyyymm+sprintf("%8.2f",spi(0,:,:,:))\
> +sprintf("%8.2f",spi(1,:,:,:))\
> +sprintf("%8.2f",spi(2,:,:,:))\
> +sprintf("%8.2f",spi(3,:,:,:)))
>
> ;wks = gsn_open_wks ("ps","spi")
> ;res = True
> ;res@gsnDraw = False
> ;res@gsnFrame = False
> ;res@vpHeightF = 0.4
> ;es@vpWidthF = 0.8
> ;res@vpXF = 0.1
> ;res@trYMinF = -3.0
> ;res@trYMaxF = 3.0
> ;res@gsnYRefLine = 0.0
> ;res@xyMonoDashPattern = True
> ;res@xyLineThicknessF = 1
> ;plt = new ( klen, "graphic")
> ;xyLineColors = (/"black","red","blue","green","brown","magenta"/)
> ;do n=0,klen-1
> ; res@xyLineColors = xyLineColors(n)
> ; res@gsnCenterString = "run="+len(n)
> ;plt(n) = gsn_csm_xy (wks,yrfrac,spi(n,:,:,:),res)
> ;end do
> ;resP = True ; modify the panel plot
> ;resP@txString = "SPI: Boulder: 1894-2010"
> ;resP@gsnMaximize = True
> ;gsn_panel(wks,plt,(/2,2/),resP)
>
>
> and this are the errors
>
> Variable: yyyymm
> Type: double
> Total Size: 96 bytes
> 12 values
> Number of Dimensions: 1
> Dimensions and sizes: [time | 12]
> Coordinates:
> time: [-657073..-656739]
> Number Of Attributes: 14
> long_name : Time
> units : days since 1800-1-1 00:00:00
> actual_range : ( -657073, -656739 )
> delta_t : 0000-01-00 00:00:00
> standard_name : time
> axis : T
> coordinate_defines : start
> totalling_period : 0000-01-00 00:00:00
> avg_period : 0030-00-00 00:00:00
> prev_avg_period : 0000-01-00 00:00:00
> climatology : climatology_bounds
> climo_period : 1981/01/01 - 2010/12/31
> ltm_range : ( 66109, 77035 )
> interpreted_actual_range : 0001/01/01 00:00:00 - 0001/12/01 00:00:00
> fatal:Argument type mismatch on argument (0) of (yyyymm_time) can not coerce
> fatal:["Execute.c":8128]:Execute: Error occurred at or near line 15 in file spi2se
>
>
> end
>
>
>
>
>
>
> ---------- Forwarded message ----------
> From: Mary Haley <haley@ucar.edu>
> Date: Wed, Jul 31, 2013 at 8:42 PM
> Subject: Re: time
> To: Setareh Rahimi <setareh.rahimi@gmail.com>
>
>
> I'm taking this offline.
>
> What exactly does your new code look like? Please send me the whole script and not just a subset.
>
> What do you mean "type of time is double"? I never saw a "time" array.
>
> What is the exact error message?
>
> --Mary
>
>
> On Jul 31, 2013, at 12:38 PM, Setareh Rahimi wrote:
>
> > Type of time is double, I repllaced the type of time with double, but got the same error again!!!
> >
> >
> > --
> > S.Rahimi
> >
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> --
> S.Rahimi
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jul 31 20:40:12 2013

This archive was generated by hypermail 2.1.8 : Thu Aug 01 2013 - 15:55:03 MDT