-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_mds_reader.py
58 lines (42 loc) · 1.68 KB
/
common_mds_reader.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
import os
class CommonMds:
def __init__(self, mds_file, verbose=False):
self.mds_file = mds_file
print(self.mds_file)
assert os.path.isfile(self.mds_file), f"{self.mds_file} does not exist!"
self.verbose = verbose
self.setup_variables()
self.read_mds_file()
def setup_variables(self):
self.no_of_modes = None
self.no_of_nodes = None
self.modes = {}
def read_mds_file(self):
with open(self.mds_file) as f:
if self.verbose:
print("Reading Data")
data = f.readlines()
# -------- BLOCK 1 --------
line = data[0].rstrip().split()
self.no_of_modes = int(line[0])
self.no_of_nodes = int(line[1])
if self.verbose:
print(f"Number of Modes identified as {self.no_of_modes}")
print(f"Number of Nodes identified as {self.no_of_nodes}")
# -------- BLOCK 2 --------
for i in range(1, 1 + self.no_of_modes):
line = data[i].rstrip().split()
self.modes[int(line[0])] = {"Nat Freq rad_s": float(line[1]), "segments": [],"mode_shape": [], "mode_slope": [], "mode_curvature": []}
# -------- BLOCK 3 --------
for line in data[1 + self.no_of_modes:]:
line = line.rstrip().split()
self.modes[int(line[0])]["segments"].append(float(line[1]))
self.modes[int(line[0])]["mode_shape"].append(float(line[2]))
if __name__ == "__main__":
mds = CommonMds(r"C:\Users\domhnall.morrisey\Documents\Python\Shear7 Testing\Unit Test\common.mds", verbose=True)
import matplotlib.pyplot as plt
nodes = [i for i in range(mds.no_of_nodes)]
plt.plot(mds.modes[1]["mode_shape"], nodes)
plt.plot(mds.modes[2]["mode_shape"], nodes)
#plt.plot(mds.modes[20]["mode_shape"], nodes)
plt.show()