Plotting

Plotting routines for displaying image sensor data using matplotlib and seaborn.

sls_detector_tools.plot.add_module_gaps(image)[source]

Add the gaps in a multi module system

Parameters:image (numpy_array) – Image used for expanding
Returns:new_image – Image with the gaps inserted
Return type:numpy_array
sls_detector_tools.plot.chip_histograms(data, xmin=0, xmax=2000, bins=400)[source]

Plot a histogram per chip of the inflection point (fit_result[‘mu’])

Parameters:
  • data (numpy_array) – numpy_array in type of fit_results with named fields
  • xmin (int, optional) – Lover edge of the histogram
  • xmax (int, optional) – Higher edge of the histogram
  • bins (int, optional) – Number of bins in the histogram
sls_detector_tools.plot.draw_module_borders(ax, vertical=False, half_module=False)[source]

Draw lines outlining the individual modules in the Eiger9M. Options as well for half modules

Parameters:
  • ax (mpl.axes) – axes of the image that should be drawn on
  • vertical (bool, optional) – Defaults to False, set to True if the image is rotated to vertical layout
  • half_module (bool) – Defaults to False, set to True to also draw a line at the border between half modules
sls_detector_tools.plot.draw_module_names(ax, vertical=False, color='white')[source]

Write out the names of the modules in the 9M image. Names are fetched from sls_detector.config.Eiger9M

Parameters:
  • ax (mpl.axes) – axes to draw the names on
  • vertical (bool, optional) – Defaults to False, set to True if the image is rotated
  • color (str) – Textcolor
sls_detector_tools.plot.fix_large_pixels(image, interpolation=True)[source]

Expand and interpolate the values in large pixels at borders and in corners Works on sigle module data with one or several frames

sls_detector_tools.plot.global_scurve(data, x, chip_divided=False)[source]

Plot a global scurve and differential scurve for the data provided.

Parameters:
  • data (numpy_array[row, col, N]) – Data to plot
  • x (numpy_array[N]) – Data for the x axis
  • chip_divided (bool) – Plot each chip seperate
  • Returns
    x: numpy_array
    xaxis data, usually threshold
    y: numpy_array
    summed counts per step

Warning

Chip divided plot is only implemented for a single module

sls_detector_tools.plot.histogram(data, xmin=0, xmax=10, nbins=10, plot=True)[source]

Histogram using a ROOT.TH1D

Parameters:
  • data (numpy_array any dimension) – Data points for the histogram
  • xmin (double) – Low limit
  • xmax (double) – High limit
  • nbins (int) – number of bins of the histogram
Returns:

result – Python dict holding x, y, mean and std

Return type:

dict

sls_detector_tools.plot.imshow(data, cmap='coolwarm', log=False, draw_asics=False, asic_color='white', asic_linewidth=2, figsize=(16, 10))[source]

Plot an image with colorbar

Parameters:
  • data (2d numpy_array) – Image data
  • cmap (std) – Name of the colormap that should be used for the plot. Default is coolwarm
  • log (bool) – If True apply a logaritmical colorscale
  • draw_asics (bool) – Draw the edges of the asic in the module Warning this currently only works for single modules
Returns:

  • ax (mpl.axes) – Matplotlib axes object
  • im (mppl.image) – Matplotlib image

Raises:

ValueError – If the size of x and y is not the same

sls_detector_tools.plot.interpolate_pixel(pixel, data, pixelmask)[source]

Return the interpolated value in pixel.

Parameters:
  • pixel (int, int) – Index of the pixel to interpolate
  • data (numpy_array) – The image to use for interpolation
  • pixelmask (numpy_array(bool)) – True for pixels that should be skipped.
  • Returns
  • value (double) – The value of the interpolated pixel
sls_detector_tools.plot.plot_pixel_fit(x, y, par, px, figure=None)[source]

Plot the fit of a single pixel, given parameters and values

sls_detector_tools.plot.plot_signals(data)[source]

Plot a set of digital signals in one plot. Expects a named numpy array as input.

sls_detector_tools.plot.random_pixels(data, x, n_pixels=5, rows=(0, 512), cols=(0, 1024))[source]

Plot data from random pixels

Parameters:
  • data (numpy_array[row, col, n]) – Detector data
  • n_pixels (int, optional) – Number of pixels to plot. Defaults to 5
  • rows (tuple) – Sets max and min row
  • cols (tuple) – Sets max and min row
sls_detector_tools.plot.setup_plot()[source]

Setup seaborn and matplotlib for nice plots. This function uses sns.set() then sets style to: talk and font scale 1.2 for better readability.