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.

Convert camera images to pixels on a s square grid#

 7 import astropy.units as u
 8 import matplotlib.pyplot as plt
 9
10 from ctapipe.image.toymodel import Gaussian
11 from ctapipe.instrument import SubarrayDescription
12 from ctapipe.visualization import CameraDisplay

get the subarray from an example file

16 subarray = SubarrayDescription.read("dataset://gamma_prod5.simtel.zst")

Geometries with square pixels#

Define a camera geometry and generate a dummy image:

26 geom = subarray.tel[40].camera.geometry
27 model = Gaussian(
28     x=0.05 * u.m,
29     y=0.05 * u.m,
30     width=0.01 * u.m,
31     length=0.05 * u.m,
32     psi="30d",
33 )
34 _, image, _ = model.generate_image(geom, intensity=500, nsb_level_pe=3)
37 CameraDisplay(geom, image)
CHEC
<ctapipe.visualization.mpl_camera.CameraDisplay object at 0x7f7469af2d40>

The CameraGeometry has functions to convert the 1d image arrays to 2d arrays and back to the 1d array:

45 image_square = geom.image_to_cartesian_representation(image)
convert images to 2d
<matplotlib.image.AxesImage object at 0x7f746a5a9630>
51 image_1d = geom.image_from_cartesian_representation(image_square)
54 CameraDisplay(geom, image_1d)
CHEC
<ctapipe.visualization.mpl_camera.CameraDisplay object at 0x7f746aafbdc0>

Geometries with hexagonal pixels#

Define a camera geometry and generate a dummy image:

64 geom = subarray.tel[1].camera.geometry
65 model = Gaussian(
66     x=0.5 * u.m,
67     y=0.5 * u.m,
68     width=0.1 * u.m,
69     length=0.2 * u.m,
70     psi="30d",
71 )
72 _, image, _ = model.generate_image(geom, intensity=5000)
75 CameraDisplay(geom, image)
LSTCam
<ctapipe.visualization.mpl_camera.CameraDisplay object at 0x7f746e7bd570>
78 image_square = geom.image_to_cartesian_representation(image)

Conversion into square geometry#

Since the resulting array has square pixels, the pixel grid has to be rotated and distorted. This is reversible (The image_from_cartesian_representation method takes care of this):

convert images to 2d
<matplotlib.image.AxesImage object at 0x7f7468d7ff70>
93 image_1d = geom.image_from_cartesian_representation(image_square)
96 disp = CameraDisplay(geom, image_1d)
LSTCam

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

Gallery generated by Sphinx-Gallery