forked from krebeljk/openInjMoldSim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplot_dt.py
36 lines (30 loc) · 799 Bytes
/
plot_dt.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
import numpy as np
from io import StringIO
import matplotlib.pyplot as plt
import re
import sys
'''
example usage:
python plot_dt.py log.openInjMoldSim
'''
# get data
cas = ''
dcas = ''
with open(str(sys.argv[1])) as origin_file:
data = origin_file.read()
for match in re.findall(r'(?m)^Time\s=.*', data):
cas = cas + match.split('=')[1] + '\n'
for match in re.findall(r'(?m)^deltaT\s=.*', data):
dcas = dcas + match.split('=')[1] + '\n'
cas = np.loadtxt(StringIO(cas))
dcas = np.loadtxt(StringIO(dcas))
# plot
fig, ax = plt.subplots()
ax.set(xlabel='t [s]'
,ylabel='dt [s]'
,title='Time step')
ax.grid()
ax.semilogy(cas, dcas, 'k', label='dt')
# legend = ax.legend(loc='upper right', shadow=True, fontsize='x-large')
plt.show()
# fig.savefig("dt.png")