CameraDisplay

class ctapipe.visualization.CameraDisplay(geometry, image=None, cmap='inferno', norm='lin', autoscale=True, title=None, allow_pick=False, autoupdate=True, show_frame=True, ax=None)[source]

Bases: object

Camera Display using matplotlib.

Parameters
geometryCameraGeometry

Definition of the Camera/Image

image: array_like

array of values corresponding to the pixels in the CameraGeometry.

axmatplotlib.axes.Axes

A matplotlib axes object to plot on, or None to create a new one

titlestr (default “Camera”)

Title to put on camera plot

normstr or matplotlib.colors.Normalize instance (default ‘lin’)

Normalization for the color scale. Supported str arguments are - ‘lin’: linear scale - ‘log’: logarithmic scale (base 10)

cmapstr or matplotlib.colors.Colormap (default ‘hot’)

Color map to use (see matplotlib.cm)

allow_pickbool (default False)

if True, allow user to click and select a pixel

autoupdatebool (default True)

redraw automatically (otherwise need to call plt.draw())

autoscalebool (default True)

rescale the vmin/vmax values when the image changes. This is set to False if set_limits_* is called to explicity set data limits.

Notes

Speed:

CameraDisplay is not intended to be very fast (matplotlib is not a very speed performant graphics library, it is intended for nice output plots). However, most of the slowness of CameraDisplay is in the constructor. Once one is displayed, changing the image that is displayed is relatively fast and efficient. Therefore it is best to initialize an instance, and change the data, rather than generating new CameraDisplays.

Pixel Implementation:

Pixels are rendered as a matplotlib.collections.PatchCollection of Polygons (either 6 or 4 sided). You can access the PatchCollection directly (to e.g. change low-level style parameters) via CameraDisplay.pixels

Output:

Since CameraDisplay uses matplotlib, any display can be saved to any output file supported via plt.savefig(filename). This includes .pdf and .png.

Attributes Summary

cmap

Color map to use.

image

The image displayed on the camera (1D array of pixel values)

norm

The norm instance of the Display

Methods Summary

add_colorbar(**kwargs)

add a colorbar to the camera plot kwargs are passed to figure.colorbar(self.pixels, **kwargs) See matplotlib documentation for the supported kwargs: https://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure.colorbar

add_ellipse(centroid, length, width, angle)

plot an ellipse on top of the camera

add_frame_name([color])

label the frame type of the display (e.g.

auto_set_axes_labels()

set the axes labels based on the Frame attribute

clear_overlays()

Remove added overlays from the axes

create_patches(shape, pix_x, pix_y, pix_width)

enable_pixel_picker()

enable ability to click on pixels

highlight_pixels(pixels[, color, linewidth, …])

Highlight the given pixels with a colored line around them

on_pixel_clicked(pix_id)

virtual function to overide in sub-classes to do something special when a pixel is clicked

overlay_coordinate(coord[, keep_old])

Plot a coordinate into the CameraDisplay

overlay_moments(hillas_parameters[, …])

helper to overlay ellipse from a HillasParametersContainer structure

set_limits_minmax(zmin, zmax)

set the color scale limits from min to max

set_limits_percent([percent])

auto-scale the color range to percent of maximum

show()

update()

redraw the display now

Attributes Documentation

cmap

Color map to use. Either name or matplotlib.colors.Colormap

image

The image displayed on the camera (1D array of pixel values)

norm

The norm instance of the Display

Possible values:

  • “lin”: linear scale

  • “log”: log scale (cannot have negative values)

  • “symlog”: symmetric log scale (negative values are ok)

  • any matplotlib.colors.Normalize instance, e. g. PowerNorm(gamma=-2)

Methods Documentation

add_colorbar(**kwargs)[source]

add a colorbar to the camera plot kwargs are passed to figure.colorbar(self.pixels, **kwargs) See matplotlib documentation for the supported kwargs: https://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure.colorbar

add_ellipse(centroid, length, width, angle, asymmetry=0.0, **kwargs)[source]

plot an ellipse on top of the camera

Parameters
centroid: (float, float)

position of centroid

length: float

major axis

width: float

minor axis

angle: float

rotation angle wrt x-axis about the centroid, anticlockwise, in radians

asymmetry: float

3rd-order moment for directionality if known

kwargs:

any MatPlotLib style arguments to pass to the Ellipse patch

add_frame_name(color='grey')[source]

label the frame type of the display (e.g. CameraFrame)

auto_set_axes_labels()[source]

set the axes labels based on the Frame attribute

clear_overlays()[source]

Remove added overlays from the axes

static create_patches(shape, pix_x, pix_y, pix_width, pix_rotation=<Quantity 0. deg>)[source]
enable_pixel_picker()[source]

enable ability to click on pixels

highlight_pixels(pixels, color='g', linewidth=1, alpha=0.75)[source]

Highlight the given pixels with a colored line around them

Parameters
pixelsindex-like

The pixels to highlight. Can either be a list or array of integers or a boolean mask of length number of pixels

color: a matplotlib conform color

the color for the pixel highlighting

linewidth: float

linewidth of the highlighting in points

alpha: 0 <= alpha <= 1

The transparency

on_pixel_clicked(pix_id)[source]

virtual function to overide in sub-classes to do something special when a pixel is clicked

overlay_coordinate(coord, keep_old=False, **kwargs)[source]

Plot a coordinate into the CameraDisplay

Parameters
coordSkyCoord

The coordinate to plot. Must be able to be transformed into the frame of the camera geometry of this display. Most of the time, this means you need to add the telescope pointing as a coordinate attribute like this: SkyCoord(..., telescope_pointing=pointing)

keep_oldbool

If False, any previously created overlays will be removed before plotting the new one

kwargs

All kwargs are passed to matplotlib.Axes.plot

overlay_moments(hillas_parameters, with_label=True, keep_old=False, **kwargs)[source]

helper to overlay ellipse from a HillasParametersContainer structure

Parameters
hillas_parameters: `HillasParametersContainer`

structuring containing Hillas-style parameterization

with_label: bool

If True, show coordinates of centroid and width and length

keep_old: bool

If True, to not remove old overlays

kwargs: key=value

any style keywords to pass to matplotlib (e.g. color=’red’ or linewidth=6)

set_limits_minmax(zmin, zmax)[source]

set the color scale limits from min to max

set_limits_percent(percent=95)[source]

auto-scale the color range to percent of maximum

show()[source]
update()[source]

redraw the display now