-
Notifications
You must be signed in to change notification settings - Fork 1
/
modeplot.py
executable file
·85 lines (66 loc) · 1.58 KB
/
modeplot.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/python3
import sys
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
# parse arguments
decay = None
wp = None
offset = 0
files = {}
plots = []
i = 1
while i < len(sys.argv):
arg = sys.argv[i]
if arg == '-d':
# theoretical decay rate
i += 1
if i == len(sys.argv): quit(2)
decay = float(sys.argv[i])
elif arg == '-o':
# decay line offset
i += 1
if i == len(sys.argv): quit(2)
offset = float(sys.argv[i])
elif arg == '-w':
# plasma frequency
i += 1
if i == len(sys.argv): quit(2)
wp = float(sys.argv[i])
else:
# arguments take the form mode,file
split = arg.find(',')
if split > 0:
mode = arg[:split]
fname = arg[split+1:]
plots.append((mode,fname))
files[fname] = None
i += 1
# read files
for fname in files:
files[fname] = pd.read_csv(fname)
plt.figure()
for modename,fname in plots:
rawdata = files[fname]
time = rawdata['time'].values
if wp != None: time = time * wp
mode = rawdata['m' + modename].values
tmpname = fname
## hack for specific files
#if 'asdff' in fname: tmpname = 'PIF'
#if 'asdfo' in fname: tmpname = 'PIC'
plt.plot(time, np.log10(mode), label = 'Mode ' + modename + ', ' + tmpname)
#plt.plot(time, np.log10(mode), label = 'mode ' + modename)
if decay != None:
y0 = np.log10(mode[0]) + offset
if wp != None:
plt.plot([0, 3 * wp], [y0, y0 - 3 / np.log(10) * decay])
else:
plt.plot([0, 3], [y0, y0 - 3/np.log(10) * decay])
if wp != None:
plt.xlabel(r'$\omega_p t$', fontsize=20)
else:
plt.xlabel('Time', fontsize=16)
plt.ylabel('log(E)', fontsize=16)
plt.legend(loc=4)
plt.show()