-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfitjob_neg_vals
executable file
·50 lines (39 loc) · 1.33 KB
/
fitjob_neg_vals
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
#!/usr/bin/env python3
# coding: utf-8
import sys
from pathlib import Path
import argparse
import os
try:
import numpy as np
except ModuleNotFoundError:
sys.exit("Module 'numpy' not installed. Exiting.")
def main():
parser = argparse.ArgumentParser(
description='Q-CHEM JOB INFO\nSearch recursively for all .out files and get general info.')
parser.add_argument("-s", "--save", nargs='?', const="neg_vals.csv", type=str,
help="Save output. Name is optional. Defaults to 'neg_vals.csv'.")
args = parser.parse_args()
num_rcts = 718
data = [["functional", "omega", "percentage"]]
for path in sorted(Path(".").rglob("res*")):
num_neg_vals = 0
with open(path) as f:
for line in f:
if " -" in line:
num_neg_vals += 1
pct_neg_vals = round(num_neg_vals/num_rcts*100, 1)
print(f"File {path} contains {pct_neg_vals}% negative values.")
if args.save:
p = path.name.lstrip("res_")
func = p.split("_")[0]
omega = p.split("_")[1].split(".")[0]
data.append([func, omega, pct_neg_vals])
# save
if args.save:
data = np.asarray(data, dtype=str)
save_loc = os.path.join(os.path.realpath("."), args.save)
np.savetxt(save_loc, data, fmt='%s', delimiter="\t")
print("\nSaved data to {}.".format(save_loc))
if __name__ == '__main__':
main()