NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: Converting GMT files to the netCDF format

Roy,


 i converted a GMT grid (small.grd for example) to a .cdf file as 
explained in the GMT documentation using a script which uses the grdinfo 
and grd2xyz commands from the gmt library. i now have small.grd, 
small.cdl, and small.cdf


  i was looking through the code and ncdump does work.. actually when i 
do a :

  ncdump -h small.cdf i got the results
                                   small
                                    {

                                    }

  ..there is not header numbers for the rows, columns, latitude/longitude.

  i tried an ncdump on a netCDF file that i knew was in the right format 
and i get something like this..

                               file {
                                     rows: 300
                                     columns: 100
                                     etc etc
                                    }

                                     all the (x,y,z) coordinates


i have looked deeper into the two files to see whats going on.
typing the command at the prompt: od -c small.cdl | more, i look at the 
first line of the header and i see a \r \n (carriage return & a line 
feed) ..??? 

i do the same for a .cdf file that i know that works and there is only a 
\n (line feed) on the first line. so this is what i do. i take the 
small.cdl file from above and at the prompt type dos2unix small.cdl... 
and guess what, the carriage return is gone and i successfully am able to 
convert it to a .cdf file(using ncgen utility) and thus i can run the 
data and get the visualization that i need. The \r i am seeing is a dos/windows 
thing and not a unix, which explains my dos2unix solution.  

I am on a linux box, which explains why i didnt get any output before on 
the ncdump since the \r is dos/windows. i know this is a lot, but these 
are the initial results and findings if you could email me back. it is 
not 2:45 pm central time and will not be back until Tuesday 13th, so if 
you respond after 4:30 central time you will know why i dont respond 
until then. i hope this helps more.....

Chad 

 On Thu, 8 May 2003, Roy 
Mendelssohn wrote:

> Hi Chad:
> 
> GMT does do netCDF but it follows a specific convention.  What 
> visualization program are you trying to read it in?  Even more 
> importantly, for the GMT netcdf file, can you do the following 
> command (assuming you have the utility and the file is foo.nc):
> 
> ncdump -h foo.nc
> 
> and send the results.  The problem usually resides with the 
> dimensioning of the variables.
> 
> -Roy M.
> 
> 
> At 1:29 PM -0500 5/8/03, Mr. Chad W. Saxon wrote:
> >i'm sorry if i was unclear before.. i am using netCDF. The GMT file is
> >for the most part the same as the netCDF file but there is one or two
> >slight variations. this is the problem i am having when figuring out how
> >my program can read both formats.
> >
> >chad
> >
> >On Thu, 8 May 2003, John Caron wrote:
> >
> >>  Mr. Chad W. Saxon wrote:
> >>
> >>  >hi there everyone. i am new to the list and have an interesting question
> >>  >regarding netCDF. I have two data formats, one in GMT and one in CDF. i
> >>  >have a computer program that uses CDF as a way to read data and
> >>  >visualize it, however the program does not read the GMT format. Is there
> >>  >a simple script or solution to convert the GMT format to CDF? i was
> >>  >thinking there was a GMT command to convert it to CDF format but am
> >>  >uncertain as to what that is. I know there is not much difference between
> >>  >the two, but its enough to cause my program not to run correctly. i hope
> >>  >i have been clear in my problem, and i would appreciate your help. thanks
> >>  >a lot.
> >>  >
> >>  >Chad
> >>  > 
> >>  >
> >>  By "CDF" do you mean "netCDF" ?
> >>
> >>  A "GMT file" might be a netCDF file already, as far as I can tell from:
> >>
> >  > http://gmt.soest.hawaii.edu/gmt/doc/html/GMT_Docs/node108.html
> >  >
> >  > do you know what you have?
> >  >
> 
> 
> -- 
> Roy Mendelssohn
> Pacific Fisheries Environmental Laboratory
> 1352 Lighthouse Avenue
> Pacific Grove, CA 93950-2097
> 
> e-mail: rmendels@xxxxxxxxxxxxx
> voice: (831)-648-9029
> fax: (831)-648-8440
> www: http://www.pfeg.noaa.gov/
> 
> "Old age and treachery will overcome youth and skill."
> 

  • 2003 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: