[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: routine for GRIB data



Kwangwoo <kwcho@kei.re.kr> wrote in message
86fe0ca1.0107022006.5d36b49a@posting.google.com">news:86fe0ca1.0107022006.5d36b49a@posting.google.com...
> I am looking for a IDL routine which can read the GRIB format data
> file.  The data I would like to read now is the NCEP reanalysis data
> (monthly mean UFLUX and VFLUX). I appreciate for your cooperation.
>
> Kwangwoo
>
> --------------------------------------------
> Kwangwoo Cho
> Global Environment Research Center
> Korea Environment Institute (KEI)
> 613-2 Pulgwang-Dong Eunpyong-Gu
> Seoul 122-706 Korea
> Tel: 82-2-380-7615
> Fax: 82-2-380-7688
> Email: kwcho@kei.re.kr
> --------------------------------------------


I use the NetCDF ncep files. They are large, but IDL handles the NetCDF
nicely.
Below is an example piece of code that will print out file information from
a NCEp NetCDF file.

The ftp site is:
archive.cdc.noaa.gov

and data on pressure levels can be found at:
/Datasets/archive0/ncep.reanalysis/pressure/

Note: archive0 is for a certain time period, also check archive1,archive2
etc...


Cheers,
bob stockwell
colorado research associates






; open and read the (HUGE) netcdf file


Filename =' put file name here!!'


Cdfid = NCDF_OPEN( Filename )

glob = NCDF_INQUIRE(Cdfid)
print
print,'_____ glob  _____________'
help,glob,/st
print
print
print,'_____ info _____________'
print,'     ',' i ',' : ','name',' : ','size'
names = strarr(glob.ndims)
sizes = lonarr(glob.ndims)
for i = 0,glob.ndims-1 do begin
 NCDF_DIMINQ, Cdfid, i, Name, Size
 names(i) = name
 sizes(i) = size
 print,i,' : ',name,' : ',size
endfor

help,Cdfid
print
print, ' ________  Variables   ___________'
 for i=0,glob.nvars-1 do begin

  ; Get information about the variable
  info = ncdf_varinq(cdfid, i)
  FmtStr = '(A," (",A," ) Dimension Ids = [ ", 10(I0," "),$)'
  print, FORMAT=FmtStr, info.name,info.datatype, info.dim[*]
  print, ']'

  ; Get attributes associated with the variable
  for j=0,info.natts-1 do begin
   attname = ncdf_attname(cdfid,i,j)
   ncdf_attget,cdfid,i,attname,attvalue
   print,' Attribute ', attname, '=', string(attvalue)
  endfor
 endfor


levelid = NCDF_VARID(Cdfid, 'level')
NCDF_VARGET, Cdfid,levelid, level
help,level

levelid = NCDF_VARID(Cdfid, 'lon')
NCDF_VARGET, Cdfid,levelid, lon
help,lon

levelid = NCDF_VARID(Cdfid, 'lat')
NCDF_VARGET, Cdfid,levelid, lat
help,lat

levelid = NCDF_VARID(Cdfid, 'time')
NCDF_VARGET, Cdfid,levelid, time
help,time

NCDF_CLOSE, Cdfid


end