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

Some enhancements for the DQM #101

Merged
merged 2 commits into from
Feb 1, 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
4 changes: 2 additions & 2 deletions src/nectarchain/dqm/mean_waveforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def PlotResults(self, name, FigPath):
)
part_ax.set_xlabel("Samples")
part_ax.set_ylabel("Amplitude (DC)")
part_ax.legend()
# part_ax.legend()
part_ax.grid()

part_name = name + "_MeanWaveforms_%s_%sGain.png" % (
Expand All @@ -158,7 +158,7 @@ def PlotResults(self, name, FigPath):
full_ax.set_title("Mean Waveforms Combined Plot (%s Gain)" % gain_c)
full_ax.set_xlabel("Samples")
full_ax.set_ylabel("Amplitude (DC)")
full_ax.legend()
# full_ax.legend()
full_ax.grid()

full_name = name + "_MeanWaveforms_CombinedPlot_%sGain.png" % gain_c
Expand Down
75 changes: 45 additions & 30 deletions src/nectarchain/dqm/start_dqm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@

from camera_monitoring import CameraMonitoring
from charge_integration import ChargeIntegrationHighLowGain
from ctapipe.io import EventSeeker, EventSource
from ctapipe.io import EventSource

Check warning on line 8 in src/nectarchain/dqm/start_dqm.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/start_dqm.py#L8

Added line #L8 was not covered by tests
from ctapipe_io_nectarcam.constants import HIGH_GAIN, LOW_GAIN
from db_utils import DQMDB
from matplotlib import pyplot as plt
from mean_camera_display import MeanCameraDisplay_HighLowGain
from mean_waveforms import MeanWaveFormsHighLowGain
from tqdm import tqdm
from traitlets.config import Config

Check warning on line 15 in src/nectarchain/dqm/start_dqm.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/start_dqm.py#L14-L15

Added lines #L14 - L15 were not covered by tests
from trigger_statistics import TriggerStatistics

# Create an ArgumentParser object
Expand All @@ -30,6 +32,13 @@
parser.add_argument(
"-r", "--runnb", help="Optional run number, automatically found on DIRAC", type=int
)
parser.add_argument("--r0", action="store_true", help="Disable all R0->R1 corrections")
parser.add_argument(

Check warning on line 36 in src/nectarchain/dqm/start_dqm.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/start_dqm.py#L35-L36

Added lines #L35 - L36 were not covered by tests
"--max-events",
default=None,
type=int,
help="Maximum number of events to loop through in each run slice",
)
parser.add_argument("-i", "--input-files", nargs="+", help="Local input files")

parser.add_argument("input_paths", help="Input paths")
Expand Down Expand Up @@ -69,7 +78,7 @@
for arg in args.input_files[1:]:
print(arg)

# Defining and priting the options
# Defining and printing the options
PlotFig = args.plot
noped = args.noped

Expand Down Expand Up @@ -106,9 +115,22 @@
cmap = "gnuplot2"

# Read and seek
reader = EventSource(input_url=path)
seeker = EventSeeker(reader)
reader1 = EventSource(input_url=path, max_events=1)
config = None
if args.r0:
config = Config(

Check warning on line 120 in src/nectarchain/dqm/start_dqm.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/start_dqm.py#L118-L120

Added lines #L118 - L120 were not covered by tests
dict(
NectarCAMEventSource=dict(
NectarCAMR0Corrections=dict(
calibration_path=None,
apply_flatfield=False,
select_gain=False,
)
)
)
)

reader = EventSource(input_url=path, config=config, max_events=args.max_events)
reader1 = EventSource(input_url=path, config=config, max_events=1)

Check warning on line 133 in src/nectarchain/dqm/start_dqm.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/start_dqm.py#L132-L133

Added lines #L132 - L133 were not covered by tests
# print(reader.file_list)

name = GetName(path)
Expand All @@ -118,26 +140,16 @@

# LIST OF PROCESSES TO RUN
########################################################################################
a = TriggerStatistics(HIGH_GAIN)
b = MeanWaveFormsHighLowGain(HIGH_GAIN)
c = MeanWaveFormsHighLowGain(LOW_GAIN)
d = MeanCameraDisplay_HighLowGain(HIGH_GAIN)
e = MeanCameraDisplay_HighLowGain(LOW_GAIN)
f = ChargeIntegrationHighLowGain(HIGH_GAIN)
g = ChargeIntegrationHighLowGain(LOW_GAIN)
h = CameraMonitoring(HIGH_GAIN)

processors = list()

processors.append(a)
processors.append(b)
processors.append(c)
processors.append(d)
processors.append(e)
processors.append(f)
processors.append(g)
processors.append(h)

processors = [

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

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/start_dqm.py#L143

Added line #L143 was not covered by tests
TriggerStatistics(HIGH_GAIN),
MeanWaveFormsHighLowGain(HIGH_GAIN),
MeanWaveFormsHighLowGain(LOW_GAIN),
MeanCameraDisplay_HighLowGain(HIGH_GAIN),
MeanCameraDisplay_HighLowGain(LOW_GAIN),
ChargeIntegrationHighLowGain(HIGH_GAIN),
ChargeIntegrationHighLowGain(LOW_GAIN),
CameraMonitoring(HIGH_GAIN),
]

# LIST OF DICT RESULTS
Results_MeanWaveForms_HighGain = {}
Expand Down Expand Up @@ -170,19 +182,22 @@
for p in processors:
p.ConfigureForRun(path, Pix, Samp, reader1)

for i, evt in enumerate(reader):
for evt in tqdm(

Check warning on line 185 in src/nectarchain/dqm/start_dqm.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/start_dqm.py#L185

Added line #L185 was not covered by tests
reader, total=args.max_events if args.max_events else len(reader), unit="ev"
):
for p in processors:
p.ProcessEvent(evt, noped)

# for the rest of the event files
for arg in args.input_files[1:]:
path2 = f"{NectarPath}/{arg}"
path2 = f"{NectarPath}/runs/{arg}"

Check warning on line 193 in src/nectarchain/dqm/start_dqm.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/start_dqm.py#L193

Added line #L193 was not covered by tests
print(path2)

reader = EventSource(input_url=path2)
seeker = EventSeeker(reader)
reader = EventSource(input_url=path2, config=config, max_events=args.max_events)

Check warning on line 196 in src/nectarchain/dqm/start_dqm.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/start_dqm.py#L196

Added line #L196 was not covered by tests

for i, evt in enumerate(reader):
for evt in tqdm(

Check warning on line 198 in src/nectarchain/dqm/start_dqm.py

View check run for this annotation

Codecov / codecov/patch

src/nectarchain/dqm/start_dqm.py#L198

Added line #L198 was not covered by tests
reader, total=args.max_events if args.max_events else len(reader), unit="ev"
):
for p in processors:
p.ProcessEvent(evt, noped)

Expand Down
Loading