Re: Grads to netcdf

From: Adam Phillips <asphilli_at_nyahnyahspammersnyahnyah>
Date: Wed, 04 Jun 2008 12:52:42 -0600

Hi Gina,

I don't know of an automatic way to do this, but I have some experience
reading in GrADS binary files into NCL based on a .ctl file.

You will need to use fbindirread, and you need to make sure that the
endians match on the machine where the file was written and the machine
you are working on. See the binary file portability section here:
http://www.ncl.ucar.edu/Applications/r-binary.shtml

If 4 variables are stated in the .ctl file, then they will occupy the
first four records of the binary file. Thus, if the control file looks
like this:

DSET ^trpp_varmod_MAM.bin
TITLE Tropopause height
UNDEF 1e20
XDEF 1 LINEAR 0.0 1.0
YDEF 32 LINEAR -85.76 5.53
ZDEF 1 LINEAR 0.0 1.0
TDEF 51 LINEAR jan1950 1yr
VARS 2
var1 1 99 1950-2000 tropopause height
var2 1 99 1979-2000 tropopause height

then to read var1/var2 into ncl you would do this:

var1 = fbindirread("trpp_varmod_MAM_trend.bin",0,(/51,32/),"float")
var2 = fbindirread("trpp_varmod_MAM_trend.bin",1,(/51,32/),"float")

Then you could create/attach metadata if so desired.

You might know all of this already, but hopefully this at least helps.
Adam

Gina Henderson wrote:
> Hi there,
>
> I have a data in the Grads format together with its .ctl file descriptor
> and I am trying to convert it to netcdf. I have seen that there is a
> script to do this on the website using Ruby only. Is there anyone who
> has done this in ncl or fortran before?
>
> Thanks Gina.
>
> --
> Gina Henderson
> Graduate Student
> Department of Geography
> 215 Pearson Hall
> University of Delaware
> Newark DE
> 19718-2541
>
> Email: ginah_at_udel.edu <mailto:ginah_at_udel.edu>
> Ph: 302-831-2344
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
--------------------------------------------------------------
Adam Phillips			             asphilli_at_ucar.edu
National Center for Atmospheric Research   tel: (303) 497-1726
ESSL/CGD/CAS                               fax: (303) 497-1333
P.O. Box 3000				
Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Jun 04 2008 - 12:52:42 MDT

This archive was generated by hypermail 2.2.0 : Wed Jun 04 2008 - 15:43:54 MDT