[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: supporting additional file formats?
- Subject: Re: supporting additional file formats?
- Date: Mon, 29 Nov 2004 10:47:30 -0700
Eric Davies wrote:
Is there a mechanism for adding support for new file formats,
similar to the library registration of Convention classes?
Thank you.
Hi Eric:
Yes, and we'd love to include additional file readers in our releases if
possible.
You just need to write a class implementing the
ucar.nc2.IOServiceProvider interface, and register it with
ucar.nc2.NetcdfFile.registerIOProvider().
For readonly files, you dont have to implement the create() and write()
methods. If you arent using structures, you dont have to implement
readNestedData(). All you really need to implement isValidFile(), open()
and read(). Have a look at subclasses of ucar.nc2.iosp for examples. The
gini and dmsp are good places to start.
Sorry not much docs yet, everything is very new. But Id be happy to work
with you to get you going. Heres a little bit of documentation from
latest version of the manual:
7.4 IOServiceProvider
The NetCDF API can be used to access other kinds of scientific data
files. The general mechanism for this is to define a class that
implements */IOServiceProvider/*, and register it with the /NetcdfFile/
class. When a file is opened through /NetcdfFile .open()/, it is first
checked to see if it is a "native" (netcdf3, netcdf4, hdf5) file, then
any registered /IOServiceProvider/s are checked by calling
/isValidFile(). /If this returns true, then a new instance of the class
is used for all I/O to the file.
To register, call one of these static methods in *NetcdfFile*:
static public void registerIOProvider( String iospClassName);
static public void registerIOProvider( Class iospClass);
The /iospClass/ must have a no-argument constructor, and it must
implement the /IOServiceProvider/ interface.
There are several standard IOServiceProvider implementations that ship
with the complete library. If you are trying to minimize code size, you
can leave any of the packages or supporting libraries out. The current
standard implementations include:
* */ucar.nc2.iosp.dmsp/* : DMSP
* */ucar.nc2.iosp.gini/* : GINI
* */ucar.nc2.iosp.grib/* : WMO Grib (version 1 and version 2)