def _get_pedestal(file1, N1): f1 = File(file1) ped = PedestalSimple() for i in range(0, N1): ev = next(f1.Events) Ev = Event(ev) Ev.read() ped.fill_pedestal_event(Ev) ped.finalize_pedestal() return ped
def subtract_pedestal(file1, file2, N1=10000, N2=3000): ped = _get_pedestal(file1, N1) f2 = File(file2) event_hi_gain_before_remove_pedestal = np.zeros((N2, 8, 40)) event_hi_gain_after_remove_pedestal = np.zeros((N2, 8, 40)) event_low_gain_before_remove_pedestal = np.zeros((N2, 8, 40)) event_low_gain_after_remove_pedestal = np.zeros((N2, 8, 40)) for i in range(0, N2): ev = next(f2.Events) Ev = Event(ev) Ev.read() event_hi_gain_before_remove_pedestal[i, :, :] = Ev.samples_high_gain event_low_gain_before_remove_pedestal[i, :, :] = Ev.samples_low_gain remove_pedestal(Ev, ped) event_hi_gain_after_remove_pedestal[i, :, :] = Ev.samples_high_gain event_low_gain_after_remove_pedestal[i, :, :] = Ev.samples_low_gain plot_hist(event_hi_gain_before_remove_pedestal, "Hi Gain") plot_hist(event_hi_gain_after_remove_pedestal, "Hi Gain") plot_hist(event_low_gain_before_remove_pedestal, "Low Gain") plot_hist(event_low_gain_after_remove_pedestal, "Low Gain")
from protozfits.simple import File from enum import Enum import matplotlib.pyplot as plt f = File("Run019_Periodic1kHz.fits.fz") for row in f.RunHeader: pass row._asdict() print(f.Events.header) #32678 / Offset for uint16 event = next(f.Events) event._asdict() print(event._fields) #higain = event.hiGain.waveforms.samples print(event.cameraCounters) print(event.cameraCounters.counters) #lo_gain_samples = toNumPyArray( # event.loGain.waveforms.samples #).reshape(-1, event.loGain.waveforms.num_samples) t = [] time = [] oldtime = []
import matplotlib.pyplot as plt import numpy as np from protozfits.simple import File from pedestal import PedestalSimple, remove_pedestal from event import Event plt.rcParams.update({'font.size': 32}) N1 = 20000 f1 = File("../data/Run021.1.fits.fz") ped = PedestalSimple() for i in range(0, N1): ev = next(f1.Events) Ev = Event(ev) Ev.read() ped.fill_pedestal_event(Ev) ped.finalize_pedestal() N2 = 1000 event_hi_gain_before_remove_pedestal = np.zeros((N2, 8, 40)) event_hi_gain_after_remove_pedestal = np.zeros((N2, 8, 40)) for i in range(0, N2): ev = next(f1.Events) Ev = Event(ev) Ev.read() event_hi_gain_before_remove_pedestal[i, :, :] = Ev.samples_high_gain remove_pedestal(Ev, ped) event_hi_gain_after_remove_pedestal[i, :, :] = Ev.samples_high_gain
high = 0 low = 1 fc = np.zeros((2, 8)) for i in [0, 2, 4, 6]: fc[high][i] = first_capacitor[i] fc[high][i + 1] = first_capacitor[i] for j in [1, 3, 5, 7]: fc[low][j - 1] = first_capacitor[j] fc[low][j] = first_capacitor[j] return fc f = File("Run021.1.fits.fz") N = 15000 n_channels = 8 n_modules = 19 RoI = 40 size4drs = 4 * 1024 hi_gain_samples = np.zeros((N, n_channels, RoI)) low_gain_samples = np.zeros((N, n_channels, RoI)) channel_pedestal = np.zeros((n_channels, 2, size4drs)) number_pedestal_event = np.zeros((n_channels, 2, size4drs)) for i in range(0, N): event = next(f.Events) hiGain, lowGain = translate_fits(event) fc = read_first_capacitor(event)