本文整理汇总了Python中ctapipe.visualization.CameraDisplay.overlay_moments方法的典型用法代码示例。如果您正苦于以下问题:Python CameraDisplay.overlay_moments方法的具体用法?Python CameraDisplay.overlay_moments怎么用?Python CameraDisplay.overlay_moments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ctapipe.visualization.CameraDisplay
的用法示例。
在下文中一共展示了CameraDisplay.overlay_moments方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: draw_several_cams
# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import overlay_moments [as 别名]
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.generate_2d_shower_model(
centroid=(0.2 - ii * 0.1, -ii * 0.05),
width=0.05 + 0.001 * ii,
length=0.15 + 0.05 * ii,
psi=ii * 20 * u.deg,
)
image, sig, bg = toymodel.make_toymodel_shower_image(
geom,
model.pdf,
intensity=1500,
nsb_level_pe=5,
)
mask = tailcuts_clean(
geom,
image,
picture_thresh=6 * image.mean(),
boundary_thresh=4 * image.mean()
)
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')
示例2: start
# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import overlay_moments [as 别名]
def start(self):
disp = None
for event in tqdm(self.source,
desc='Tel{}'.format(self.tel),
total=self.reader.max_events,
disable=~self.progress):
self.log.debug(event.trig)
self.log.debug("Energy: {}".format(event.mc.energy))
self.calibrator.calibrate(event)
if disp is None:
x, y = event.inst.pixel_pos[self.tel]
focal_len = event.inst.optical_foclen[self.tel]
geom = CameraGeometry.guess(x, y, focal_len)
self.log.info(geom)
disp = CameraDisplay(geom)
# disp.enable_pixel_picker()
disp.add_colorbar()
if self.display:
plt.show(block=False)
# display the event
disp.axes.set_title('CT{:03d} ({}), event {:06d}'.format(
self.tel, geom.cam_id, event.r0.event_id)
)
if self.samples:
# display time-varying event
data = event.dl0.tel[self.tel].pe_samples[self.channel]
for ii in range(data.shape[1]):
disp.image = data[:, ii]
disp.set_limits_percent(70)
plt.suptitle("Sample {:03d}".format(ii))
if self.display:
plt.pause(self.delay)
if self.write:
plt.savefig('CT{:03d}_EV{:10d}_S{:02d}.png'
.format(self.tel, event.r0.event_id, ii))
else:
# display integrated event:
im = event.dl1.tel[self.tel].image[self.channel]
if self.clean:
mask = tailcuts_clean(geom, im, picture_thresh=10,
boundary_thresh=7)
im[~mask] = 0.0
disp.image = im
if self.hillas:
try:
ellipses = disp.axes.findobj(Ellipse)
if len(ellipses) > 0:
ellipses[0].remove()
params = hillas_parameters(pix_x=geom.pix_x,
pix_y=geom.pix_y, image=im)
disp.overlay_moments(params, color='pink', lw=3,
with_label=False)
except HillasParameterizationError:
pass
if self.display:
plt.pause(self.delay)
if self.write:
plt.savefig('CT{:03d}_EV{:010d}.png'
.format(self.tel, event.r0.event_id))
self.log.info("FINISHED READING DATA FILE")
if disp is None:
self.log.warning('No events for tel {} were found in {}. Try a '
'different EventIO file or another telescope'
.format(self.tel, self.infile),
)
pass
示例3: tailcuts_clean
# 需要导入模块: from ctapipe.visualization import CameraDisplay [as 别名]
# 或者: from ctapipe.visualization.CameraDisplay import overlay_moments [as 别名]
psi='35d')
image, sig, bg = toymodel.make_toymodel_shower_image(geom, model.pdf,
intensity=50,
nsb_level_pe=1000)
# Apply image cleaning
cleanmask = tailcuts_clean(geom, image, picture_thresh=200,
boundary_thresh=100)
clean = image.copy()
clean[~cleanmask] = 0.0
# Calculate image parameters
hillas = hillas_parameters(geom.pix_x, geom.pix_y, clean)
print(hillas)
# Show the camera image and overlay Hillas ellipse and clean pixels
disp.image = image
disp.cmap = 'PuOr'
disp.highlight_pixels(cleanmask, color='black')
disp.overlay_moments(hillas, color='cyan', linewidth=3)
# Draw the neighbors of pixel 100 in red, and the neighbor-neighbors in
# green
for ii in geom.neighbors[130]:
draw_neighbors(geom, ii, color='green')
draw_neighbors(geom, 130, color='cyan', lw=2)
plt.show()