Re: Failed reading ERA Data

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Jul 16 2013 - 13:09:30 MDT

The problem is that ut_inv_calendar returns doubles, and your time array is actually integers.

You can try converting tstart and tlast to integers:

tstart = toint(ut_inv_calendar(2000,1,1,00,0,0,time@units,0))
tlast = toint(ut_inv_calendar(2000,1,1,00,0,0,time@units,0))

In general, I recommend using cd_inv_calendar, because this is newer and has more options.

--Mary

On Jul 16, 2013, at 11:05 AM, Xi Chang wrote:

> Hi All,
>
> I found a strange behavior to read the era40 data via subscripting method,
> Here is a simple code:
>
> begin
>
> ufile = addfile("uwnd.2000.nc","r")
> time = ufile->time
>
> tstart = ut_inv_calendar(2000,1,1,00,0,0,time@units,0)
> tlast = ut_inv_calendar(2000,1,1,00,0,0,time@units,0)
>
> print(tstart)
> print(tlast)
>
> U = short2flt(ufile->uwnd({tstart:tlast},:,:,:))
> printVarSummary (U)
>
> end
>
> However, I got this error:
> fatal:Coordinate subscript type mismatch. Subscript (0) can not be coerced to type of coordinate variable, subscript (0)
>
> It is so strange for me, since I have checked eveything was ok.
>
> Here is the detail of the input data:
>
> dimensions:
> lon = 144 ;
> lat = 73 ;
> lev = 23 ;
> time = UNLIMITED ; // (366 currently)
> variables:
> float lon(lon) ;
> lon:units = "degrees_east" ;
> lon:long_name = "longitude" ;
> float lat(lat) ;
> lat:units = "degrees_north" ;
> lat:long_name = "latitude" ;
> int lev(lev) ;
> lev:units = "millibars" ;
> lev:long_name = "pressure_level" ;
> int time(time) ;
> time:units = "hours since 1900-01-01 00:00:0.0" ;
> time:long_name = "time" ;
> short uwnd(time, lev, lat, lon) ;
> uwnd:scale_factor = 0.00611294863578099 ;
> uwnd:add_offset = -0.00708951113578099 ;
> uwnd:_FillValue = -32767s ;
> uwnd:missing_value = -32767s ;
> uwnd:units = "m s**-1" ;
> uwnd:long_name = "U velocity" ;
>
> thank you for a quick view for this email.
>
> -- Xi
>
>
>
>
> _______________________________________________
> 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 Tue Jul 16 13:09:40 2013

This archive was generated by hypermail 2.1.8 : Tue Jul 16 2013 - 13:21:17 MDT