Skip to content

Commit

Permalink
Merge pull request #8 from HealthyPear/feature/mars_1st_pass_cleaning…
Browse files Browse the repository at this point in the history
…_ctapipe

CTA-MARS 1st pass cleaning from ctapipe
  • Loading branch information
HealthyPear committed Oct 20, 2019
2 parents cd151d4 + 89a6542 commit ff46672
Showing 1 changed file with 2 additions and 51 deletions.
53 changes: 2 additions & 51 deletions protopipe/pipeline/image_cleaning.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import numpy as np
from ctapipe.image.cleaning import tailcuts_clean
from ctapipe.image.cleaning import mars_cleaning_1st_pass

try:
from pywicta.denoising.wavelets_mrtransform import WaveletTransform
Expand All @@ -16,46 +16,6 @@
__all__ = ["ImageCleaner"]


def mars_cleaning_1st_pass(
geom,
image,
picture_thresh=7,
boundary_thresh=5,
keep_isolated_pixels=False,
min_number_picture_neighbors=0,
):

"""This is here temporarely, just for test-productions.
There will be a separate pull-request on ctapipe."""

pixels_from_tailcuts_clean = tailcuts_clean(
geom,
image,
picture_thresh,
boundary_thresh,
keep_isolated_pixels,
min_number_picture_neighbors,
) # this does checks for core pixels and first neighbors

# MARS has the same threshold for both boundary_thresh
pixels_above_2nd_boundary = image >= boundary_thresh

pixels_with_previous_neighbors = geom.neighbor_matrix_sparse.dot(
pixels_from_tailcuts_clean
)
if keep_isolated_pixels:
return (
pixels_above_2nd_boundary & pixels_with_previous_neighbors
) | pixels_from_tailcuts_clean
else:
pixels_with_2ndboundary_neighbors = geom.neighbor_matrix_sparse.dot(
pixels_above_2nd_boundary
)
return (pixels_above_2nd_boundary & pixels_with_previous_neighbors) | (
pixels_from_tailcuts_clean & pixels_with_2ndboundary_neighbors
)


class ImageCleaner(object):
"""Class applying image cleaning. It can handle wavelet or tail-cuts-based methods.
Expand Down Expand Up @@ -94,16 +54,7 @@ def initialise_clean_opt(self):
"min_number_picture_neighbors": opt["min_number_picture_neighbors"],
}

# print(type)
# print(cam_id)
# print(cuts)

# we don't want to use the old tailcut ....
# self.cleaners[cam_id] = lambda img, geom, opt: tailcuts_clean(
# image=img, geom=geom, **opt
# )

# ... we want to use new MARS 1st pass function
# Select the CTA-MARS 1st pass as cleaning algorithm
self.cleaners[cam_id] = lambda img, geom, opt: mars_cleaning_1st_pass(
image=img, geom=geom, **opt
)
Expand Down

0 comments on commit ff46672

Please sign in to comment.