Hi all -
I have a GMT-style bathymetry file that conforms to netcdf conventions
(Ferret will read it), but ends up with reversed latitudes.
The file consists of a 2-d grid given as a single vector ("Z"), with
the grid specifications given in variables X_RANGE, Y_RANGE, DIMENSION.
yes? use 1304785711512.grd
yes? sho dat 1
1> ./1304785711512.grd (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 ... ... ...
Z 1:763420 ... ... ...
yes? list X_RANGE, Y_RANGE, DIMENSION
DATA SET: ./1304785711512.grd
Bathymetry Grid
X: 0.5 to 2.5
Column 1: X_RANGE is X_RANGE (Longitude)
Column 2: Y_RANGE is Y_RANGE (Latitude)
Column 3: DIMENSION
X_RANGE Y_RANGE DIMENSION
1 / 1: 151.8 -11.50 820.0
2 / 2: 152.3 -11.00 931.0
Note that 820*931 = 763420, which is the size of Z.
I can decode this as follows:
- - - - - - -
def sym dimx `dimension[i=1]`
def sym dimy `dimension[i=2]`
define axis/x=`x_range[i=1]`:`x_range[i=2]`/npoints=($dimx)/unit=lon xlon
define axis/y=`y_range[i=1]`:`y_range[i=2]`/npoints=($dimy)/unit=lat ylat
let zz=reshape('Z',x[gx=xlon]+y[gy=ylat])
- - - - - - -
This works fine except for one crucial thing: the latitudes are reversed!
Some experimentation shows that the 1-d array Z contains the 2-d grid
listed in north-to-south order (despite the apparent south-to-north
order of Y_RANGE):
first 820 values are W-E along the northern edge
next 820 values are 1 gridpoint south of the northern edge
...
last 820 values are along the southern edge
Does anybody have a good idea of how to reshape this grid correctly?
Thanks .... Billy K