From d64f1caa42c990035d929447e727abe381b5b729 Mon Sep 17 00:00:00 2001 From: Kai B Date: Mon, 10 Sep 2018 10:58:26 +0200 Subject: [PATCH 1/3] add failing test to show weird hillas behaviour --- ctapipe/image/tests/test_hillas.py | 31 ++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/ctapipe/image/tests/test_hillas.py b/ctapipe/image/tests/test_hillas.py index d4be5c7d11c..7409be0d984 100644 --- a/ctapipe/image/tests/test_hillas.py +++ b/ctapipe/image/tests/test_hillas.py @@ -57,12 +57,17 @@ def create_sample_image_zeros(psi='-30d'): def create_sample_image_masked(psi='-30d'): geom, image, clean_mask = create_sample_image(psi) - # threshold in pe image = masked_array(image, mask=~clean_mask) - return geom, image +def create_sample_image_selected_pixel(psi='-30d'): + geom, image, clean_mask = create_sample_image(psi) + import IPython; IPython.embed() + + return geom[clean_mask], image[clean_mask] + + def compare_result(x, y): ux = u.Quantity(x) uy = u.Quantity(y) @@ -121,6 +126,28 @@ def test_hillas_masked(): # compare_result(results.kurtosis, results_ma.kurtosis) +def test_hillas_selected(): + """ + test Hillas-parameter routines on a sample image with selected values + against a sample image with masked values set tozero + """ + + geom, image = create_sample_image_zeros() + geom, image_ma = create_sample_image_selected_pixel() + + results = hillas_parameters_4(geom, image) + results_ma = hillas_parameters_4(geom, image_ma) + + compare_result(results.length, results_ma.length) + compare_result(results.width, results_ma.width) + compare_result(results.r, results_ma.r) + compare_result(results.phi.deg, results_ma.phi.deg) + compare_result(results.psi.deg, results_ma.psi.deg) + compare_result(results.skewness, results_ma.skewness) + # compare_result(results.kurtosis, results_ma.kurtosis) + + + def test_hillas_failure(): geom, image = create_sample_image_zeros(psi='0d') blank_image = zeros_like(image) From 541fa5bd9fa4975990423eaa9f8de4ff7fd4fc92 Mon Sep 17 00:00:00 2001 From: Kai B Date: Mon, 10 Sep 2018 11:02:58 +0200 Subject: [PATCH 2/3] remove embed --- ctapipe/image/tests/test_hillas.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ctapipe/image/tests/test_hillas.py b/ctapipe/image/tests/test_hillas.py index 7409be0d984..c0bed7eed23 100644 --- a/ctapipe/image/tests/test_hillas.py +++ b/ctapipe/image/tests/test_hillas.py @@ -63,8 +63,7 @@ def create_sample_image_masked(psi='-30d'): def create_sample_image_selected_pixel(psi='-30d'): geom, image, clean_mask = create_sample_image(psi) - import IPython; IPython.embed() - + return geom[clean_mask], image[clean_mask] From 0904146f87095be50f8dbe27cc50aad8fbd80ad8 Mon Sep 17 00:00:00 2001 From: Kai B Date: Mon, 10 Sep 2018 11:05:59 +0200 Subject: [PATCH 3/3] do note overwrite variable --- ctapipe/image/tests/test_hillas.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ctapipe/image/tests/test_hillas.py b/ctapipe/image/tests/test_hillas.py index c0bed7eed23..1c30042c893 100644 --- a/ctapipe/image/tests/test_hillas.py +++ b/ctapipe/image/tests/test_hillas.py @@ -132,10 +132,10 @@ def test_hillas_selected(): """ geom, image = create_sample_image_zeros() - geom, image_ma = create_sample_image_selected_pixel() + geom_selected, image_ma = create_sample_image_selected_pixel() results = hillas_parameters_4(geom, image) - results_ma = hillas_parameters_4(geom, image_ma) + results_ma = hillas_parameters_4(geom_selected, image_ma) compare_result(results.length, results_ma.length) compare_result(results.width, results_ma.width)