Visualization#
In this section you find the reference documentation of the modules contained in the visualization module.
visualize#
Module for visualization.
- visualization.visualize.get_colors(palette='default')[source]#
Get the colour list of the palette requested.
If no palette is provided, the default is returned.
- Parameters:
- palette: str
Colour palette.
- Returns:
- list
Colour list.
- Raises:
- KeyError
if provided palette does not exist.
- visualization.visualize.get_lines()[source]#
Get the line style list used in this module.
- Returns:
- list
List with line styles.
- visualization.visualize.get_markers()[source]#
Get the marker list used in this module.
- Returns:
- list
List with markers.
- visualization.visualize.plot_1d(data, **kwargs)[source]#
Produce a high contrast one dimensional plot from multiple data sets.
A ratio plot can be added at the bottom to allow easy comparison. Additional options, such as plot title, plot legend, etc., are given in kwargs. Any option that can be changed after plotting (e.g., axes limits, log scale, etc.) should be done using the returned plt instance.
- Parameters:
- data: numpy structured array or a dictionary of structured arrays
Each structured array has two columns, the first is the x-axis and the second the y-axis. The titles of the columns are set as the axes titles. The labels of each dataset set are given in the dictionary keys and will be used in the legend.
- **kwargs:
palette: string Choose a colour palette (see set_style for additional information).
title: string Set a plot title.
no_legend: bool Do not print a legend for the plot.
big_plot: bool Increase marker and font sizes (like in a wide light curve).
no_markers: bool Do not print markers.
empty_markers: bool Print empty (hollow) markers
plot_ratio: bool Add a ratio plot at the bottom. The first entry in the data dictionary is used as the reference for the ratio. If data dictionary is not an OrderedDict, the reference will be random.
plot_difference: bool Add a difference plot at the bottom. The first entry in the data dictionary is used as the reference for the difference. If data dictionary is not an OrderedDict, the reference will be random.
Any additional kwargs for plt.plot
- Returns:
- pyplot.figure
Instance of pyplot.figure in which the plot was produced
- Raises:
- ValueError
if asked to plot a ratio or difference with just one set of data
- visualization.visualize.plot_hist_2d(data, **kwargs)[source]#
Produce a two dimensional histogram plot.
Any option that can be changed after plotting (e.g., axes limits, log scale, etc.) should be done using the returned plt instance.
- Parameters:
- data: numpy structured array
The columns of the structured array are used as the x-axis and y-axis titles.
- **kwargs:
title: set a plot title.
Any additional kwargs for plt.hist2d
- Returns:
- pyplot.figure
Instance of pyplot.figure in which the plot was produced.
- visualization.visualize.plot_table(table, y_title, **kwargs)[source]#
Produce a high contrast one dimensional plot from the data in an astropy.Table.
A ratio plot can be added at the bottom to allow easy comparison. Additional options, such as plot title, plot legend, etc., are given in kwargs. Any option that can be changed after plotting (e.g., axes limits, log scale, etc.) should be done using the returned plt instance.
- Parameters:
- table: astropy.Table or astropy.QTable
The first column of the table is the x-axis and the second column is the y-axis. Any additional columns will be treated as additional data to plot. The column titles are used in the legend (except for the first column).
- y_title: str
The y-axis title.
- **kwargs:
palette: choose a colour palette (see set_style for additional information).
title: set a plot title.
no_legend: do not print a legend for the plot.
big_plot: increase marker and font sizes (like in a wide light curve).
no_markers: do not print markers.
empty_markers: print empty (hollow) markers
plot_ratio: bool Add a ratio plot at the bottom. The first entry in the data dictionary is used as the reference for the ratio. If data dictionary is not an OrderedDict, the reference will be random.
plot_difference: bool Add a difference plot at the bottom. The first entry in the data dictionary is used as the reference for the difference. If data dictionary is not an OrderedDict, the reference will be random.
Any additional kwargs for plt.plot
- Returns:
- pyplot.fig
Instance of pyplot.fig.
- Raises:
- ValueError
if table has less than two columns.
- visualization.visualize.save_figure(fig, output_file, figure_format=None, log_title='', dpi='figure')[source]#
Save figure to output file(s).
- Parameters:
- fig: plt.figure
Figure to save.
- output_file: Path, str
Path to save the figure (without suffix).
- figure_format: list
List of formats to save the figure.
- title: str
Title of the figure to be added to the log message.
- visualization.visualize.set_style(palette='default', big_plot=False)[source]#
Set the plotting style to homogenize plot style across the framework.
The function receives the colour palette name and whether it is a big plot or not. The latter sets the fonts and marker to be bigger in case it is a big plot. The available colour palettes are as follows:
classic (default): A classic colorful palette with strong colors and contrast.
modified classic: Similar to the classic, with slightly different colors.
autumn: A slightly darker autumn style colour palette.
purples: A pseudo sequential purple colour palette (not great for contrast).
greens: A pseudo sequential green colour palette (not great for contrast).
To use the function, simply call it before plotting anything. The function is made public, so that it can be used outside the visualize module. However, it is highly recommended to create plots only through the visualize module.
- Parameters:
- palette: str
Colour palette.
- big_plot: bool
Flag to set fonts and marker bigger. If True, it sets them bigger.
- Raises:
- KeyError
if provided palette does not exist.
legend_handlers#
Helper functions for legend handlers used for plotting.
- class visualization.legend_handlers.HexEdgePixelHandler[source]#
Legend handler class to plot a hexagonal “edge” pixel.
- class visualization.legend_handlers.HexOffPixelHandler[source]#
Legend handler class to plot a hexagonal “off” pixel.
- class visualization.legend_handlers.HexPixelHandler[source]#
Legend handler class to plot a hexagonal “on” pixel.
- class visualization.legend_handlers.LSTHandler(radius=None)[source]#
Legend handler class to plot a representation of an LST in an array layout.
- class visualization.legend_handlers.MSTHandler(radius=None)[source]#
Legend handler class to plot a representation of an MST in an array layout.
- class visualization.legend_handlers.MeanRadiusOuterEdgeHandler[source]#
Legend handler class to plot a the mean radius outer edge of the dish.
- class visualization.legend_handlers.MeanRadiusOuterEdgeObject[source]#
Object for Mean radius outer edge.
- class visualization.legend_handlers.SCTHandler(radius=None)[source]#
Legend handler class to plot a representation of an SCT in an array layout.
- class visualization.legend_handlers.SSTHandler(radius=None)[source]#
Legend handler class to plot a representation of an SST in an array layout.
- class visualization.legend_handlers.SquareEdgePixelHandler[source]#
Legend handler class to plot a square “edge” pixel.
- class visualization.legend_handlers.SquareOffPixelHandler[source]#
Legend handler class to plot a square “off” pixel.
plot_array_layout#
Plot array elements for a layout.
- visualization.plot_array_layout.get_telescope_patch(name, x, y, radius)[source]#
Create patch for a telescope.
- Returns:
- patchPatch
Circle or rectangle patch.
- visualization.plot_array_layout.plot_array_layout(telescopes, show_tel_label=False, axes_range=None, marker_scaling=1.0, background_telescopes=None)[source]#
Plot telescope array layout.
- Parameters:
- telescopesTable
Telescope data table.
- show_tel_labelbool
Show telescope labels (default False).
- axes_rangefloat or None
Axis range, auto if None.
- marker_scalingfloat
Marker size scale factor.
- background_telescopesTable or None
Optional background telescope table.
- Returns:
- figFigure
Matplotlib figure object.
plot_camera#
Plot camera pixel layout.
- visualization.plot_camera.plot_pixel_layout(camera, camera_in_sky_coor=False, pixels_id_to_print=50)[source]#
Plot the pixel layout for an observer facing the camera.
Including in the plot edge pixels, off pixels, pixel ID for the first 50 pixels, coordinate systems, FOV, focal length and the average edge radius.
- Parameters:
- cameraCamera
Camera object to plot.
- camera_in_sky_coorbool, optional
Flag to plot the camera in the sky coordinate system.
- pixels_id_to_printint, optional
Number of pixel IDs to print in the plot.
- Returns:
- figplt.Figure
Figure with the pixel layout.
plot_tables#
Plot tabular data.
plot_pixels#
Functions for plotting pixel layout information.
- visualization.plot_pixels.plot(config, output_file, db_config=None)[source]#
Plot pixel layout based on configuration.
- Parameters:
- configdict
Configuration dictionary containing: - file_name : str, name of camera config file - column_x : str, x-axis label - column_y : str, y-axis label - parameter_version: str, version of the parameter - telescope : str, name of the telescope
- output_filestr
Path where to save the plot
- db_configdict, optional
Database configuration.
- Returns:
- None
The function saves the plot to the specified output file.
- visualization.plot_pixels.plot_pixel_layout_from_file(dat_file_path, telescope_model_name, **kwargs)[source]#
Plot the pixel layout from a camera config file.
This function reads the pixel configuration from the specified camera config file and generates a plot of the pixel layout for the given telescope model.
- Parameters:
- dat_file_pathstr or Path
Path to the camera config file containing pixel configuration
- telescope_model_namestr
Name/model of the telescope
- **kwargs
- pixels_id_to_printint
Number of pixel IDs to print in the plot
- titlestr
Plot title
- xtitlestr
X-axis label
- ytitlestr
Y-axis label
- Returns:
- matplotlib.figure.Figure
The generated figure