Coder Social home page Coder Social logo

cdlparser's People

Contributors

rockdoc-mo avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

cdlparser's Issues

Tidy up t_IDENT method

The t_IDENT method finishes up with the line

return(t)

which looks like a copy-and-paste mis-cue. Works fine, but looks odd.

Add better exception handling

Better exception handling is required in a number of places, particularly the p_xxx methods which construct the in-memory netCDF structures.

Add parse_data method

Add a parse_data() method to the CDLParser base class so that client code can pass in CDL input text as a plain string. The existing parse_file() method can then simply call the proposed new method having read in the text from the CDL file.

It would be nice to support general-purpose stream input, but I don't think the underlying PLY parser supports that approach - need to check this.

Add a CDL4Parser class

Adding an extra class to handle parsing of CDL files that adhere to the netCDF-4 syntax is a longer term goal. The CDL4 grammar is significantly more complex than that used in CDL3, so it's a non-trivial task.

Incorrect handling of fill values for record variables

In the case of record variables which contain fill values (using '_' in the data block), an error is thrown if the specification of the data for the unlimited dimension appears after the record variable in the data block. If the unlimited dimension data precedes the record variable in the data block then all is well.

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "cdlparser.py", line 177, in parse_file
    return self.parse_text(data, ncfile=ncfile)
  File "cdlparser.py", line 204, in parse_text
    self.parser.parse(input=cdltext, lexer=self.lexer)
  File "/Users/phil/lib/python/ply/yacc.py", line 265, in parse
    return self.parseopt_notrack(input,lexer,debug,tracking,tokenfunc)
  File "/Users/phil/lib/python/ply/yacc.py", line 971, in parseopt_notrack
    p.callable(pslice)
  File "cdlparser.py", line 639, in p_datadecl
    self.write_var_data(var, arr)
  File "cdlparser.py", line 812, in write_var_data
    raise CDLContentError(errmsg)
cdlparser.CDLContentError: Error attempting to write data array for variable tas
Exception details are as follows:
could not convert string to float: _

Syntax error raised if a global attribute is defined before dimensions section

If a global attribute is defined ahead of the dimensions block, as shown in the CDL snippet below, then a CDLSyntaxError exception is raised. Although it's rare in practice, this is valid CDL, as evinced by the fact that this CDL example is handled correctly by the ncgen utility.

netcdf unusual_order {

// global attributes
:comment = "blah blah" ;

dimensions:
   x = 10 ;
   y = 20 ;
...
}

Version numbering

The cdlparser module is currently versioned using the 'version' attribute, which has to be updated manually, and is something that is easy to overlook. Can we have git automatically increment the version number? Or at least some kind of build number?

Implement a dry-run option

A dry-run option would be useful for those situations where, for example, you maybe want to check the syntax of a CDL file without actually creating a netCDF output file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.