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

1 year ago
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. # Open the file and read in the data
  4. with open('../data/test02.dat', 'r') as f:
  5. lines = f.readlines()
  6. # Extract the second column of data
  7. data = []
  8. for line in lines:
  9. values = line.strip().split()
  10. data.append(float(values[1]))
  11. #determine histrange from data
  12. hist_range = 5 * np.std(data)
  13. hist_mean = np.mean(data)
  14. hist_start = hist_mean - hist_range
  15. hist_end = hist_mean + hist_range
  16. # Create the histogram with range
  17. hist, bins, _ = plt.hist(data, bins=100, range=(hist_start,hist_end))
  18. # Calculate the mean and RMS
  19. bin_centers = 0.5 * (bins[:-1] + bins[1:])
  20. # Set the x-axis label and title
  21. plt.xlabel('Data')
  22. plt.title('Histogram of Data')
  23. # Show the plot
  24. plt.show()
  25. # Print the mean and RMS
  26. print(f"Mean: {np.mean(data):.3g}")
  27. print(f"RMS: {np.std(data):.3g}")