From 51fc818f29d39df62e639d4bdf07b9476e22dbcd Mon Sep 17 00:00:00 2001 From: Halim Ashkar Date: Wed, 21 Jun 2023 18:09:01 +0200 Subject: [PATCH] bug fic for mean_camera_display.py --- src/nectarchain/dqm/mean_camera_display.py | 64 +++++++++++++--------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/src/nectarchain/dqm/mean_camera_display.py b/src/nectarchain/dqm/mean_camera_display.py index 603b7a01..c821dd2d 100644 --- a/src/nectarchain/dqm/mean_camera_display.py +++ b/src/nectarchain/dqm/mean_camera_display.py @@ -28,6 +28,10 @@ def ConfigureForRun(self, path, Chan, Samp, Reader1): self.cmap = "gnuplot2" self.cmap2 = "gnuplot2" + self.CameraAverage = [] + self.CameraAverage_ped = [] + + def ProcessEvent(self, evt, noped): self.pixelBAD = evt.mon.tel[0].pixel_status.hardware_failing_pixels pixel = evt.nectarcam.tel[0].svc.pixel_ids @@ -41,28 +45,31 @@ def ProcessEvent(self, evt, noped): if evt.trigger.event_type.value == 32: #count peds self.counter_ped += 1 - else: - self.counter_evt += 1 + self.CameraAverage_ped1 = ( + evt.r0.tel[0].waveform[self.k].sum(axis=1)) + self.CameraAverage_ped.append(self.CameraAverage_ped1[pixels]) - if evt.trigger.event_type.value == 32: # only peds now - self.CameraAverage_ped += ( - evt.r0.tel[0].waveform[self.k].sum(axis=1) - ) # fill channels one by one and sum them for peds only - self.CameraAverage_ped = self.CameraAverage_ped[pixels] else: - self.CameraAverage += ( - evt.r0.tel[0].waveform[self.k].sum(axis=1) - ) # fill channels one by one and sum them - self.CameraAverage = self.CameraAverage[pixels] + self.counter_evt += 1 + self.CameraAverage1 = ( + evt.r0.tel[0].waveform[self.k].sum(axis=1)) + self.CameraAverage.append(self.CameraAverage1[pixels]) + return None def FinishRun(self): - self.CameraAverage_overEvents = self.CameraAverage / self.counter_evt - self.CameraAverage_overEvents_overSamp = ( - self.CameraAverage_overEvents / self.Samp - ) + if self.counter_evt > 0: + self.CameraAverage = np.array(self.CameraAverage) + self.CameraAverage = self.CameraAverage.sum(axis = 0) + self.CameraAverage_overEvents = (self.CameraAverage / self.counter_evt) + + self.CameraAverage_overEvents_overSamp = ( + self.CameraAverage_overEvents / self.Samp + ) if self.counter_ped > 0: + self.CameraAverage_ped = np.array(self.CameraAverage_ped) + self.CameraAverage_ped = self.CameraAverage_ped.sum(axis = 0) self.CameraAverage_ped_overEvents = ( self.CameraAverage_ped / self.counter_ped ) @@ -76,12 +83,14 @@ def GetResults(self): # ASSIGN RESUTLS TO DICT if self.k == 0: - # self.MeanCameraDisplay_Results_Dict[ - # "CAMERA-AVERAGE-OverEVENTS-HIGH-GAIN" - # ] = self.CameraAverage_overEvents - self.MeanCameraDisplay_Results_Dict[ - "CAMERA-AVERAGE-PHY-OverEVENTS-OverSamp-HIGH-GAIN" - ] = self.CameraAverage_overEvents_overSamp + + if self.counter_evt > 0: + # self.MeanCameraDisplay_Results_Dict[ + # "CAMERA-AVERAGE-OverEVENTS-HIGH-GAIN" + # ] = self.CameraAverage_overEvents + self.MeanCameraDisplay_Results_Dict[ + "CAMERA-AVERAGE-PHY-OverEVENTS-OverSamp-HIGH-GAIN" + ] = self.CameraAverage_overEvents_overSamp if self.counter_ped > 0: # self.MeanCameraDisplay_Results_Dict[ @@ -92,12 +101,13 @@ def GetResults(self): ] = self.CameraAverage_ped_overEvents_overSamp if self.k == 1: - # self.MeanCameraDisplay_Results_Dict[ - # "CAMERA-AVERAGE-OverEVENTS-LOW-GAIN" - # ] = self.CameraAverage_overEvents - self.MeanCameraDisplay_Results_Dict[ - "CAMERA-AVERAGE-PHY-OverEVENTS-OverSamp-LOW-GAIN" - ] = self.CameraAverage_overEvents_overSamp + if self.counter_evt > 0: + # self.MeanCameraDisplay_Results_Dict[ + # "CAMERA-AVERAGE-OverEVENTS-LOW-GAIN" + # ] = self.CameraAverage_overEvents + self.MeanCameraDisplay_Results_Dict[ + "CAMERA-AVERAGE-PHY-OverEVENTS-OverSamp-LOW-GAIN" + ] = self.CameraAverage_overEvents_overSamp if self.counter_ped > 0: # self.MeanCameraDisplay_Results_Dict[