diff --git a/src/ctapipe/monitoring/outlier.py b/src/ctapipe/monitoring/outlier.py index cc00fb104d7..a8929bd5fa7 100644 --- a/src/ctapipe/monitoring/outlier.py +++ b/src/ctapipe/monitoring/outlier.py @@ -13,7 +13,7 @@ import numpy as np -from ctapipe.core import TelescopeComponent +from ctapipe.core import TelescopeComponent, traits from ctapipe.core.traits import List @@ -55,11 +55,14 @@ class RangeOutlierDetector(OutlierDetector): """ validity_range = List( - [1.0, 2.0], + trait=traits.Float(), + default_value=[1.0, 2.0], help=( "Range of valid statistic values (in units of the image value)." "Values outside the range are identified as outliers." ), + minlen=2, + maxlen=2, ).tag(config=True) def __call__(self, column): @@ -80,12 +83,15 @@ class MedianOutlierDetector(OutlierDetector): """ median_range_factors = List( - [-1.0, 1.0], + trait=traits.Float(), + default_value=[-1.0, 1.0], help=( "Multiplicative factors (unitless) applied to the camera median" "of the provided statistic values to define a valid range based on the" "deviation of the values to its camera median." ), + minlen=2, + maxlen=2, ).tag(config=True) def __call__(self, column): @@ -109,12 +115,15 @@ class StdOutlierDetector(OutlierDetector): """ std_range_factors = List( - [-1.0, 1.0], + trait=traits.Float(), + default_value=[-1.0, 1.0], help=( "Multiplicative factors (unitless) applied to the camera standard deviation" "of the provided statistic values to define a valid range based on the" "deviation of the values to its camera median." ), + minlen=2, + maxlen=2, ).tag(config=True) def __call__(self, column): diff --git a/src/ctapipe/monitoring/tests/test_outlier.py b/src/ctapipe/monitoring/tests/test_outlier.py index fdb703472ff..da7d7619b33 100644 --- a/src/ctapipe/monitoring/tests/test_outlier.py +++ b/src/ctapipe/monitoring/tests/test_outlier.py @@ -27,7 +27,9 @@ def test_range_detection(example_subarray): # Initialize the outlier detector based on the range of valid values # In this test, the interval [15, 25] corresponds to the range (in waveform samples) # of accepted mean (or median) values of peak times of flat-field events - detector = RangeOutlierDetector(subarray=example_subarray, validity_range=[15, 25]) + detector = RangeOutlierDetector( + subarray=example_subarray, validity_range=[15.0, 25.0] + ) # Detect outliers outliers = detector(table["mean"]) # Construct the expected outliers @@ -54,7 +56,7 @@ def test_median_detection(example_subarray): # In this test, the interval [-0.9, 8] corresponds to multiplication factors # typical used for the median values of charge images of flat-field events detector = MedianOutlierDetector( - subarray=example_subarray, median_range_factors=[-0.9, 8] + subarray=example_subarray, median_range_factors=[-0.9, 8.0] ) # Detect outliers outliers = detector(table["median"]) @@ -87,7 +89,7 @@ def test_std_detection(example_subarray): # typical used for the std values of charge images of flat-field events # and median (and std) values of charge images of pedestal events detector = StdOutlierDetector( - subarray=example_subarray, std_range_factors=[-15, 15] + subarray=example_subarray, std_range_factors=[-15.0, 15.0] ) ff_outliers = detector(ff_table["std"]) ped_outliers = detector(ped_table["median"])