Re: Daily calendar

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Fri, 19 May 2006 07:25:54 -0600 (MDT)

> My requirement is to assign time coordinates for the data which are supplied
> as individual files for each day.
>
> for example..
> (0) AIRS.2005.07.20.L3.RetStd001.v4.0.9.0.G05203185105.hdf
> (1) AIRS.2005.07.21.L3.RetStd001.v4.0.9.0.G05204161409.hdf
> (2) AIRS.2005.07.22.L3.RetStd001.v4.0.9.0.G05205154813.hdf
>
> these files are for 20/07/2005 to 22/07/2005.
>
> I read these data into an array as
>
> fils = systemfunc("ls AIRS*.hdf")
> nfils = dimsizes(fils)
> nlev = 24
> nlon = 360
> nlat = 180
>
> T_A = new ( (/nfils,nlev,nlat,nlon/), "float")
>
> do nf=0,nfils-1
> f1 = addfile (fils(nf), "r")
> T_A(nf,:,:,:) = f1->Temperature_MW_A
> end do
>
> My ultimate aim is to assign proper time coordinates and do some computation
> and finally write them as netcdf.
>
> Could anyone help me to get the dates from the filename itself and assign
> them as coordinates?
___________________________________________________________________________
function parseFileName (s:string, opt:integer)
begin
   c = stringtochar( s )
   year = stringtointeger( (/ c(5:8) /) )
   mon = stringtointeger( (/ c(10:11) /) )
   day = stringtointeger( (/ c(13:14) /) )

   if (opt.eq.0) then
       date = (/year, mon, day /) ; return a vector of length 3
       date_at_units = "year, month, day"
       return( date)
   end if
   if (opt.eq.1) then
       date = year*10000+ mon*100+ day
       date_at_units = "yyyymmdd"
       return( year*10000+ mon*100+ day ) ; return as yyyymmdd
   end if

end
begin
    fil = "AIRS.2005.07.20.L3.RetStd001.v4.0.9.0.G05203185105.hdf"

    date = parseFileName (fil , 0)
    DATE = parseFileName (fil , 1)

    print(date)
    print(DATE)

end

________________________________________________________
/ptmp/shea>ncl parse.ncl

Variable: date
Type: integer
Total Size: 12 bytes
             3 values
Number of Dimensions: 1
Dimensions and sizes: [3]
Coordinates:
Number Of Attributes: 1
   units : year, month, day
(0) 2005
(1) 7
(2) 20

Variable: DATE
Type: integer
Total Size: 4 bytes
             1 values
Number of Dimensions: 1
Dimensions and sizes: [1]
Coordinates:
(0) 20050720
_____________________________________________________________
Good luck
D
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri May 19 2006 - 07:25:54 MDT

This archive was generated by hypermail 2.2.0 : Fri May 19 2006 - 10:04:53 MDT