Re: Grads Binary file

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Sat, 4 Mar 2006 08:22:21 -0700 (MST)

Thx for posting the information below. We like it when people post!!

A few minor comments:

[1] It is not necessary to create strings and then convert to integer.
    A more efficient way:

    yrStrt = 1982
    yrLast = 2002

    nmos = 12
    nyrs = yrLast-yrStrt+1
    ntim = nmos*nyrs
    time = new ( ntim , "integer")
    delete(time@_FillValue)

    nt = 0
    do year=yrStrt,yrLast
       time(nt:nt+nmos-1) = year*100 + ispan(1,nmos,1) ; array syntax
       nt = nt+nmos
    end do

[2] There are functions in contributed.ncl [a033] that create the
    desired arrays:

    load ".../contributed.ncl"

    time = yyyymm_time(yrStrt, yrLast, "integer") ; yyyymm
    lat = latGlobeFo (nlat, "lat", "latitude", "degrees_north")
    lon = lonGlobeFo (nlon, "lon", "longitude","degrees_east")

http://www.ncl.ucar.edu/Document/Functions/Contributed/yyyymm_time.shtml
http://www.ncl.ucar.edu/Document/Functions/Contributed/latGlobeFo.shtml
http://www.ncl.ucar.edu/Document/Functions/Contributed/lonGlobeFo.shtml

also, fyi

http://www.ncl.ucar.edu/Document/Functions/Contributed/latGlobeF.shtml
http://www.ncl.ucar.edu/Document/Functions/Contributed/lonGlobeF.shtml

nice for plotting
http://www.ncl.ucar.edu/Document/Functions/Contributed/yyyymm_to_yyyyfrac.shtml

Regards
D

On Sat, 4 Mar 2006, Prince K. Xavier wrote:

>
> I'm a GrADS user too..
>
> During my transition to NCL I too am facing the same problem. What I do is
> to convert the Grads file to NetCDF with the 'lats4d' package in Grads.
> Then use the 'addfile' command to read the netcdf.
>
> Else, to read the binary file of Grads, one has to supply all the
> attributes explicitly to the data read with 'fbindirread'
>
> Please see a NCL script segment.
>
>
> fname = "/user1/prince/Reynolds/1x1/sstan_jan1982_dec2002.grd"
>
> ntim = 252
> nlat = 180
> nlon = 360
>
> lonL = 0
> lonR = 360
> latS = -89.5
> latN = 89.5
>
> years = sprinti("%4i",ispan(1982,2002,1)) ; write integers
> as string
> months = sprinti("%0.2i", ispan(1,12,1)) ; ditto for
> months
>
> time = new(dimsizes(years)*dimsizes(months),"integer") ; create
> time array
> k=0
> do i=0,dimsizes(years)-1
> do j = 0, dimsizes(months)-1
> time(k)=stringtointeger(years(i)+months(j)) ; combine to
> strings
> k=k+1 ; and
> convert to int
> end do
> end do
>
>
> lat = fspan(latS,latN,nlat)
> lat_at_units = "degrees_north"
>
>
> lon = fspan(lonL,lonR,nlon)
> lon_at_units = "degrees_east"
>
> sst = fbindirread(fname,0,(/ntim,nlat,nlon/), "float")
>
> sst!0 = "time"
> sst!1 = "lat"
> sst!2 = "lon"
>
> time_at_long_name = "time"
> time_at_units = "yyyymm"
>
> sst&time = time
> sst&lat = lat
> sst&lon = lon
> sst@_FillValue = -32767
>
> ------------------------------------------
>
> Hope this helps!
> Prince
>
> On Fri, 3 Mar 2006, Dennis Shea wrote:
>
> >
> > Well, I am not a GrADS user :-)
> > so I do not know. You may have to go to the GrADS
> > WWW and read about it.
> >
> > GrADS format is basically a flat binary file.
> >
> > I speculate that the following will work.
> >
> > rain = fbindirread("1991new.grads", 0, 365, "float")
> > print(rain)
> >
> > ==========================================================================
> > > On Thu, 2 Mar 2006, sahana_paul wrote:
> >>
> > Hi,
> > I have dat in grads binary file say temp.grads and descripter file
> > temp.ctl and temp.map also. Is it possible to use this file in NCL or anyother
> > way to convert it netcdf, grib, or any other file format.
> >
> >> I have station data, so how to assaign the lat lon to the
> >> perticular station.
> >> my ctl file is,
> >>
> >> dset ^1991new.grads
> >> dtype station
> >> stnmap 1991new.map
> >> undef -9999.00
> >> title rain
> >> tdef 365 linear 01jan1991 1dy
> >> vars 1
> >> rain 0 99 rain
> >> endvars
> >>
> >> in that case I cannot use the grads2nc.
> >>
> >> regards
> >>
> >> sahana
> >>
> >
> > _______________________________________________
> > ncl-talk mailing list
> > ncl-talk_at_ucar.edu
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
>
> --
> Prince K XAVIER
> Centre for Atmospheric and Oceanic Sciences
> Indian Institute of Science
> Bangalore - 560 012
> INDIA
> http://caos.iisc.ernet.in/hpg/students/prince.html
> __________________________________________________
> Phone No.
> +91 80 2293 2505 (Extn:201)
> +91 98808 19172 (Mobile)
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sat Mar 04 2006 - 08:22:21 MST

This archive was generated by hypermail 2.2.0 : Wed Mar 08 2006 - 17:08:41 MST