Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d2713ea
Support of multiple NectarCAM cameras for DQM job submitter and DQM r…
jlenain Oct 1, 2025
59741a4
Adapt the DQM to support multiple NectarCAM cameras
jlenain Oct 2, 2025
570532f
handle several nectarCAM cameras
Oct 2, 2025
fea5470
Update notebook
jlenain Oct 3, 2025
502bae1
Change help message
jlenain Oct 3, 2025
b0c0cb7
Lost a fundamental change during an unfortunate rebase onto main
jlenain Oct 3, 2025
1656aec
Update unit tests for DQM
jlenain Oct 3, 2025
72d2924
Lint
jlenain Oct 3, 2025
e20aeb2
Leftovers
jlenain Oct 3, 2025
e0caa91
Should cover and close #190
jlenain Oct 3, 2025
f948b96
Better doc
jlenain Oct 3, 2025
92fb281
Add option to select camera to DQM
jlenain Oct 3, 2025
a86d2ea
Typo
jlenain Oct 3, 2025
e48302d
Propagate camera option to DQM job submitter
jlenain Oct 3, 2025
2bb3ad7
Propagate camera option to core code, and gain scripts
jlenain Oct 6, 2025
f6fe8b3
Properly propagate camera option to load_wfs_compute_charge script
jlenain Oct 6, 2025
b0e7fd9
Properly propagate camera option in core code
jlenain Oct 6, 2025
4477865
Remove duplicate code
jlenain Oct 6, 2025
14b2114
Propagate camera option to gain users' scripts
jlenain Oct 7, 2025
1f99a6d
Propagate telescope ID to flatfield and waveforms components
jlenain Oct 7, 2025
ef9315a
Propagate telescope ID to tool tutorial
jlenain Oct 7, 2025
c5305b0
More consistent auto-discovery of QM as default
jlenain Oct 7, 2025
3f08a48
Lint
jlenain Oct 7, 2025
cad0773
Include camera number in DQM results archive
jlenain Oct 10, 2025
f485835
Fix typo
jlenain Oct 10, 2025
d9b29a0
Fix typo
jlenain Oct 10, 2025
a0a071f
Forgot to propagate `camera` to DIRAC parent directory for DQM results
jlenain Oct 10, 2025
b8505b7
Using a local container image is just for testing this PR !
jlenain Oct 13, 2025
ad870b9
Add support for several cameras in flat-field script
jlenain Oct 16, 2025
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
1 change: 1 addition & 0 deletions notebooks/tool_implementation/tuto_photostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
progress_bar=True,
run_number=FF_run_number,
Ped_run_number=Ped_run_number,
camera="NectarCAMQM",
SPE_result=path[0],
method="LocalPeakWindowSum",
extractor_kwargs={"window_width": 12, "window_shift": 4},
Expand Down
4 changes: 2 additions & 2 deletions src/nectarchain/data/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def findrun(
"""
basepath = f"{os.environ['NECTARCAMDATA']}/runs/"
list = glob.glob(
basepath + "**/*" + str(run_number) + "*.fits.fz", recursive=True
basepath + "**/*" + str(run_number).zfill(4) + "*.fits.fz", recursive=True
)
list_path = [Path(chemin) for chemin in list]
if len(list_path) == 0:
Expand Down Expand Up @@ -188,7 +188,7 @@ def __get_GRID_location_DIRAC(
catalog = DCatalog()
with redirect_stdout(sys.stdout):
fccli = FileCatalogClientCLI(catalog.catalog)
sys.stdout = StdoutRecord(keyword=f"Run{run_number}")
sys.stdout = StdoutRecord(keyword=f"Run{str(run_number).zfill(4)}")
fccli.do_find("-q " + basepath)
lfns = sys.stdout.output
sys.stdout = sys.__stdout__
Expand Down
4 changes: 2 additions & 2 deletions src/nectarchain/makers/calibration/gain/photostat_makers.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ def _load_eventsource(self, FF_run=True):
if FF_run:
self.log.debug("loading FF event source")
self.event_source = self.enter_context(
self.load_run(self.run_number, self.max_events)
self.load_run(self.run_number, self.max_events, camera=self.camera)
)
else:
self.log.debug("loading Ped event source")
self.event_source = self.enter_context(
self.load_run(self.Ped_run_number, self.max_events)
self.load_run(self.Ped_run_number, self.max_events, camera=self.camera)
)

def start(
Expand Down
28 changes: 26 additions & 2 deletions src/nectarchain/makers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
ComponentNameList,
Integer,
Path,
TraitError,
Unicode,
classes_with_traits,
flag,
)
Expand Down Expand Up @@ -70,7 +72,10 @@ def _default_log_file(self):

@staticmethod
def load_run(
run_number: int, max_events: int = None, run_file: str = None
run_number: int,
max_events: int = None,
run_file: str = None,
camera: int = "NectarCAMQM",
) -> LightNectarCAMEventSource:
"""Static method to load from $NECTARCAMDATA directory data for specified run
with max_events.
Expand All @@ -83,6 +88,8 @@ def load_run(
max of events to be loaded. Defaults to -1, to load everything.
run_file : optional
if provided, will load this run file
camera : str
camera for which data are processed. (Default: NectarCAMQM)
Returns
-------
Expand All @@ -91,7 +98,7 @@ def load_run(
"""
# Load the data from the run file.
if run_file is None:
generic_filename, _ = DataManagement.findrun(run_number)
generic_filename, _ = DataManagement.findrun(run_number, camera=camera)
log.info(f"{str(generic_filename)} will be loaded")
eventsource = LightNectarCAMEventSource(
input_url=generic_filename, max_events=max_events
Expand All @@ -110,6 +117,7 @@ class EventsLoopNectarCAMCalibrationTool(BaseNectarCAMCalibrationTool):
Args:
run_number (int): The ID of the run to be processed.
camera (str): The NectarCAM camera for which data should be processed.
max_events (int, optional): The maximum number of events to be loaded.
Defaults to None.
run_file (optional): The specific run file to be loaded.
Expand All @@ -131,6 +139,7 @@ class EventsLoopNectarCAMCalibrationTool(BaseNectarCAMCalibrationTool):
aliases = {
("i", "input"): "EventsLoopNectarCAMCalibrationTool.run_file",
("r", "run-number"): "EventsLoopNectarCAMCalibrationTool.run_number",
("c", "camera"): "EventsLoopNectarCAMCalibrationTool.camera",
("m", "max-events"): "EventsLoopNectarCAMCalibrationTool.max_events",
("o", "output"): "EventsLoopNectarCAMCalibrationTool.output_path",
"events-per-slice": "EventsLoopNectarCAMCalibrationTool.events_per_slice",
Expand Down Expand Up @@ -161,6 +170,13 @@ class EventsLoopNectarCAMCalibrationTool(BaseNectarCAMCalibrationTool):
config=True
)

camera = Unicode(
help="camera for which the data will be processed",
default_value="NectarCAMQM",
allow_none=False,
read_only=True,
).tag(config=True)

output_path = Path(
help="output filename",
default_value=pathlib.Path(
Expand Down Expand Up @@ -218,6 +234,14 @@ def __new__(cls, *args, **kwargs):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

prefix = "NectarCAM"
cameras = [f"{prefix}" + "QM"]
cameras.extend([f"{prefix + str(i)}" for i in range(2, 10)])

if self.camera not in cameras and self.run_file is None:
raise TraitError(f"The camera field should be one of {cameras}.")

if not ("output_path" in kwargs.keys()):
self._init_output_path()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
from nectarchain.makers.calibration import PhotoStatisticNectarCAMCalibrationTool
from nectarchain.makers.extractor.utils import CtapipeExtractor

prefix = "NectarCAM"
cameras = [f"{prefix}" + "QM"]
cameras.extend([f"{prefix + str(i)}" for i in range(2, 10)])

parser = argparse.ArgumentParser(
prog="gain_SPEfit_computation.py",
description=f"compute high and low gain with the Photo-statistic\
Expand All @@ -24,6 +28,16 @@
"--Ped_run_number", nargs="+", default=[], help="run(s) list", type=int
)

parser.add_argument(
"-c",
"--camera",
choices=cameras,
default=[camera for camera in cameras if "QM" in camera][0],
help="""Process data for a specific NectarCAM camera.
Default: NectarCAMQM (Qualification Model).""",
type=str,
)

# max events to be loaded
parser.add_argument(
"-m",
Expand Down Expand Up @@ -170,6 +184,7 @@ def main(
progress_bar=True,
run_number=_FF_run_number,
max_events=_max_events,
camera=args.camera,
Ped_run_number=_Ped_run_number,
SPE_result=path[0],
**kwargs,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#HOW TO :
#to perform photo-statistic high and low gain computation with pedestal run 2609, flat field run 2609 and SPE fit result from run 2634 (1400V run)
python gain_PhotoStat_computation.py --FF_run_number 3937 --Ped_run_number 3938 --SPE_run_number 3942 --SPE_config HHVfixed --max_events 100 --method LocalPeakWindowSum --extractor_kwargs '{"window_width":16,"window_shift":4}' --overwrite -v INFO --reload_events
python gain_PhotoStat_computation.py --camera="NectarCAMQM" --FF_run_number 3937 --Ped_run_number 3938 --SPE_run_number 3942 --SPE_config HHVfixed --max_events 100 --method LocalPeakWindowSum --extractor_kwargs '{"window_width":16,"window_shift":4}' --overwrite -v INFO --reload_events

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
)
from nectarchain.makers.extractor.utils import CtapipeExtractor

prefix = "NectarCAM"
cameras = [f"{prefix}" + "QM"]
cameras.extend([f"{prefix + str(i)}" for i in range(2, 10)])

parser = argparse.ArgumentParser(
prog="gain_SPEfit_combined_computation.py",
description=f"compute high gain with SPE fit for one run at nominal voltage from a SPE result from a run at 1400V. By default, output data are saved in $NECTARCAMDATA/../SPEfit/data/",
Expand All @@ -23,6 +27,16 @@
"-r", "--run_number", nargs="+", default=[], help="run(s) list", type=int
)

parser.add_argument(
"-c",
"--camera",
choices=cameras,
default=[camera for camera in cameras if "QM" in camera][0],
help="""Process data for a specific NectarCAM camera.
Default: NectarCAMQM (Qualification Model).""",
type=str,
)

# max events to be loaded
parser.add_argument(
"-m",
Expand Down Expand Up @@ -171,6 +185,7 @@ def main(
tool = FlatFieldSPECombinedStdNectarCAMCalibrationTool(
progress_bar=True,
run_number=_run_number,
camera=args.camera,
max_events=_max_events,
SPE_result=path[0],
**kwargs,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#HOW TO :

#to perform SPE fit of run 3936 (supposed to be taken at nominal voltage) from SPE fit performed on 3942 (taken at 1400V) (luminosity can not be supposed the same)
python gain_SPEfit_combined_computation.py -r 3936 --HHV_run_number 3942 --multiproc --nproc 8 --chunksize 2 -p 45 56 --max_events 100 --method LocalPeakWindowSum --extractor_kwargs '{"window_width":16,"window_shift":4}' --overwrite -v DEBUG --reload_events
python gain_SPEfit_combined_computation.py --camera="NectarCAMQM" -r 3936 --HHV_run_number 3942 --multiproc --nproc 8 --chunksize 2 -p 45 56 --max_events 100 --method LocalPeakWindowSum --extractor_kwargs '{"window_width":16,"window_shift":4}' --overwrite -v DEBUG --reload_events
15 changes: 15 additions & 0 deletions src/nectarchain/user_scripts/ggrolleron/gain_SPEfit_computation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
)
from nectarchain.makers.extractor.utils import CtapipeExtractor

prefix = "NectarCAM"
cameras = [f"{prefix}" + "QM"]
cameras.extend([f"{prefix + str(i)}" for i in range(2, 10)])

parser = argparse.ArgumentParser(
prog="gain_SPEfit_computation.py",
description=f"compute high gain with SPE fit for one run at very very high voltage (~1400V) or at nominal voltage (it can often fail). By default, output data are saved in $NECTARCAMDATA/../SPEfit/data/",
Expand All @@ -24,6 +28,16 @@
"-r", "--run_number", nargs="+", default=[], help="run(s) list", type=int
)

parser.add_argument(
"-c",
"--camera",
choices=cameras,
default=[camera for camera in cameras if "QM" in camera][0],
help="""Process data for a specific NectarCAM camera.
Default: NectarCAMQM (Qualification Model).""",
type=str,
)

# max events to be loaded
parser.add_argument(
"-m",
Expand Down Expand Up @@ -160,6 +174,7 @@ def main(
try:
tool = _class(
progress_bar=True,
camera=args.camera,
run_number=_run_number,
max_events=_max_events,
**kwargs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#nominal runs : 2633,3936

#to perform SPE fit of a run at nominal voltage
python gain_SPEfit_computation.py -r 3942 --reload_events --multiproc --nproc 8 --chunksize 2 -p 45 56 --max_events 100 --method LocalPeakWindowSum --extractor_kwargs '{"window_width":16,"window_shift":4}' --overwrite -v DEBUG
python gain_SPEfit_computation.py --camera="NectarCAMQM" -r 3942 --reload_events --multiproc --nproc 8 --chunksize 2 -p 45 56 --max_events 100 --method LocalPeakWindowSum --extractor_kwargs '{"window_width":16,"window_shift":4}' --overwrite -v DEBUG
#to perform SPE fit of a HHV run
python gain_SPEfit_computation.py -r 3936 --reload_events --multiproc --nproc 8 --chunksize 2 -p 45 56 --max_events 100 --method LocalPeakWindowSum --extractor_kwargs '{"window_width":16,"window_shift":4}' --overwrite -v DEBUG
python gain_SPEfit_computation.py --camera="NectarCAMQM" -r 3936 --reload_events --multiproc --nproc 8 --chunksize 2 -p 45 56 --max_events 100 --method LocalPeakWindowSum --extractor_kwargs '{"window_width":16,"window_shift":4}' --overwrite -v DEBUG
#to perform SPE fit of a HHV run letting n and pp parameters free
python gain_SPEfit_computation.py -r 3942 --HHV --free_pp_n --reload_events --multiproc --nproc 8 --chunksize 2 -p 45 56 --max_events 100 --method LocalPeakWindowSum --extractor_kwargs '{"window_width":16,"window_shift":4}' --overwrite -v DEBUG
python gain_SPEfit_computation.py --camera="NectarCAMQM" -r 3942 --HHV --free_pp_n --reload_events --multiproc --nproc 8 --chunksize 2 -p 45 56 --max_events 100 --method LocalPeakWindowSum --extractor_kwargs '{"window_width":16,"window_shift":4}' --overwrite -v DEBUG
17 changes: 17 additions & 0 deletions src/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
WaveformsNectarCAMCalibrationTool,
)

prefix = "NectarCAM"
cameras = [f"{prefix}" + "QM"]
cameras.extend([f"{prefix + str(i)}" for i in range(2, 10)])

parser = argparse.ArgumentParser(
prog="load_wfs_compute_charge",
description="This program load waveforms from fits.fz run files and compute charge",
Expand All @@ -26,6 +30,16 @@
"-r", "--run_number", nargs="+", default=[], help="run(s) list", type=int
)

parser.add_argument(
"-c",
"--camera",
choices=cameras,
default=[camera for camera in cameras if "QM" in camera][0],
help="""Process data for a specific NectarCAM camera.
Default: NectarCAMQM (Qualification Model).""",
type=str,
)

# max events to be loaded
parser.add_argument(
"-m",
Expand Down Expand Up @@ -132,6 +146,7 @@ def main(
tool = WaveformsNectarCAMCalibrationTool(
progress_bar=True,
run_number=_run_number,
camera=args.camera,
max_events=_max_events,
**waveforms_kwargs,
)
Expand All @@ -143,6 +158,7 @@ def main(
tool = ChargesNectarCAMCalibrationTool(
progress_bar=True,
run_number=_run_number,
camera=args.camera,
max_events=_max_events,
from_computed_waveforms=True,
**charges_kwargs,
Expand All @@ -155,6 +171,7 @@ def main(
tool = ChargesNectarCAMCalibrationTool(
progress_bar=True,
run_number=_run_number,
camera=args.camera,
max_events=_max_events,
from_computed_waveforms=True,
**charges_kwargs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@

#FF and Ped : 3943

python load_wfs_compute_charge.py -r 3942 --max_events 100 --method GlobalPeakWindowSum --extractor_kwargs '{"window_width":16,"window_shift":4}' --overwrite -v DEBUG
python load_wfs_compute_charge.py --camera="NectarCAMQM" -r 3942 --max_events 100 --method GlobalPeakWindowSum --extractor_kwargs '{"window_width":16,"window_shift":4}' --overwrite -v DEBUG

Loading