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)
CHEC
<ctapipe.visualization.mpl_camera.CameraDisplay object at 0x79f094d37c70>

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

convert images to 2d
<matplotlib.image.AxesImage object at 0x79f08bac9a80>
CHEC
<ctapipe.visualization.mpl_camera.CameraDisplay object at 0x79f08af8a980>

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)
LSTCam
<ctapipe.visualization.mpl_camera.CameraDisplay object at 0x79f08b5d2800>

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 0x79f08a954220>
LSTCam

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

Gallery generated by Sphinx-Gallery