[Thread Prev][Thread Next][Index]

MISTAKE Converting GMT files to the netCDF format



! mistake below!!

Joe McLean wrote:

Hi Mark,

I haven't done this in a while, but try
yes? fill my_grid
instead of
yes? fill depth[g=my_grid]

and start with a small subset so you can see quickly if it works.
yes? fill my_grid[i=1:300,y=1:200]

Sorry, I meant to type 'j' instead of 'y'
SHOULD BE: yes? fill my_grid[i=1:300,j=1:200]
 

Joe
-----------------------------------

Mark A Ohrenschall wrote:

(Originally posted in the netCDF maillist.)

I'm having trouble applying the tip that Steve gave me in his email, quoted later. Here's what I'm doing:

[mao@panther coastal_relief]$ ferret
        NOAA/PMEL TMAP
        FERRET v5.40
        Linux 2.4.3-12smp - 02/19/02
        09-May-03 15:24

yes? use gulf1.nc
yes? DEFINE AXIS/X=-98:-81/npoints=20401 xax
yes? DEFINE AXIS/Y=24:31/npoints=8401 yax
yes? LET my_grid = RESHAPE(depth, x[gx=xax]+y[gy=yax])
yes? set region/x=-98:-97/y=24:25
yes? fill depth[g=my_grid]
 **ERROR: dimensions improperly specified: must be a 2D region
          CONTOUR/FILL depth[g=my_grid]
yes? show data
     currently SET data sets:
    1> ./gulf1.nc  (default)
 name     title                             I         J         K         L
 X_RANGE                                   1:2       ...       ...       ...
 Y_RANGE                                   1:2       ...       ...       ...
 Z_RANGE                                   1:2       ...       ...       ...
 SPACING                                   1:2       ...       ...       ...
 DIMENSION
                                           1:2       ...       ...       ...
 DEPTH                                     1:171388  ...       ...       ...

yes? show grid my_grid
    GRID (G003)
 name       axis              # pts   start                end
 XAX       X                20401 r   -98                  -81
 YAX       Y                 8401 r   24                   31
 normal    Z
 normal    T
yes?
So what am I doing wrong?

Thanks,

Mark

Steve Hankin wrote:

Hi Mark,

A solution to mention to you because I know that you happen to be a Ferret user:

You can use the Ferret RESHAPE function to "wrap" the 1D array of values given in the GMT netCDF file into its proper 2D gridded configuration.  These 3 commands:

    yes? DEFINE AXIS/X=-98:-81/npoints=20401 xax
    yes? DEFINE AXIS/Y=24:31/npoints=8401 yax
    yes? LET my_grid = RESHAPE(gmt_var, x[xg=xax]+y[gy=yax])

Note, though, that your particular example (20401x8401) will need a LOT of memory.  Since GMT has unwrapped the grid into a 1D array it has eliminated any reasonable possibility of subsetting or striding on the data as it is pulled from netCDF -- two copies of the entire array have to be handled as a block in memory.

Helluva way to use netCDF ...

    - steve

==========================================

Mark A Ohrenschall wrote:

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.

[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement