readout software for 2 channels [0 and 1] of the tdc-gpx2 board with raspberry pi 3B SPI readout.
This code is a fork of the original design by marvin.peter@physik.uni-giessen.de
https://github.com/marvin5300/tdc-gpx2_software
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
873 B
35 lines
873 B
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
# Open the file and read in the data
|
|
with open('../data/test02.dat', 'r') as f:
|
|
lines = f.readlines()
|
|
|
|
# Extract the second column of data
|
|
data = []
|
|
for line in lines:
|
|
values = line.strip().split()
|
|
data.append(float(values[1]))
|
|
|
|
#determine histrange from data
|
|
hist_range = 5 * np.std(data)
|
|
hist_mean = np.mean(data)
|
|
hist_start = hist_mean - hist_range
|
|
hist_end = hist_mean + hist_range
|
|
|
|
# Create the histogram with range
|
|
hist, bins, _ = plt.hist(data, bins=100, range=(hist_start,hist_end))
|
|
|
|
# Calculate the mean and RMS
|
|
bin_centers = 0.5 * (bins[:-1] + bins[1:])
|
|
|
|
# Set the x-axis label and title
|
|
plt.xlabel('Data')
|
|
plt.title('Histogram of Data')
|
|
|
|
# Show the plot
|
|
plt.show()
|
|
|
|
# Print the mean and RMS
|
|
print(f"Mean: {np.mean(data):.3g}")
|
|
print(f"RMS: {np.std(data):.3g}")
|