ctapipe is not stable yet, so expect large and rapid changes to structure and functionality as we explore various design choices before the 1.0 release.

Basic Image Cleaning and Dilation#

Here we create an example shower image, do a tail-cuts (picture/boundary) cleaning, and then dilate the resulting cleaning mask by several neighbor pixels

11 import astropy.units as u
12
13 # %matplotlib inline
14 from matplotlib import pyplot as plt
15
16 from ctapipe.image import dilate, tailcuts_clean, toymodel
17 from ctapipe.instrument import SubarrayDescription
18 from ctapipe.visualization import CameraDisplay
19
20 # Load a camera from an example file
21 subarray = SubarrayDescription.read("dataset://gamma_prod5.simtel.zst")
22 geom = subarray.tel[100].camera.geometry
23
24 # Create a fake camera image to display:
25 model = toymodel.Gaussian(
26     x=0.2 * u.m,
27     y=0.0 * u.m,
28     width=0.05 * u.m,
29     length=0.15 * u.m,
30     psi="35d",
31 )
32
33 image, sig, bg = model.generate_image(geom, intensity=1500, nsb_level_pe=5)

Apply the image cleaning:

40 cleanmask = tailcuts_clean(geom, image, picture_thresh=10, boundary_thresh=5)
41 clean = image.copy()
42 clean[~cleanmask] = 0.0
43
44 disp = CameraDisplay(geom, image=image)
45 disp.highlight_pixels(cleanmask, color="red")
NectarCam

Now dialte the mask a few times:

53 def show_dilate(mask, times=1):
54     m = mask.copy()
55     for ii in range(times):
56         m = dilate(geom, m)
57     CameraDisplay(
58         geom, image=(m.astype(int) + mask.astype(int)), title="dilate{}".format(times)
59     )
63 plt.figure(figsize=(18, 3))
64
65 for ii in range(0, 6):
66     plt.subplot(1, 7, ii + 1)
67     show_dilate(cleanmask.copy(), times=ii)
dilate0, dilate1, dilate2, dilate3, dilate4, dilate5

Total running time of the script: (0 minutes 4.273 seconds)

Gallery generated by Sphinx-Gallery