Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def update(frame):
x, y = np.random.uniform(-fov, fov, size=2) * scale
width = np.random.uniform(0, maxwid - minwid) * scale + minwid
length = np.random.uniform(0, maxlen) * scale + width
angle = np.random.uniform(0, 360)
intens = np.random.exponential(2) * 500
model = toymodel.Gaussian(
x=x * u.m,
y=y * u.m,
width=width * u.m,
length=length * u.m,
psi=angle * u.deg,
)
self.log.debug(
"Frame=%d width=%03f length=%03f intens=%03d",
frame,
width,
length,
intens,
)
image, _, _ = model.generate_image(geom, intensity=intens, nsb_level_pe=3,)
def draw_several_cams(geom, ncams=4):
cmaps = ["jet", "afmhot", "terrain", "autumn"]
fig, axs = plt.subplots(1, ncams, figsize=(15, 4),)
for ii in range(ncams):
disp = CameraDisplay(geom, ax=axs[ii], title="CT{}".format(ii + 1),)
disp.cmap = cmaps[ii]
model = toymodel.Gaussian(
x=(0.2 - ii * 0.1) * u.m,
y=(-ii * 0.05) * u.m,
width=(0.05 + 0.001 * ii) * u.m,
length=(0.15 + 0.05 * ii) * u.m,
psi=ii * 20 * u.deg,
)
image, _, _ = model.generate_image(geom, intensity=1500, nsb_level_pe=5,)
mask = tailcuts_clean(
geom,
image,
picture_thresh=6 * image.mean(),
boundary_thresh=4 * image.mean(),
)
cleaned = image.copy()
from ctapipe.image import toymodel
from ctapipe.instrument import CameraGeometry
from ctapipe.visualization import CameraDisplay
if __name__ == "__main__":
plt.style.use("ggplot")
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(1, 1, 1)
geom = CameraGeometry.from_name("NectarCam")
disp = CameraDisplay(geom, ax=ax)
disp.add_colorbar()
model = toymodel.Gaussian(
x=0.05 * u.m, y=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)
disp.image = image
mask = disp.image > 10
disp.highlight_pixels(mask, linewidth=2, color="crimson")
plt.show()
def update(frame):
x, y = np.random.uniform(-fov, fov, size=2)
width = np.random.uniform(0.01, maxwid)
length = np.random.uniform(width, maxlen)
angle = np.random.uniform(0, 180)
intens = width * length * (5e4 + 1e5 * np.random.exponential(2))
model = toymodel.Gaussian(
x=x * u.m,
y=y * u.m,
width=width * u.m,
length=length * u.m,
psi=angle * u.deg,
)
image, _, _ = model.generate_image(geom, intensity=intens, nsb_level_pe=5,)
disp.image = image
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()
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)
for disp in disps:
disp.add_colorbar(ax=disp.axes)