Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: st: Reading NetCDF files
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
RE: st: Reading NetCDF files
Date
Thu, 16 Feb 2012 13:06:58 +0000
Despite using climatic data quite frequently, I have not (yet) used NetCDF files or even heard about them until Gordon started this thread. But I typically find myself reading in climatic data from what by Stata standards is a strangely structured text file and then it's half-a-hour of intensive ad hoc coding with -reshape-s, -rename-s and goodness knows what all over the place.
The modern way to do this in Stata would be to write, in Mata, specific software to handle NetCDF that was a translation of (say) C or Java code. There is no doubt that StataCorp are very, very good at writing this kind of program if only they could be convinced that enough users, or potential users, need it. As Gordon himself is not shy of writing Stata programs I read his reluctance to do it as implying that it is not trivial, or if trivial not interesting!
Nick
[email protected]
Gordon Hughes
Thank you for the various suggestions. Some conclusions might be
useful for anyone else facing the same problem:
A. There are quite a number of programs that will extract from or
use data in NetCDF files but all involve a minimum of one or two
intermediate steps before the data can be imported into Stata. It
would be nice to eliminate this, but I don't have the time or
(probably) expertise to take it on because, at a minimum, it will
involve linking C or Fortran programs to Stata.
B. Linux & other Unix derivatives are much better served than either
Windows or Mac OS-X in this area.
C. Almost certainly, the most direct route is to use Matlab which
has built-in routines for accessing NetCDF files. Octave & R provide
alternatives, but the routines are not as convenient and they rely on
user-written packages.
D. There are some nice programs written in Java - hence available on
Windows & Macs - which are designed to display maps and other figures
from NetCDF data. Some contain options to produce text files
containing the data which can be edited for use with
Stata. Personally, I have found Panoply (written and maintained by
people at the NASA GISS centre) very easy to use. It can generate
cdl text files; these are large and a bit tedious to edit but quite
straightforward in format.
Gordon Hughes
[email protected]
At 14:45 15/02/2012, you wrote:
>I don't know of a NetCDF reader, but one alternative to consider
>might be to convert it to another format that is understood by stata.
>There is a JSON reader (user-written insheetjson command, available
>by the stata command "net install insheetjson")
>and there seems to be a NetCDF-to-JSON converter available at:
>
>http://www.unidata.ucar.edu/software/netcdf/software.html#JSON
>
>Just an alternative to consider...
>
>- Erik
>
> > Date: Tue, 14 Feb 2012 18:42:28 +0000
> > From: Gordon Hughes <[email protected]>
> > Subject: st: Reading NetCDF files
> >
> > Dear Statalist,
> >
> > Is anyone aware of a Stata user-written routine or other method of
> > importing data stored in NetCDF files into Stata?
> >
> > As background, NetCDF denotes the Network Common Data Form, a binary
> > file format which is widely used for climate data and other data
> > compiled by geophysicists, earth scientists, etc.
> >
> > There are libraries written in C, Fortran & Java which can be used to
> > read NetCDF files but I was trying to avoid the need to special
> > purpose routines to extract the data. In addition, I believe that
> > there are R modules which can read NetCDF files, but this means a
> > struggle to remember the details of R data structures.
> >
> > I would be very grateful for any suggestions.
> >
> > Gordon Hughes
> > [email protected]
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/