-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsobpplot.py
More file actions
41 lines (29 loc) · 797 Bytes
/
Copy pathsobpplot.py
File metadata and controls
41 lines (29 loc) · 797 Bytes
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
# sobpplot.py
# Plot SOBP generated by Geant4 (CSV format).
import g4score
import matplotlib as mpl
mpl.use('Agg')
import pylab as pl
def sobpplot(fname):
x,x2,d = g4score.getxz(fname)
title = 'Proton Spread-out Bragg Peak'
xlabel = 'Depth (mm)'
ylabel = 'Dose (arbitrary units)'
## Add light grey grid
pl.figure()
ax=pl.axes()
ax.set_axisbelow(True)
pl.grid(color='lightgrey', zorder=20)
pl.title(title,weight='bold')
pl.xlabel(xlabel)
pl.ylabel(ylabel)
# Plot out to 140 mm
x = x[:141] # Use with Geant4.9.4
#x = x2[:141] # Use with Geant4.9.3
d = d[:141]
pl.plot(x,d,linewidth=2)
pl.savefig('sobp-demo.png')
if __name__ == '__main__':
import sys
fname = sys.argv[1]
sobpplot(fname)