Skip to content
rockdoc edited this page Nov 15, 2012 · 17 revisions

About cdlparser

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.

Package Dependencies

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.

Usage

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.

Unsupported Features

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!

Clone this wiki locally