How to convert netcdf to ascii

Lee Byerle labyerle at MET.UTAH.EDU
Fri Sep 9 19:20:38 EDT 2005


To get an ascii file for further programming (e.g., without the commas,
semicolons, header info) using ncdump, you can use the -v option and some unix commands:

For instance, if you want the wind variables on a grid (for variable 'wind'):

ncdump -v wind myfile.nc > wind_out

#remove extra characters:
sed 's/,/ /g' wind_out > wind1_out
sed 's/;/ /g' wind1_out > wind2_out
sed 's/}/ /g' wind2_out > wind3_out

#strip top lines of header:
tail +80 wind3_out > wind_ascii_out

good luck,
Lee

On Fri, 9 Sep 2005, volz wrote:

> T is correct. The ncdump command is part of the tools for netcdf. ncdump is included as
> part of the typical install of NetCDF, as I recall.
>
> You will need to install the NetCDF package for your architecture and OS. Try Unidata
> for more info.
>
> http://my.unidata.ucar.edu/content/software/netcdf/index.html
>
> Good luck,
> --
> Karl Volz
>
>
> On Fri, 9 Sep 2005 16:38:18 +1000, Tennessee Leeuwenburg wrote
> > ncdump doesn't come from Grads. It comes from a suite of tools made
> > available by Unidata, and may have to be compiled and installed
> > separately. I'm not a grads expert, so maybe grads does leverage off
> > those tools or something, but they are certainly available independently
> > also.
> >
> > Cheers,
> > -T
> >
> > > Hi,
> > > I have tried to convert netcdf files to the ASCII using following
> > > command:
> > >
> > > ncdump input.nc > output.txt
> > >
> > > where input.nc is my netcdf input file and output.txt would be the
> > > output ASCII file.
> > > This command does not work. It only gives the [WINDOWS-1252?]“Unknown command:
> [WINDOWS-1252?]ncdump”
> > > -message. I have also tried it by writing a simple script test.gs:
> > >
> > > [WINDOWS-1252?]‘sdfopen [WINDOWS-1252?]input.nc’
> > > [WINDOWS-1252?]‘ncdump input.nc > [WINDOWS-1252?]output.txt’
> > >
> > > and then used a command:
> > >
> > > run test
> > >
> > > The same error message comes from that. I.e., sdfopen command works but
> > > the command ncdump [WINDOWS-1252?]doesn’t. I am using Grads version 1.8SL11 and I have
> > > always opened gradsnc with a command
> > >
> > > ga [WINDOWS-1252?]–l
> > >
> > > As I am new with Grads I may not know all (even simplest) things what
> > > should be done, i.e., is there some settings or other, which should be
> > > done before using that command, or could the reason be that the command
> > > ncdump [WINDOWS-1252?]doesn’t work in the version I am using.
> > >
> > > Can anybody help me with this problem, please?
> > >
> > > Best wishes,
> > > Mari Kauhaniemi
>



More information about the gradsusr mailing list