-
Notifications
You must be signed in to change notification settings - Fork 4
Home
cdlparser implements a Python-based parser for reading files encoded in netCDF-3 Common Data form Language, a.k.a. CDL. The parser logic is based upon the tokens and rules defined in the flex and yacc files used by the ncgen3 utility that ships with the standard netCDF distribution.
The cdlparser module depends upon the following Python packages. If you don't already have them then you'll need to download and install them.
- PLY - http://www.dabeaz.com/ply/
- netcdf4-python - http://code.google.com/p/netcdf4-python/
The basic usage idiom is as follows:
myparser = CDL3Parser(...) ncdataset = myparser.parse_file(cdlfilename, ...)
If the input CDL file is valid then the above code should result in a netCDF-3 file being generated, either in the same directory as the CDL file (and with the .cdl extension replaced with .nc), or else in the location specified via the ncfile keyword argument to the parse() method.
The ncdataset variable returned by the parse_file method is a handle to a netCDF4.Dataset object,
which you can then query and manipulate as you wish.
The following CDL v3 features are not supported by cdlparser:
- Use of the 'l' or 'L' suffix to indicate integer constants. This feature has been deprecated.
- Use of the lexical tokens DoubleInf, NaN, +/-Infinity, FloatInf, +/-Inff. These tokens were used to indicate fill values prior to netCDF 2.4 (according to the ncgen.l file).
Enjoy!