image_panels.py
Module implementing plots and interactive elements of the DataViewers.
- class image_panels.Sliders[source]
Object defining draggable lines allowing user to choose exact position of a slice.
- __init__(image_plot, pos=(0, 0), mainplot=True, orientation='horizontal')[source]
Initialize two draggable sliders.
- Parameters:
image_plot (ImagePlot) –
ImagePloton which sliders are displayedpos (Iterable) – initial position of the sliders
mainplot (bool) – if
Trueregister signals for both sliders. Different behavior is expected forImagePlots being horizontal and vertical cutsorientation (str) –
relative orientation of the image, when vertical the actual orientation of sliders is flipped. Default is horizontal.
Note
Actually, it’s easier to define sliders in coordinate system of the data, where horizontal always corresponds to slicing along momentum.
- Return type:
None
- add_to(widget)[source]
Add these sliders to a
pyqtgraphwidget.- Parameters:
widget (Any) – widget to which sliders are added
- Return type:
None
- remove_from(widget)[source]
Remove these sliders from a
pyqtgraphwidget.- Parameters:
widget (Any) – widget to which sliders are removed
- Return type:
None
- set_color(linecolor=(255, 255, 0, 255), hover_color=(195, 155, 0, 255))[source]
Set the color and hover color of both sliders that make up. The arguments can be any
pyqtgraphcompatible color specifiers.
- on_dragged_h()[source]
Callback for dragging horizontal slider changing value of the connected
CustomTracedVariable.
- on_dragged_v()[source]
Callback for dragging vertical slider changing value of the connected
CustomTracedVariable.- Return type:
None
- class image_panels.ImagePlot[source]
Object displaying 2D color-scaled data using different colormaps. It treats data as a regular rectangular images, which allows for time efficient slicing and updating displayed cuts. Inherits from
pyqtgraph.PlotWidgetwhich gives access to additional plotty features like displaying custom scales instead of just pixels.- __init__(image=None, background=(64, 64, 64), name=None, mainplot=True, orientation='horizontal', **kwargs)[source]
Initialize color-scaled plot.
- Parameters:
image (ndarray | None) – 2D array with data
background (Any) – color of the background, can be any pyqtgraph compatible color specifier
mainplot (bool) – specifies behavior of the draggable sliders. See
Slidersfor more detailsorientation (str) – orientation of the image. Default is ‘horizontal’
kwargs (dict) – kwargs passed to parent
pg.PlotWidgetname (str | None)
- Return type:
None
- update_allowed_values()[source]
Update the allowed values of the sliders. This assumes that the displayed image is in pixel coordinates and sets the allowed values to the available pixels.
- Return type:
None
- set_bounds(xmin, xmax, ymin, ymax)[source]
Set both, the displayed area of the axes and the range in which sliders can be dragged.
- set_image(image, emit=True, *args, **kwargs)[source]
Set/update displayed image. Also make sure the old one has been removed.
- set_xscale(scale)[source]
Set custom values of the
xscale.- Parameters:
scale (ndarray) – 1D array with axis values
- Return type:
None
- set_yscale(scale)[source]
Set custom values of the
yscale.- Parameters:
scale (ndarray) – 1D array with axis values
- Return type:
None
- set_ticks(min_val, max_val, axis)[source]
Set customized axis’ ticks to reflect the dimensions of the physical data.
- get_limits()[source]
Get limits of the image data.
- Returns:
list of lists in a format: [[x_min, x_max], [y_min, y_max]]
- Return type:
- fix_viewrange()[source]
Prevent zooming out by fixing the limits of the
QViewBox.- Return type:
None
- add_binning_lines(pos, width, orientation='horizontal')[source]
Add not-movable lines around the specified sliders. The lines indicate integration area for a corresponding cut.
- remove_binning_lines(orientation='horizontal')[source]
Remove binning lines from the
ImagePlot.- Parameters:
orientation (str) – orientation of the slider
- Return type:
None
- register_momentum_slider(traced_variable)[source]
Register vertical slider draggable along momentum in the cut plots.
- Parameters:
traced_variable (TracedVariable) – connected traced variable
- Return type:
None
- set_position()[source]
Set the position of the momentum sliders whenever the value of connected
CustomTracedVariablehas changed.- Return type:
None
- on_allowed_values_change()[source]
Set new momentum slider bounds after changing allowed values of the connected
CustomTracedVariable, e.g. after setting binning lines.- Return type:
None
- class image_panels.CurvePlot[source]
Object displaying basic 1D curves with a draggable slider.
- __init__(background=(64, 64, 64), name=None, orientation='horizontal', slider_width=1, z_plot=False, **kwargs)[source]
Initialize simple 1D plot panel.
- Parameters:
background (Any) – color of the background, can be any pyqtgraph compatible color specifier
orientation (str) – orientation of the plot. Default is ‘horizontal’
slider_width (int) – width of the draggable slider
z_plot (bool) – if
True, plot is a main energy plot of theDataViewer3DGUIkwargs (dict) – kwargs passed to parent
PlotWidgetname (str | None)
- Return type:
None
- get_data()[source]
Get the currently displayed data as a tuple of arrays.
- Returns:
(x_data, y_data)
- Return type:
- register_traced_variable(traced_variable)[source]
Register
CustomTracedVariableconnected to the slider.- Parameters:
traced_variable (TracedVariable)
- Return type:
None
- on_position_change()[source]
Callback for dragging slider changing value of the connected
CustomTracedVariable.- Return type:
None
- on_allowed_values_change()[source]
Set new momentum slider bounds after changing allowed values of the connected
CustomTracedVariable, e.g. after setting binning lines.- Return type:
None
- set_position()[source]
Set the position of the sliders whenever the value of connected
CustomTracedVariablehas changed.- Return type:
None
- add_binning_lines(pos, width)[source]
Add not-movable lines around the specified sliders. The lines indicate integration area for a corresponding cut.
- set_bounds(lower, upper)[source]
Set both, the displayed area of the axes and the range in which sliders can be dragged.
- set_ticks(min_val, max_val, axis)[source]
Set customized axis’ ticks to reflect the dimensions of the physical data.