Skip to content

Commit

Permalink
added more units tests
Browse files Browse the repository at this point in the history
  • Loading branch information
clara-escanuela committed Jan 17, 2024
1 parent 4b4acf4 commit 1f94003
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
6 changes: 3 additions & 3 deletions ctapipe/image/cleaning.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ def time_clustering(
firstly applied. The cut is performed relative to the noise to account for, e.g., bright stars. Alternatively,
a hard cut could also be performed.
DBSCAN runs with the reconstructed times and pixel positions after rescaling. The reconstructed times and
pixel positions are rescaled because eps is not dimension dependent. If scaling is performed properly, eps
can be set to 1. DBSCAN returns the cluster IDs of each point being -1 the label for noise pixels.
DBSCAN runs with the reconstructed times and pixel positions after scaling. Scaling is needed because eps
is not dimension dependent. If scaling is performed properly, eps can be set to 1. DBSCAN returns the
cluster IDs of each point being -1 the label for noise pixels.
Parameters
----------
Expand Down
44 changes: 43 additions & 1 deletion ctapipe/image/tests/test_cleaning.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def test_time_cleaning():
core_neighbors = geom.neighbors[core_pixel]

charge[core_pixel], charge[core_neighbors] = 15, 5
peak_time[core_pixel], peak_time[core_neighbors] = (18, 20)
peak_time[core_pixel], peak_time[core_neighbors] = (0.0, 0.0)

mask = cleaning.time_clustering(
geom,
Expand All @@ -358,6 +358,48 @@ def test_time_cleaning():

assert np.count_nonzero(mask) == 0

mask = cleaning.time_clustering(
geom,
charge,
peak_time,
eps=1.0,
space_scale_m=0.25,
time_scale_ns=4.0,
hard_cut_pe=1,
minpts=5,
)

assert np.count_nonzero(mask) == 7

mask = cleaning.time_clustering(
geom,
charge,
peak_time,
eps=1.0,
space_scale_m=0.25,
time_scale_ns=4.0,
hard_cut_pe=1,
minpts=8,
)

assert np.count_nonzero(mask) == 0

charge[core_pixel], charge[core_neighbors] = 15, 5
peak_time[core_pixel], peak_time[core_neighbors] = (0.0, 30.0)

mask = cleaning.time_clustering(
geom,
charge,
peak_time,
eps=1.0,
space_scale_m=0.25,
time_scale_ns=4.0,
hard_cut_pe=1,
minpts=5,
)

assert np.count_nonzero(mask) == 6


def test_time_constrained_clean():
geom = CameraGeometry.from_name("LSTCam")
Expand Down

0 comments on commit 1f94003

Please sign in to comment.