-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgridcollector.py
42 lines (37 loc) · 1.64 KB
/
gridcollector.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
from gridData import Grid
import numpy as np
import re
from pathlib import Path
from SFED_routines import sfed_kh_3drism, integrate_sfed
class GridCollector():
def __init__(self, mol, fname, suffix=["H", "C", "G", "U"]):
self.mol = mol
self.fname = fname
self.suffix = suffix
self.delta = None
self.grids = {}
self.read()
def read(self):
DX = Path(self.fname).glob("*.dx")
files = [p for p in DX if p.is_file()]
if not files:
raise Exception("No .dx files found")
for dx in files:
name = dx.stem.split('.')
if (name[0].endswith("_"+self.suffix[0])):
self.grids[self.suffix[0]+name[1]] = Grid(self.fname + "/" + dx.stem + ".dx")
self.delta = np.prod(self.grids[self.suffix[0]+name[1]].delta)
elif (name[0].endswith("_"+self.suffix[1])):
self.grids[self.suffix[1]+name[1]] = Grid(self.fname + "/" + dx.stem + ".dx")
elif (name[0].endswith("_"+self.suffix[2])):
self.grids[self.suffix[2]+name[1]] = Grid(self.fname + "/" + dx.stem + ".dx")
elif (name[0].endswith("_"+self.suffix[3])):
self.grids[self.suffix[3]+name[1]] = Grid(self.fname + "/" + dx.stem + ".dx")
if not self.grids:
raise Exception("No tagged .dx files found")
if __name__ == "__main__":
base_path = Path(__file__).parent
data_path = file_path = (base_path / "../SFED/data/DATA/KH/").resolve()
print(str(data_path) + "/3methbut1e/3")
gc3methbut1e = GridCollector("3methbut1e", str(data_path) + "/3methbut1e/3")
print(gc3methbut1e.grids)