-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupdate_properties.py
63 lines (51 loc) · 1.62 KB
/
update_properties.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Process a properties file output by Psi4 and add to properties.
Update the properties dictionary in the psi4_metadata to add their
properties and method from the properties.json file output during
a run of Psi4.
"""
import json
import argparse
from psi4_step import properties
def analyze(data, properties):
method = data['_method']
for key, value in data.items():
if key[0] == '_':
continue
if key in properties:
metadata = properties[key]
methods = metadata['methods']
if method not in methods:
methods.append(method)
methods.sort()
else:
properties[key] = {
"calculation": [
"energy",
"optimization",
"thermodynamics",
"vibrations"
],
"dimensionality": "scalar",
'methods': [method],
"description": "",
"type": "float",
"units": ""
}
if isinstance(value, list):
properties[key]["dimensionality"] = [len(value)]
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument(
'file',
type=str,
nargs='+',
help="The 'properties.json' files to process"
)
args = parser.parse_args()
for filename in args.file:
with open(filename) as fd:
data = json.load(fd)
analyze(data, properties)
print(json.dumps(properties, sort_keys=True, indent=4))