-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplotter.py
More file actions
35 lines (29 loc) · 821 Bytes
/
plotter.py
File metadata and controls
35 lines (29 loc) · 821 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
import matplotlib.pyplot as plt
import os
# Detector pixels: find data files
location = os.getcwd()
txtfiles = []
for file in os.listdir(location):
try:
if file.endswith(".txt") and file.startswith("detector"):
txtfiles.append(str(file))
except Exception as e:
raise e
print(txtfiles)
# Initialise plot
fig, ax = plt.subplots(nrows=2, ncols=1)
# Get data
for filename in txtfiles:
file = open(filename, 'r')
data = {}
dim = 0
for line in file:
data[dim] = line.split()
dim += 1
# Add to plot
ax[0].scatter(data[0], data[1], s=0.75, marker='x') # x and y
ax[1].scatter(data[0], data[2], s=0.75, marker='x') # x and z
ax[0].set_title('XY-plane pixel locations')
ax[1].set_title('XZ-plane pixel locations')
plt.axis('equal')
plt.show()