forked from cta-observatory/ctapipe
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_hillas_parameters.py
More file actions
executable file
·43 lines (32 loc) · 1.19 KB
/
Copy pathplot_hillas_parameters.py
File metadata and controls
executable file
·43 lines (32 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
"""
Example of drawing a Camera using a toymodel shower image.
"""
import matplotlib.pylab as plt
import astropy.units as u
from ctapipe.image import toymodel, hillas_parameters, tailcuts_clean
from ctapipe.instrument import CameraGeometry
from ctapipe.visualization import CameraDisplay
if __name__ == "__main__":
# Load the camera
geom = CameraGeometry.from_name("LSTCam")
disp = CameraDisplay(geom)
disp.add_colorbar()
# Create a fake camera image to display:
model = toymodel.Gaussian(
x=0.2 * u.m, y=0.0 * u.m, width=0.05 * u.m, length=0.15 * u.m, psi="35d"
)
image, sig, bg = model.generate_image(geom, intensity=1500, nsb_level_pe=2)
# Apply image cleaning
cleanmask = tailcuts_clean(geom, image, picture_thresh=10, boundary_thresh=5)
clean = image.copy()
clean[~cleanmask] = 0.0
# Calculate image parameters
hillas = hillas_parameters(geom, clean)
print(hillas)
# Show the camera image and overlay Hillas ellipse and clean pixels
disp.image = image
disp.cmap = "inferno"
disp.highlight_pixels(cleanmask, color="crimson")
disp.overlay_moments(hillas, color="cyan", linewidth=1)
plt.show()