forked from deepaksamuel/bragg-peak
-
Notifications
You must be signed in to change notification settings - Fork 0
/
erdf.py
33 lines (27 loc) · 1011 Bytes
/
erdf.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
#%%
# creates the erdf file and also plots the erdf curves.
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import os
directory = "data" # the folder containing all the depth-dose data
colnames=['X', 'Y', 'Z', 'Total Dose', 'Total2','Entries']
dd =[]
for i in range(0,298) :
first_val=[]
for file in os.listdir(directory):
filename = os.fsdecode(file)
if filename.endswith(".txt"): #or filename.endswith(".py"):
#print(os.path.join(directory, filename))
df = pd.read_csv(os.path.join(directory, filename),skiprows=3,header=0,names=colnames)
first_val.append(df['Total Dose'][i])
continue
else:
continue
plt.plot(first_val)
dd.append(first_val)
np.savetxt('erdf.txt',dd,delimiter='\t')
plt.show()
# ERDF data: Columns correspond to energy. First column: 100 MeV Last column: 250 MeV, Step: 2 MeV.
# Rows correspond to WEPL. First row: 0 mm; last row: 299 mm; step: 1 mm
# %%