[Thread Prev][Thread Next][Index]
Re: Converting GMT files to the netCDF format --- script
Hi All,
I'm sure others have also already written a script like
this, but here it is what I'm using to convert GMT cdf
files do FERRET cdf...
--------------------------------
gmt2fer.jnl
-----------------------------------------------------
sp echo 's/z/var/' > sed.cmds
sp echo 's/xysivare/xysize/' >> sed.cmds
sp echo 's/xyvar2/xyz2/' >> sed.cmds
sp echo '1,$s/NaN/-1.e+34/g' >> sed.cmds
sp echo '1,$s/nan/-1.e+34/g' >> sed.cmds
def sym tmp *YOUR CHOICE*
def sym gmt_nc *YOUR CHOICE*
def sym fer_nc *YOUR CHOICE*
! -- Ferret doesn't like a var called Z.
! ... Caution, this overwrites original file...
sp ncdump ($gmt_nc) | sed -f sed.cmds | ncgen -o ($tmp)
sp mv ($tmp) ($gmt_nc)
use ($gmt_nc)
def ax/x=`x_range[i=1]`:`x_range[i=2]`:`spacing[i=1]`/units=longitude
xax
def ax/y=`y_range[i=1]`:`y_range[i=2]`:`spacing[i=2]`/units=latitude yax
let tpl = 0*x[gx=xax]+0*y[gy=yax]
let var_r = reshape(var,tpl)
set mem/size=20
save/file=($tmp)/clobber var_r
canc var/all; canc data/all
use/order=X-Y ($tmp)
save/file=($fer_nc)/clobber var_r
-------------------------------------------------------------------
Ansley Manke wrote:
>
> Hi Mark,
> Once you've written a NetCDF file, you can always read it
> and permute or flip the with, for instance, USE/ORDER=X-Y
>
> For a description of this, go to this section in the Users Guide,
> "NetCDF, permuted axes, /ORDER qualifier". The syntax
> must be used carefully. ( I see we need more index entries
> pointing to this information!) Here's one relevant bit:
>
> To indicate that the coordinates along a particular
> axis are reversed from the "right hand rule" ordering,
> for example a Y axis which runs north to south (not
> uncommon in image data), we would precede that axis
> by a minus sign. For example
>
> USE/ORDER=X-Y my_flipped_images.nc
>
> Hope this is what you need!
>
> Ansley Manke
>
> Mark A Ohrenschall wrote:
>
> > Thanks, everyone, for your help -- it works!
> >
> > However, I have one small detail to take care of. The y-axis of the
> > grid
> > in the netCDF file is inverted, and I need to re-order the rows. I
> > tried
> > repeating my steps but this time transposing the coordinates (24 and
> > 31)
> > in the DEFINE AXIS/Y command, but that makes no difference.
> >
> > What can I do to re-order the y-axis?
> >
> > Thanks,
> >
> > Mark
> >
> > Mark A Ohrenschall wrote:
> >
> > > 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])
>
> --
> Ansley Manke Pacific Marine Environmental Laboratory Seattle WA
> (206)526-6246
>
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement