Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from ctapipe.instrument import CameraDescription, CameraGeometry
from ctapipe.visualization import CameraDisplay
if __name__ == "__main__":
plt.style.use("bmh")
camera_names = CameraDescription.get_known_camera_names()
n_tels = len(camera_names)
n_rows = np.trunc(np.sqrt(n_tels)).astype(int)
n_cols = np.ceil(n_tels / n_rows).astype(int)
plt.figure(figsize=(15, 6))
for ii, name in enumerate(sorted(camera_names)):
print("plotting", name)
geom = CameraGeometry.from_name(name)
ax = plt.subplot(n_rows, n_cols, ii + 1)
disp = CameraDisplay(geom)
disp.image = np.random.uniform(size=geom.pix_id.shape)
disp.cmap = "viridis"
plt.xlabel("")
plt.ylabel("")
plt.tight_layout()
plt.show()
def main():
fig, axs = plt.subplots(1, 2, constrained_layout=True, figsize=(6, 3))
model = Gaussian(0 * u.m, 0.1 * u.m, 0.3 * u.m, 0.05 * u.m, 25 * u.deg)
cam = CameraGeometry.from_name("FlashCam")
image, *_ = model.generate_image(cam, 2500)
CameraDisplay(cam, ax=axs[0], image=image)
CameraDisplay(
cam.transform_to(EngineeringCameraFrame()), ax=axs[1], image=image,
)
axs[0].set_title("CameraFrame")
axs[1].set_title("EngineeringCameraFrame")
plt.show()
# fill LST data from the CameraConfig table
self.fill_lst_service_container_from_zfile()
# Instrument information
for tel_id in self.data.lst.tels_with_data:
assert (tel_id == 0) # only LST1 for the moment (id = 0)
# optics info from standard optics.fits.gz file
optics = OpticsDescription.from_name("LST")
optics.tel_subtype = '' # to correct bug in reading
# camera info from LSTCam-[geometry_version].camgeom.fits.gz file
geometry_version = 2
camera = CameraGeometry.from_name("LSTCam", geometry_version)
tel_descr = TelescopeDescription(optics, camera)
self.n_camera_pixels = tel_descr.camera.n_pixels
tels = {tel_id: tel_descr}
# LSTs telescope position taken from MC from the moment
tel_pos = {tel_id: [50., 50., 16] * u.m}
subarray = SubarrayDescription("LST1 subarray")
subarray.tels = tels
subarray.positions = tel_pos
self.data.inst.subarray = subarray
import numpy as np
from astropy import units as u
from matplotlib import pyplot as plt
from ctapipe.instrument import CameraGeometry
from ctapipe.visualization import CameraDisplay
if __name__ == "__main__":
geom = CameraGeometry.from_name("Whipple109")
image = np.random.uniform(size=geom.pix_id.shape)
plt.figure(figsize=(10, 4))
N = 4
for ii in range(N):
plt.subplot(1, N, ii + 1)
geom.rotate(ii * (geom.pix_rotation + 30 * u.deg))
d2 = CameraDisplay(geom, image=image, cmap="viridis")
plt.tight_layout()
plt.show()
)
cleaned = image.copy()
cleaned[~mask] = 0
hillas = hillas_parameters(geom, cleaned)
disp.image = image
disp.add_colorbar(ax=axs[ii])
disp.set_limits_percent(95)
disp.overlay_moments(hillas, linewidth=3, color="blue")
if __name__ == "__main__":
hexgeom = CameraGeometry.from_name("LSTCam")
recgeom = CameraGeometry.make_rectangular()
draw_several_cams(recgeom)
draw_several_cams(hexgeom)
plt.tight_layout()
plt.show()
"""
import astropy.units as u
import matplotlib.pylab as plt
from matplotlib.colors import PowerNorm
from matplotlib.style import use
from ctapipe.image import toymodel
from ctapipe.instrument import CameraGeometry
from ctapipe.visualization import CameraDisplay
if __name__ == "__main__":
use("ggplot")
# load the camera
fig, axs = plt.subplots(1, 3, figsize=(15, 5))
geom = CameraGeometry.from_name("LSTCam")
titles = "Linear Scale", "Log-Scale", "PowerNorm(gamma=2)"
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=5,)
disps = []
for ax, title in zip(axs, titles):
disps.append(CameraDisplay(geom, ax=ax, image=image, title=title))
disps[0].norm = "lin"
disps[1].norm = "log"
disps[2].norm = PowerNorm(2)