diff --git a/libeos/file_reader.py b/libeos/file_reader.py index 260575b..7d32596 100644 --- a/libeos/file_reader.py +++ b/libeos/file_reader.py @@ -203,6 +203,8 @@ class AmorData: self.filter_project_x() + self.correct_for_chopper_phases() + self.correct_for_chopper_opening() self.calculate_derived_properties() @@ -216,7 +218,7 @@ class AmorData: #self.chopper2TriggerTime = self.chopper1TriggerTime # + np.array(self.hdf['entry1/Amor/chopper/ch2_trigger/event_time_offset'][:], dtype=np.int64) self.startTime = self.chopper1TriggerTime[0] - self.stopTime = self.chopper1TriggerTime[-2] + self.stopTime = self.chopper1TriggerTime[-3] if self.seriesStartTime is None: self.seriesStartTime = self.startTime logging.debug(f' series start time (epoch): {self.seriesStartTime/1e9:13.2f} s') @@ -233,65 +235,6 @@ class AmorData: self.pixelID_e = np.array(self.hdf['/entry1/Amor/detector/data/event_id'][:], dtype=np.int64) self.dataPacket_p = np.array(self.hdf['/entry1/Amor/detector/data/event_index'][:], dtype=np.uint64) self.dataPacketTime_p = np.array(self.hdf['/entry1/Amor/detector/data/event_time_zero'][:], dtype=np.int64) - #if self.config.monitorType in ['auto', 'p']: - # try: - # self.currentTime = np.array(self.hdf['entry1/Amor/detector/proton_current/time'][:], dtype=np.int64) - # self.current = np.array(self.hdf['entry1/Amor/detector/proton_current/value'][:,0], dtype=float) - # if len(self.current)>4: - # self.config.monitorType = 'p' - # else: - # self.config.monitorType = 't' - # except(KeyError, IndexError): - # self.config.monitorType = 't' - #else: - # self.config.monitorType = 't' - #TODO: protonMonitor - -# def sort_pulses(self): -# pulseTime = np.sort(self.dataPacketTime_p) -# print(np.shape(pulseTime)) -# pulseTime = pulseTime[np.abs(pulseTime[:]-np.roll(pulseTime, 1)[:])>5] -# print(np.shape(pulseTime)) -# pulseTime -= np.int64(self.seriesStartTime) -# pulseTime = pulseTime[pulseTime>=0] -# print(np.shape(pulseTime)) -# pulseTime = pulseTime[pulseTime<=(self.stopTime-self.seriesStartTime)] -# print(np.shape(pulseTime)) -# -# chopperPeriod = np.int64(2*self.tau*1e9) -# -# # fill in missing pulse times -# # TODO: check for real end time -# try: -# # further files -# # TODO: use the first pulse of the respective measurement -# #nextPulseTime = startTime % np.int64(self.tau*2e9) -# #nextPulseTime = self.pulseTimeS[-1] + chopperPeriod -# nextPulseTime = pulseTime[0] -# except AttributeError: -# # first file -# nextPulseTime = pulseTime[0] % np.int64(self.tau*2e9) -# -# # calculate where time tiefference between pulses exceeds its time by more than 1/2 -# # this yields the number of missing pulses -# pulseLengths = pulseTime[1:]-pulseTime[:-1] -# pulseExtra = (pulseLengths-np.int64(self.tau*1e9))//np.int64(self.tau*2e9) -# gap_indices = np.where(pulseExtra>0)[0] -# - # if len(gap_indices)==0: - # # no missing pulses, just use given array - # self.pulseTimeS = np.array(pulseTime, dtype=np.int64) - # return - # self.pulseTimeS = np.array(pulseTime[:gap_indices[0]+1], dtype=np.int64) - # last_index = gap_indices[0] - # for gapi in gap_indices[1:]: - # # insert missing pulses into each gap - # gap_pulses = pulseTime[last_index]+np.arange(1, pulseExtra[last_index]+1)*chopperPeriod - # self.pulseTimeS = np.append(self.pulseTimeS, gap_pulses) - # self.pulseTimeS = np.append(self.pulseTimeS, pulseTime[last_index+1:gapi+1]) - # last_index = gapi - # if last_index