From 7a011211cb5f05af398cd3cd6eff43f9ba3440f4 Mon Sep 17 00:00:00 2001 From: jlenain Date: Wed, 29 Mar 2023 22:25:42 +0200 Subject: [PATCH 1/2] Enable all ctapipe charge extractors. --- .../user_scripts/ggrolleron/load_wfs_compute_charge.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py b/src/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py index 74f82e38..eb1ac7de 100644 --- a/src/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py +++ b/src/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py @@ -80,7 +80,14 @@ #extractor arguments parser.add_argument('--extractorMethod', - choices=["FullWaveformSum","LocalPeakWindowSum"], + choices=["FullWaveformSum", + "FixedWindowSum", + "GlobalPeakWindowSum", + "LocalPeakWindowSum", + "SlidingWindowMaxSum", + "NeighborPeakWindowSum", + "BaselineSubtractedNeighborPeakWindowSum", + "TwoPassWindowSum"], default="LocalPeakWindowSum", help='charge extractor method', type=str From 1025cf6b8ed6d7c3f5678d56246b40d1cf27824d Mon Sep 17 00:00:00 2001 From: "guillaume.grolleron" Date: Thu, 30 Mar 2023 15:54:58 +0200 Subject: [PATCH 2/2] -remove "NeighborPeakWindowSum" and "BaselineSubtractedNeighborPeakWindowSum" extractor (bug unfixed) -bugfix when using extractor on waveforms 3D (ctapipe written for 2D) --- .../calibration/container/charge.py | 18 +++++++++++++----- .../ggrolleron/load_wfs_compute_charge.py | 2 -- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/nectarchain/calibration/container/charge.py b/src/nectarchain/calibration/container/charge.py index e23cffe2..cb15cb2f 100644 --- a/src/nectarchain/calibration/container/charge.py +++ b/src/nectarchain/calibration/container/charge.py @@ -296,14 +296,22 @@ def compute_charge(waveformContainer : WaveformsContainer,channel : int,method : if not(method in list_ctapipe_charge_extractor or method in list_nectarchain_charge_extractor) : raise ArgumentError(f"method must be in {list_ctapipe_charge_extractor}") - if "apply_integration_correction" in eval(method).class_traits() : - kwargs["apply_integration_correction"] = False + extractor_kwargs = {} + for key in eval(method).class_own_traits().keys() : + if key in kwargs.keys() : + extractor_kwargs[key] = kwargs[key] - ImageExtractor = eval(method)(waveformContainer.subarray,**kwargs) + if "apply_integration_correction" in eval(method).class_own_traits().keys() : #to change the default behavior of ctapipe extractor + extractor_kwargs["apply_integration_correction"] = kwargs.get("apply_integration_correction",False) + + log.debug(f"Extracting waveforms with method {method} and extractor_kwargs {extractor_kwargs}") + ImageExtractor = eval(method)(waveformContainer.subarray,**extractor_kwargs) if channel == constants.HIGH_GAIN: - return ImageExtractor(waveformContainer.wfs_hg,waveformContainer.TEL_ID,channel) + out = np.array([ImageExtractor(waveformContainer.wfs_hg[i],waveformContainer.TEL_ID,channel) for i in range(len(waveformContainer.wfs_hg))]).reshape(2,waveformContainer.wfs_hg.shape[0], waveformContainer.wfs_hg.shape[1]) + return out[0],out[1] elif channel == constants.LOW_GAIN: - return ImageExtractor(waveformContainer.wfs_lg,waveformContainer.TEL_ID,channel) + out = np.array([ImageExtractor(waveformContainer.wfs_lg[i],waveformContainer.TEL_ID,channel) for i in range(len(waveformContainer.wfs_lg))]).reshape(2,waveformContainer.wfs_lg.shape[0], waveformContainer.wfs_lg.shape[1]) + return out[0],out[1] else : raise ArgumentError(f"channel must be {constants.LOW_GAIN} or {constants.HIGH_GAIN}") diff --git a/src/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py b/src/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py index eb1ac7de..adcb2b9c 100644 --- a/src/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py +++ b/src/nectarchain/user_scripts/ggrolleron/load_wfs_compute_charge.py @@ -85,8 +85,6 @@ "GlobalPeakWindowSum", "LocalPeakWindowSum", "SlidingWindowMaxSum", - "NeighborPeakWindowSum", - "BaselineSubtractedNeighborPeakWindowSum", "TwoPassWindowSum"], default="LocalPeakWindowSum", help='charge extractor method',