-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplot3_energies.py
44 lines (35 loc) · 1.14 KB
/
plot3_energies.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
import sys
import os
import glob
import numpy as np
from pyMCDS_cells import pyMCDS_cells
import matplotlib.pyplot as plt
argc = len(sys.argv)-1
print("# args=",argc)
#data_dir = 'output'
if (argc < 1):
# data_dir = int(sys.argv[kdx])
print("Usage: provide output subdir")
sys.exit(-1)
kdx = 1
data_dir = sys.argv[kdx]
print('data_dir = ',data_dir)
os.chdir(data_dir)
xml_files = glob.glob('output*.xml')
os.chdir('..')
xml_files.sort()
#print('xml_files = ',xml_files)
ds_count = len(xml_files)
print("----- ds_count = ",ds_count)
mcds = [pyMCDS_cells(xml_files[i], data_dir) for i in range(ds_count)]
tval = np.linspace(0, mcds[-1].get_time(), ds_count)
print('tval= ',tval)
y_energy = np.array( [mcds[idx].data['discrete_cells']['energy'] for idx in range(ds_count)] )
print('y_energy=',y_energy)
plt.plot(tval, y_energy[:,0], label='cell0', linewidth=1) #, color='lime')
plt.plot(tval, y_energy[:,1], label='cell1', linewidth=1) #, color='lime')
plt.plot(tval, y_energy[:,2], label='cell2', linewidth=1) #, color='lime')
plt.legend(loc='center left', prop={'size': 10})
plt.title(data_dir + ": energies")
#plt.savefig(data_dir + '.png')
plt.show()