[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: text files to Netcdf format...



>To: address@hidden
>From: "chad saxon" <address@hidden>
>Subject: Re: 20031022: text files to Netcdf format... 
>Organization: HPC
>Keywords: 200310080827.h988RxOb010367, ncgen, text data

Hi Chad,

> hi all.. here is an interesting question.. i have a set of text files that
> represent certain images, but so i can work with the images more freely i
> was wondering if there was a way or many different ways of converting these
> text files to netcdf?? thanks a bunch!

One approach is to convert the text image data into CDL form using
text-processing tools such as awk, shell scripts, or a scripting
language such as Perl, Python, or Ruby.  Then you can use "ncgen -b"
to convert that CDL file to a binary netCDF file.

Another approach is to represent the netCDF file you want in CDL form,
then use the ncgen utility with "-c" or "-f" option to generate a C or
Fortran program that will create that netCDF file.  Then you can just
add a few lines to that program to read the text image data into the
data variables provided in the ncgen-generated program and it should
do what you want.

Finally, if you are already familiar with Perl, Python, or Ruby, they
all have netCDF interfaces so the easiest approach may be to just use
one of those scripting languages to read in the text data and write
out a netCDF file using the appropriate interface.

--Russ

_____________________________________________________________________

Russ Rew                                         UCAR Unidata Program
address@hidden          http://www.unidata.ucar.edu/staff/russ