Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pixel participation #81

Merged
merged 9 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions src/nectarchain/dqm/camera_monitoring.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,42 @@
class CameraMonitoring(DQMSummary):
def __init__(self, gaink):
self.k = gaink
self.Pix = None
self.Samp = None
self.camera = None
self.cmap = None
self.subarray = None
self.event_id = []
self.event_times = []
self.DrawerTemp = None
self.run_start = None
self.run_end = None
self.DrawerTimes = None
self.DrawerTemp11 = None
self.DrawerTemp21 = None
self.DrawerNum1 = None
self.DrawerTimes_new = None
self.DrawerTemp12 = None
self.DrawerTemp22 = None
self.DrawerNum2 = None
self.DrawerTemp1_mean = []
self.DrawerTemp2_mean = []
self.CameraMonitoring_Results_Dict = {}
self.ChargeInt_Figures_Dict = {}
self.ChargeInt_Figures_Names_Dict = {}

Check warning on line 38 in src/nectarchain/dqm/camera_monitoring.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/camera_monitoring.py#L16-L38

Added lines #L16 - L38 were not covered by tests

def ConfigureForRun(self, path, Pix, Samp, Reader1):
# define number of pixels and samples
self.Pix = Pix
self.Samp = Samp

self.camera = CameraGeometry.from_name("NectarCam-003").transform_to(
self.camera = Reader1.subarray.tel[0].camera.geometry.transform_to(

Check warning on line 45 in src/nectarchain/dqm/camera_monitoring.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/camera_monitoring.py#L45

Added line #L45 was not covered by tests
EngineeringCameraFrame()
)
self.cmap = "gnuplot2"

self.subarray = Reader1.subarray

self.event_id = []
self.event_times = []

for i, evt1 in enumerate(Reader1):
self.run_start1 = evt1.nectarcam.tel[0].svc.date

Expand Down Expand Up @@ -89,8 +109,6 @@
self.DrawerTemp22 = self.DrawerTemp21[self.DrawerTimes_new < self.run_end]
self.DrawerNum2 = self.DrawerNum1[self.DrawerTimes_new < self.run_end]

self.DrawerTemp1_mean = []
self.DrawerTemp2_mean = []
TotalDrawers = np.max(self.DrawerNum2)

for i in range(TotalDrawers + 1):
Expand All @@ -110,7 +128,6 @@
print("DRAWER TEMPERATURE COULD NOT BE RETRIEVED!")

def GetResults(self):
self.CameraMonitoring_Results_Dict = {}
try:
self.CameraMonitoring_Results_Dict[
"CAMERA-TEMPERATURE-AVERAGE"
Expand All @@ -122,8 +139,6 @@
return self.CameraMonitoring_Results_Dict

def PlotResults(self, name, FigPath):
self.ChargeInt_Figures_Dict = {}
self.ChargeInt_Figures_Names_Dict = {}

try:
fig, disp = plt.subplots()
Expand Down
36 changes: 28 additions & 8 deletions src/nectarchain/dqm/charge_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,32 @@
class ChargeIntegrationHighLowGain(DQMSummary):
def __init__(self, gaink):
self.k = gaink
self.Pix = None
self.Samp = None
self.counter_evt = None
self.counter_ped = None
self.image_all = []
self.peakpos_all = []
self.image_ped = []
self.peakpos_ped = []
self.camera = None
self.cmap = None
self.subarray = None
self.integrator = None
self.pixelBAD = None
self.image_all = []
self.image_all_median = None
self.image_all_average = None
self.image_all_std = None
self.image_all_rms = None
self.image_ped = []
self.image_ped_median = None
self.image_ped_average = None
self.image_ped_std = None
self.image_ped_rms = None
self.ChargeInt_Results_Dict = {}
self.ChargeInt_Figures_Dict = {}
self.ChargeInt_Figures_Names_Dict = {}

Check warning on line 40 in src/nectarchain/dqm/charge_integration.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/charge_integration.py#L15-L40

Added lines #L15 - L40 were not covered by tests

def ConfigureForRun(self, path, Pix, Samp, Reader1):
# define number of pixels and samples
Expand All @@ -21,9 +47,10 @@
self.counter_evt = 0
self.counter_ped = 0

self.camera = CameraGeometry.from_name("NectarCam-003").transform_to(
self.camera = Reader1.subarray.tel[0].camera.geometry.transform_to(

Check warning on line 50 in src/nectarchain/dqm/charge_integration.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/charge_integration.py#L50

Added line #L50 was not covered by tests
EngineeringCameraFrame()
)

self.cmap = "gnuplot2"

self.subarray = Reader1.subarray
Expand All @@ -37,11 +64,7 @@

self.integrator = LocalPeakWindowSum(subarray, config=config)

self.image_all = []
self.peakpos_all = []

self.image_ped = []
self.peakpos_ped = []

def ProcessEvent(self, evt, noped):
self.pixelBAD = evt.mon.tel[0].pixel_status.hardware_failing_pixels
Expand Down Expand Up @@ -106,7 +129,6 @@
self.image_ped_rms = np.sqrt(np.sum(self.image_ped**2, axis=0))

def GetResults(self):
self.ChargeInt_Results_Dict = {}

if self.k == 0:
self.ChargeInt_Results_Dict[
Expand Down Expand Up @@ -167,8 +189,6 @@
return self.ChargeInt_Results_Dict

def PlotResults(self, name, FigPath):
self.ChargeInt_Figures_Dict = {}
self.ChargeInt_Figures_Names_Dict = {}

# titles = ['All', 'Pedestals']
if self.k == 0:
Expand Down
22 changes: 17 additions & 5 deletions src/nectarchain/dqm/dqm_summary_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
self.FirstReader = reader1
self.Samp = len(evt1.r0.tel[0].waveform[0][0])
self.Pix = len(evt1.r0.tel[0].waveform[0])

return self.Pix, self.Samp

def ConfigureForRun(self):
Expand All @@ -36,11 +35,12 @@
def WriteAllResults(self, path, DICT):
data2 = Table()
data1 = Table()
data0 = Table()

Check warning on line 38 in src/nectarchain/dqm/dqm_summary_processor.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/dqm_summary_processor.py#L38

Added line #L38 was not covered by tests
data = Table()
hdu, hdu1, hdu2 = None, None, None
hdu, hdu0, hdu1, hdu2 = None, None, None, None

Check warning on line 40 in src/nectarchain/dqm/dqm_summary_processor.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/dqm_summary_processor.py#L40

Added line #L40 was not covered by tests
hdulist = fits.HDUList()
for i, j in DICT.items():
if i == "Results_TriggerStatistics":
if (i == "Results_TriggerStatistics"):

Check warning on line 43 in src/nectarchain/dqm/dqm_summary_processor.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/dqm_summary_processor.py#L43

Added line #L43 was not covered by tests
for n2, m2 in j.items():
data2[n2] = m2
hdu2 = fits.BinTableHDU(data2)
Expand All @@ -52,7 +52,13 @@
for n1, m1 in j.items():
data1[n1] = m1
hdu1 = fits.BinTableHDU(data1)
hdu1.name = "MWF"
hdu1.name = "MWF"

Check warning on line 55 in src/nectarchain/dqm/dqm_summary_processor.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/dqm_summary_processor.py#L55

Added line #L55 was not covered by tests

elif (i == "Results_PixelTimeline_HighGain") or (i == "Results_PixelTimeline_LowGain"):
for n0, m0 in j.items():
data0[n0] = m0
hdu0 = fits.BinTableHDU(data0)
hdu0.name = "BPX"

Check warning on line 61 in src/nectarchain/dqm/dqm_summary_processor.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/dqm_summary_processor.py#L57-L61

Added lines #L57 - L61 were not covered by tests

else:
for n, m in j.items():
Expand All @@ -67,11 +73,17 @@
hdulist.append(hdu1)
else:
print("No MWF studies requests")
if hdu0:
hdulist.append(hdu0)

Check warning on line 77 in src/nectarchain/dqm/dqm_summary_processor.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/dqm_summary_processor.py#L76-L77

Added lines #L76 - L77 were not covered by tests
else:
print("No Pixel Timeline studies requests")

Check warning on line 79 in src/nectarchain/dqm/dqm_summary_processor.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/dqm_summary_processor.py#L79

Added line #L79 was not covered by tests
if hdu:
hdulist.append(hdu)
else:
print("No Camera studies requests")
FileName = path + "_Results.fits"


FileName = path + '_Results.fits'

Check warning on line 86 in src/nectarchain/dqm/dqm_summary_processor.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/dqm_summary_processor.py#L86

Added line #L86 was not covered by tests
print(FileName)
hdulist.writeto(FileName, overwrite=True)
return None
44 changes: 27 additions & 17 deletions src/nectarchain/dqm/mean_camera_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,31 @@
class MeanCameraDisplay_HighLowGain(DQMSummary):
def __init__(self, gaink):
self.k = gaink
return None
self.Pix = None
self.Samp = None
self.CameraAverage = None
self.CameraAverage_ped = None
self.counter_evt = None
self.counter_ped = None
self.camera = None
self.cmap = None
self.CameraAverage = []
self.CameraAverage1 = []
self.CameraAverage_ped = []
self.CameraAverage_ped1 = []
self.CameraAverage_overEvents = None
self.CameraAverage_overEvents_overSamp = None
self.CameraAverage_ped_overEvents = None
self.CameraAverage_ped_overEvents_overSamp = None
self.MeanCameraDisplay_Results_Dict = {}
self.MeanCameraDisplay_Figures_Dict = {}
self.MeanCameraDisplay_Figures_Names_Dict = {}

Check warning on line 29 in src/nectarchain/dqm/mean_camera_display.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/mean_camera_display.py#L11-L29

Added lines #L11 - L29 were not covered by tests

def ConfigureForRun(self, path, Pix, Samp, Reader1):
# define number of pixels and samples
self.Pix = Pix
self.Samp = Samp

self.CameraAverage = np.zeros(self.Pix)
self.CameraAverage_ped = np.zeros(self.Pix)
self.counter_evt = 0
self.counter_ped = 0

Expand All @@ -26,8 +42,6 @@

self.cmap = "gnuplot2"

self.CameraAverage = []
self.CameraAverage_ped = []

def ProcessEvent(self, evt, noped):
self.pixelBAD = evt.mon.tel[0].pixel_status.hardware_failing_pixels
Expand Down Expand Up @@ -72,8 +86,6 @@
)

def GetResults(self):
# INITIATE DICT
self.MeanCameraDisplay_Results_Dict = {}

# ASSIGN RESUTLS TO DICT
if self.k == 0:
Expand Down Expand Up @@ -113,8 +125,6 @@
return self.MeanCameraDisplay_Results_Dict

def PlotResults(self, name, FigPath):
self.MeanCameraDisplay_Figures_Dict = {}
self.MeanCameraDisplay_Figures_Names_Dict = {}

# titles = ['All', 'Pedestals']
if self.k == 0:
Expand All @@ -123,14 +133,14 @@
gain_c = "Low"

if self.counter_evt > 0:
fig1, self.disp1 = plt.subplots()
self.disp1 = CameraDisplay(
fig1, disp1 = plt.subplots()
disp1 = CameraDisplay(

Check warning on line 137 in src/nectarchain/dqm/mean_camera_display.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/mean_camera_display.py#L136-L137

Added lines #L136 - L137 were not covered by tests
geometry=self.camera[~self.pixelBAD[0]],
image=self.CameraAverage_overEvents_overSamp[~self.pixelBAD[0]],
cmap=plt.cm.coolwarm,
)
self.disp1.add_colorbar()
self.disp1.axes.text(2.0, 0, "Charge (DC)", rotation=90)
disp1.add_colorbar()
disp1.axes.text(2.0, 0, "Charge (DC)", rotation=90)

Check warning on line 143 in src/nectarchain/dqm/mean_camera_display.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/mean_camera_display.py#L142-L143

Added lines #L142 - L143 were not covered by tests
plt.title("Camera average %s gain (ALL)" % gain_c)

self.MeanCameraDisplay_Figures_Dict[
Expand All @@ -144,14 +154,14 @@
plt.close()

if self.counter_ped > 0:
fig2, self.disp2 = plt.subplots()
self.disp2 = CameraDisplay(
fig2, disp2 = plt.subplots()
disp2 = CameraDisplay(

Check warning on line 158 in src/nectarchain/dqm/mean_camera_display.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/mean_camera_display.py#L157-L158

Added lines #L157 - L158 were not covered by tests
geometry=self.camera[~self.pixelBAD[0]],
image=self.CameraAverage_ped_overEvents_overSamp[~self.pixelBAD[0]],
cmap=plt.cm.coolwarm,
)
self.disp2.add_colorbar()
self.disp2.axes.text(2.0, 0, "Charge (DC)", rotation=90)
disp2.add_colorbar()
disp2.axes.text(2.0, 0, "Charge (DC)", rotation=90)

Check warning on line 164 in src/nectarchain/dqm/mean_camera_display.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/mean_camera_display.py#L163-L164

Added lines #L163 - L164 were not covered by tests
plt.title("Camera average %s gain (PED)" % gain_c)

self.MeanCameraDisplay_Figures_Dict[
Expand Down
24 changes: 13 additions & 11 deletions src/nectarchain/dqm/mean_waveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,30 @@
class MeanWaveFormsHighLowGain(DQMSummary):
def __init__(self, gaink):
self.k = gaink
return None
self.Pix = None
self.Samp = None
self.Mwf = None
self.Mwf_ped = None
self.counter_evt = None
self.counter_ped = None
self.Mwf_average = None
self.Mwf_ped_average = None
self.Mwf_Mean_overPix = []
self.Mwf_ped_Mean_overPix = []
self.MeanWaveForms_Results_Dict = {}
self.MeanWaveForms_Figures_Dict = {}
self.MeanWaveForms_Figures_Names_Dict = {}

Check warning on line 21 in src/nectarchain/dqm/mean_waveforms.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/mean_waveforms.py#L9-L21

Added lines #L9 - L21 were not covered by tests

def ConfigureForRun(self, path, Pix, Samp, Reader1):
# define number of pixels and samples
self.Pix = Pix
self.Samp = Samp

# redefine everything
self.Mwf = np.zeros((self.Pix, self.Samp))
self.Mwf_ped = np.zeros((self.Pix, self.Samp))
self.counter_evt = 0
self.counter_ped = 0

self.Mwf_average = np.zeros((self.Pix, self.Samp))
self.Mwf_ped_average = np.zeros((self.Pix, self.Samp))
self.Mwf_Mean_overPix = []
self.Mwf_ped_Mean_overPix = []

self.wf_list_plot = list(range(1, self.Samp + 1)) # used for plotting later on

return None
Expand Down Expand Up @@ -64,8 +70,6 @@
return None

def GetResults(self):
# INITIATE DICT
self.MeanWaveForms_Results_Dict = {}

# ASSIGN RESUTLS TO DICT
if self.k == 0:
Expand All @@ -89,8 +93,6 @@
return self.MeanWaveForms_Results_Dict

def PlotResults(self, name, FigPath):
self.MeanWaveForms_Figures_Dict = {}
self.MeanWaveForms_Figures_Names_Dict = {}

wf_list = np.array(self.wf_list_plot)

Expand Down
Loading
Loading