-
Notifications
You must be signed in to change notification settings - Fork 16
csv file time history #115
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
base: main
Are you sure you want to change the base?
Changes from 9 commits
e6bb395
aed0699
c2e36f7
b846996
abe35c4
c35b681
5d851fd
5e31e4f
a7976a9
52243bd
26ccdd6
fc124a9
d023bc0
d91b4f1
af3145c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| Main ChemKED module | ||
| """ | ||
| # Standard libraries | ||
| from os.path import exists | ||
| from os.path import exists, isabs, dirname, join | ||
| from collections import namedtuple | ||
| from warnings import warn | ||
| from copy import deepcopy | ||
|
|
@@ -111,8 +111,10 @@ def __init__(self, yaml_file=None, dict_input=None, *, skip_validation=False): | |
| if yaml_file is not None: | ||
| with open(yaml_file, 'r') as f: | ||
| self._properties = yaml.safe_load(f) | ||
| directory = dirname(yaml_file) | ||
| elif dict_input is not None: | ||
| self._properties = dict_input | ||
| directory = None | ||
| else: | ||
| raise NameError("ChemKED needs either a YAML filename or dictionary as input.") | ||
|
|
||
|
|
@@ -121,7 +123,7 @@ def __init__(self, yaml_file=None, dict_input=None, *, skip_validation=False): | |
|
|
||
| self.datapoints = [] | ||
| for point in self._properties['datapoints']: | ||
| self.datapoints.append(DataPoint(point)) | ||
| self.datapoints.append(DataPoint(point, directory)) | ||
|
|
||
| self.reference = Reference( | ||
| volume=self._properties['reference'].get('volume'), | ||
|
|
@@ -589,6 +591,7 @@ class DataPoint(object): | |
|
|
||
| Arguments: | ||
| properties (`dict`): Dictionary adhering to the ChemKED format for ``datapoints`` | ||
| directory (`str`, optional): Directory to look for auxiliary files | ||
|
|
||
| Attributes: | ||
| composition (`list`): List of dictionaries representing the species and their quantities | ||
|
|
@@ -631,7 +634,7 @@ class DataPoint(object): | |
| 'compression-ratio' | ||
| ] | ||
|
|
||
| def __init__(self, properties): | ||
| def __init__(self, properties, directory=''): | ||
| for prop in self.value_unit_props: | ||
| if prop in properties: | ||
| quant = self.process_quantity(properties[prop]) | ||
|
|
@@ -685,7 +688,10 @@ def __init__(self, properties): | |
| values = np.array(hist['values']) | ||
| else: | ||
| # Load the values from a file | ||
| values = np.genfromtxt(hist['values']['filename'], delimiter=',') | ||
| filename = hist['values']['filename'] | ||
| if not isabs(filename): | ||
| filename = join(directory, filename) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will fail if the input is a
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changing the default directory to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that change will fix the problem on this line, because the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. I just pushed another commit so that |
||
| values = np.genfromtxt(filename, delimiter=',') | ||
|
|
||
| time_history = TimeHistory( | ||
| time=Q_(values[:, time_col], time_units), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| --- | ||
| file-authors: | ||
| - name: Kyle E Niemeyer | ||
| ORCID: 0000-0003-4425-7097 | ||
| file-version: 0 | ||
| chemked-version: 0.0.1 | ||
| reference: | ||
| doi: 10.1002/kin.20180 | ||
| authors: | ||
| - name: Gaurav Mittal | ||
| - name: Chih-Jen Sung | ||
| ORCID: 0000-0003-2046-8076 | ||
| - name: Richard A Yetter | ||
| journal: International Journal of Chemical Kinetics | ||
| year: 2006 | ||
| volume: 38 | ||
| pages: 516-529 | ||
| detail: Fig. 6, open circle | ||
| experiment-type: ignition delay | ||
| apparatus: | ||
| kind: rapid compression machine | ||
| institution: Case Western Reserve University | ||
| facility: CWRU RCM | ||
| datapoints: | ||
| - temperature: | ||
| - 297.4 kelvin | ||
| ignition-delay: | ||
| - 1.0 ms | ||
| pressure: | ||
| - 958.0 torr | ||
| composition: | ||
| kind: mole fraction | ||
| species: | ||
| - species-name: H2 | ||
| InChI: 1S/H2/h1H | ||
| amount: | ||
| - 0.12500 | ||
| - species-name: O2 | ||
| InChI: 1S/O2/c1-2 | ||
| amount: | ||
| - 0.06250 | ||
| - species-name: N2 | ||
| InChI: 1S/N2/c1-2 | ||
| amount: | ||
| - 0.18125 | ||
| - species-name: Ar | ||
| InChI: 1S/Ar | ||
| amount: | ||
| - 0.63125 | ||
| ignition-type: | ||
| target: pressure | ||
| type: d/dt max | ||
| rcm-data: | ||
| compression-time: | ||
| - 38.0 ms | ||
| time-histories: | ||
| - type: volume | ||
| time: | ||
| units: s | ||
| column: 0 | ||
| quantity: | ||
| units: cm3 | ||
| column: 1 | ||
| values: | ||
| filename: rcm_history.csv | ||
| ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is now 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.