Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a summary of data files from the Python interface #586

Closed
bryanwweber opened this issue Jan 10, 2019 · 3 comments · Fixed by #589
Closed

Provide a summary of data files from the Python interface #586

bryanwweber opened this issue Jan 10, 2019 · 3 comments · Fixed by #589

Comments

@bryanwweber
Copy link
Member

Cantera provides several data files in CTI and XML format for use with the Python interface. The directory where these are installed can be found by running

import cantera.data
print(cantera.data.__path__)

It would be useful to provide functions to list the available files and print a summary of each file in the interpreter. Something like

>>> import cantera.data as ctd
>>> print(ctd.files)
['gri30.xml', 'h2o2.xml', ...]
>>> print(ctd.summary('gri30.xml'))
Some text that summarizes gri30.xml, collected from the start of the file, or a comment in the file
@speth
Copy link
Member

speth commented Jan 10, 2019

I would defer this until the YAML format is completed (#584), where we will have a place for this kind of metadata (tentatively, the description key of the YAML file).

This is also kind of dependent on #339, given that most of the input files don't contain a description in any format.

@bryanwweber
Copy link
Member Author

I dunno. I just looked at a few of them, and they either had something as a description (mostly as a # comment), or it was obvious the source (e.g., GRI30). For those that don't have anything, even something like "Example silane chemistry, source unknown" would be good enough. If we can pick something as a "standard" this would probably make a good GSoC project, and if the new YAML format is merged before May, so much the better. I'm thinking either the first contiguous comment block in the file (compatible with both CTI and CTML) or a "module"-level triple-quote string for CTI and comment block for CTML would be the main options for a standard (and leaving the YAML discussion to #584).

@bryanwweber
Copy link
Member Author

OK, given my comments about deprecation of CTI and XML in #584, I realize it probably doesn't make sense to try to standardize a format for metadata in those files. So for now, for this issue, I think what could be done is to generate the list of input files in the data folder where Cantera is installed. This could look something like, in

interfaces/cython/cantera/data/__init__.py:

here = Path(__file__).parent
data_files = [x.name for x in here.iterdir() if not x.name.startswith('__')]

Note: This is probably not enough (for instance, we might want to change which files are excluded), but it gives the idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants