-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrip3dScatterPlot.py
84 lines (63 loc) · 2.48 KB
/
strip3dScatterPlot.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
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import time, glob, os
def dataConf(fileName):
# geometry_id,hit_id,channel0,channel1,timestamp,value from file './event000000000-cells.csv'
data = pd.read_csv(fileName, usecols=['eventIndex', 'localX', 'localY', 'localZ'])
#conv to df
df = pd.DataFrame(data,columns=['eventIndex', 'localX', 'localY', 'localZ'])
#passes df to plotting func
uniqueEventList = df['eventIndex'].unique().tolist()
del uniqueEventList[0]
print("there are ", len(uniqueEventList), " unique event ids")
print("highest frequency event index: " + str(df['eventIndex'].mode()))
limitsMargin = 25
for id in uniqueEventList:
dataBatch = df.loc[df['eventIndex'] == id]
plot(dataBatch, limitsMargin)
def plot(data, margin):
# configures dataframe data into python lists
localXList = list(data.iloc[:, 1])
localYList = list(data.iloc[:, 2])
localZList = list(data.iloc[:, 3])
xlims = (data['localX'].min() - margin, data['localX'].max() + margin)
ylims = (data['localY'].min() - margin, data['localY'].max() + margin)
zlims = (data['localZ'].min() - margin, data['localZ'].max() + margin)
# create artifical beamline
beamDensisity = 50
zLimRange = zlims[1] - zlims[0]
beamStep = zLimRange/beamDensisity
beamXList = [0] * beamDensisity
beamYList = [0] * beamDensisity
beamZList = []
beamZMaxTemp = zlims[1]
for i in range(beamDensisity):
beamZList.append(beamZMaxTemp)
beamZMaxTemp -= beamStep
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(localXList, localYList, localZList, c='r', marker='o')
ax.scatter(beamXList, beamYList, beamZList, c='b', marker='o')
ax.set_xlim(xlims)
ax.set_ylim(ylims)
ax.set_zlim(zlims)
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
ax.set_title("event id: " + str(int(data['eventIndex'].iloc[0])))
# plt.
plt.tight_layout()
# plt.savefig("./stripHistImages/" + str(int(data['eventIndex'].iloc[0])) + '.pdf', bbox_inches='tight')
plt.show()
#user input for file selection
file = input("Path of file to process: ")
startTime = time.time()
if file == 'del': # delete all files in dir with certain file extention
for filename in glob.glob('./*.png'):
os.remove(filename)
else:
file = './ITk/stripDataV1.csv'
dataConf(file)
endTime = time.time()
print(endTime-startTime)