-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
189 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
from dqm_summary_processor import dqm_summary | ||
from matplotlib import pyplot as plt | ||
from ctapipe.visualization import CameraDisplay | ||
from ctapipe.instrument import CameraGeometry | ||
from ctapipe.coordinates import EngineeringCameraFrame | ||
import numpy as np | ||
|
||
|
||
class PixelTimeline_HighLowGain(dqm_summary): | ||
def __init__(self, gaink): | ||
self.k = gaink | ||
return None | ||
|
||
def ConfigureForRun(self, path, Pix, Samp, Reader1): | ||
# define number of pixels and samples | ||
self.Pix = Pix | ||
self.Samp = Samp | ||
|
||
|
||
self.counter_evt = 0 | ||
self.counter_ped = 0 | ||
|
||
self.camera = CameraGeometry.from_name("NectarCam-003").transform_to(EngineeringCameraFrame()) | ||
self.camera2 = CameraGeometry.from_name("NectarCam-003").transform_to(EngineeringCameraFrame()) | ||
|
||
self.cmap = "gnuplot2" | ||
self.cmap2 = "gnuplot2" | ||
|
||
|
||
self.SumBadPixels_ped = [] | ||
self.SumBadPixels = [] | ||
|
||
def ProcessEvent(self, evt, noped): | ||
pixelBAD = evt.mon.tel[0].pixel_status.hardware_failing_pixels[self.k] | ||
pixel = evt.nectarcam.tel[0].svc.pixel_ids | ||
if len(pixel) < self.Pix: | ||
pixel21 = list(np.arange(0, self.Pix - len(pixel), 1, dtype=int)) | ||
pixel = list(pixel) | ||
pixels = np.concatenate([pixel21, pixel]) | ||
else: | ||
pixels = pixel | ||
|
||
if evt.trigger.event_type.value == 32: # count peds | ||
self.counter_ped += 1 | ||
self.counter_evt += 1 | ||
BadPixels_ped1 = list(map(int, pixelBAD[pixels])) | ||
SumBadPixelsEvent_ped = sum(BadPixels_ped1) | ||
self.SumBadPixels_ped.append(SumBadPixelsEvent_ped) | ||
self.SumBadPixels.append(0) | ||
|
||
else: | ||
self.counter_evt += 1 | ||
self.counter_ped += 1 | ||
BadPixels1 = list(map(int, pixelBAD[pixels])) | ||
SumBadPixelsEvent = sum(BadPixels1) | ||
self.SumBadPixels.append(SumBadPixelsEvent) | ||
self.SumBadPixels_ped.append(0) | ||
|
||
return None | ||
|
||
def FinishRun(self): | ||
|
||
self.BadPixelTimeline_ped = np.array(self.SumBadPixels_ped, dtype=float)/self.Pix | ||
self.BadPixelTimeline = np.array(self.SumBadPixels, dtype=float)/self.Pix | ||
print(self.BadPixelTimeline) | ||
print( self.BadPixelTimeline_ped) | ||
|
||
|
||
|
||
|
||
def GetResults(self): | ||
# INITIATE DICT | ||
self.PixelTimeline_Results_Dict = {} | ||
|
||
# ASSIGN RESUTLS TO DICT | ||
if self.k == 0: | ||
|
||
if self.counter_evt > 0: | ||
self.PixelTimeline_Results_Dict[ | ||
"CAMERA-BadPixTimeline-PHY-HIGH-GAIN" | ||
] = self.BadPixelTimeline | ||
|
||
|
||
if self.counter_ped > 0: | ||
self.PixelTimeline_Results_Dict[ | ||
"CAMERA-BadPixTimeline-PED-HIGH-GAIN" | ||
] = self.BadPixelTimeline_ped | ||
|
||
|
||
if self.k == 1: | ||
if self.counter_evt > 0: | ||
self.PixelTimeline_Results_Dict[ | ||
"CAMERA-BadPixTimeline-PHY-LOW-GAIN" | ||
] = self.BadPixelTimeline | ||
|
||
if self.counter_ped > 0: | ||
self.PixelTimeline_Results_Dict[ | ||
"CAMERA-BadPixTimeline-PED-LOW-GAIN" | ||
] = self.BadPixelTimeline_ped | ||
|
||
|
||
return self.PixelTimeline_Results_Dict | ||
|
||
def PlotResults(self, name, FigPath): | ||
self.PixelTimeline_Figures_Dict = {} | ||
self.PixelTimeline_Figures_Names_Dict = {} | ||
|
||
# titles = ['All', 'Pedestals'] | ||
if self.k == 0: | ||
gain_c = "High" | ||
if self.k == 1: | ||
gain_c = "Low" | ||
|
||
if self.counter_evt > 0: | ||
fig1, disp = plt.subplots() | ||
plt.plot(np.arange(self.counter_evt), self.BadPixelTimeline*100, label = "Physical events") | ||
plt.legend() | ||
plt.xlabel("Timeline") | ||
plt.ylabel("BPX fraction (%)") | ||
plt.title("BPX Timeline %s gain (ALL)" % gain_c) | ||
|
||
full_name = name + "_BPX_Timeline_%sGain_All.png" % gain_c | ||
FullPath = FigPath + full_name | ||
self.PixelTimeline_Figures_Dict[ | ||
"BPX-TIMELINE-ALL-%s-GAIN" % gain_c | ||
] = fig1 | ||
self.PixelTimeline_Figures_Names_Dict[ | ||
"BPX-TIMELINE-ALL-%s-GAIN" % gain_c | ||
] = FullPath | ||
|
||
plt.close() | ||
|
||
if self.counter_ped > 0: | ||
fig2, disp = plt.subplots() | ||
plt.plot(np.arange(self.counter_ped), self.BadPixelTimeline_ped*100, label = "Pedestal events") | ||
plt.legend() | ||
plt.xlabel("Timeline") | ||
plt.ylabel("BPX fraction (%)") | ||
plt.title("BPX Timeline %s gain (PED)" % gain_c) | ||
|
||
full_name = name + "_BPX_Timeline_%sGain_Ped.png" % gain_c | ||
FullPath = FigPath + full_name | ||
self.PixelTimeline_Figures_Dict[ | ||
"BPX-TIMELINE-PED-%s-GAIN" % gain_c | ||
] = fig2 | ||
self.PixelTimeline_Figures_Names_Dict[ | ||
"BPX-TIMELINE-PED-%s-GAIN" % gain_c | ||
] = FullPath | ||
|
||
plt.close() | ||
|
||
return ( | ||
self.PixelTimeline_Figures_Dict, | ||
self.PixelTimeline_Figures_Names_Dict, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters