Re: Converting GMT files to the netCDF format



Mark A Ohrenschall wrote:

Hey, I've got a really similar (identical?) problem:

I have a netCDF file that was generated by GMT, and this is what it looks like:

ncdump -v x_range,y_range,z_range,spacing,dimension gulf.nc
netcdf gulf {
dimensions:
       side = 2 ;
       xysize = 171388801 ;
variables:
       double x_range(side) ;
               x_range:units = "" ;
       double y_range(side) ;
               y_range:units = "" ;
       double z_range(side) ;
               z_range:units = "" ;
       double spacing(side) ;
       int dimension(side) ;
       float z(xysize) ;
               z:scale_factor = 1. ;
               z:add_offset = 0. ;
               z:node_offset = 0 ;

// global attributes:
               :title = "" ;
               :source = "" ;
data:
x_range = -98, -81 ;
y_range = 24, 31 ;
z_range = -3706.10009765625, 383 ;
spacing = 0.000833333333333333, 0.000833333333333333 ;
dimension = 20401, 8401 ;
}

It's implicitly a 2-D grid that I'd like to be COARDS-compliant. A colleague on the GMT maillist asked the same basic question on my behalf, and forwarded this response to me:

> From: Norman Vine <nhv@xxxxxxxx>
> Date: Wed May 7, 2003  8:09:26 AM US/Mountain
> To: gmt-help@xxxxxxxxxx
> Subject: [GMT-HELP:10777] RE: GMT to COARDS-compliant netCDF?
> Reply-To: nhv@xxxxxxxx
>
>> Is anyone aware of a utility or procedure to export data from GMT
>> into a
>> COARDS-compliant netCDF file?
>
> If you use Python this is easy enough todo
>
> Several modules build apon the Scientific Python NetCDF
> http://starship.python.net/~hinsen/ScientificPython/ <http://starship.python.net/%7Ehinsen/ScientificPython/>
>
> COARDS specific
> http://www.pyclimate.org/
>
> GMT specific
> http://starship.python.net/crew/jhauser/NCfns.py.html

I've looked a little at www.pyclimate.org, and it doesn't look like a push-button process. It may be more expedient in my case to write a hasty Java program against the Java netCDF API to do this conversion.

I'd be interested in what anyone else has done or can suggest.

Cheers,

Mark

1. COARDS requires lat/lon coordinates, so you need to make sure thats the case.

2. Its pretty easy to use the NcML writer to do this kind of transformation, once you know what metadata you need. Its like using a declarative language instead of a procedural one. Give me the CDL of what you want (or better, run it through thncgen to get a netcdf file) and ill give you the NcML to transform it.

3. I might add an "automatic" converter to particularly important Conventions like COARDS. The rub is that the original file has to have equivilent metadata, and a Convention parser needs to be written for it. Is GMT in that category? Are its conventions published?



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