reborn.viewers.qtviews package¶
Subpackages¶
- reborn.viewers.qtviews.padview_widgets package
- Submodules
- reborn.viewers.qtviews.padview_widgets.display_editor module
Widget
Widget.fix_current_levels
Widget.upper_fixed_checkbox_action
Widget.upper_fixed_spinbox_action
Widget.upper_percentile_checkbox_action
Widget.upper_percentile_spinbox_action
Widget.lower_fixed_checkbox_action
Widget.lower_fixed_spinbox_action
Widget.lower_percentile_checkbox_action
Widget.lower_percentile_spinbox_action
Widget.mirror_checkbox_action
Widget.ignore_masked_checkbox_action
- reborn.viewers.qtviews.padview_widgets.display_options module
- reborn.viewers.qtviews.padview_widgets.edit_beam module
- reborn.viewers.qtviews.padview_widgets.edit_geometry module
- reborn.viewers.qtviews.padview_widgets.frame_navigator module
- reborn.viewers.qtviews.padview_widgets.mask_editor module
- reborn.viewers.qtviews.padview_widgets.misc module
- reborn.viewers.qtviews.padview_widgets.ring_editor module
- reborn.viewers.qtviews.padview_widgets.run_stats module
- reborn.viewers.qtviews.padview_widgets.swaxs_simulator module
- Module contents
Submodules¶
reborn.viewers.qtviews.padviews module¶
- class reborn.viewers.qtviews.padviews.PADViewMainWindow(main=True)[source]¶
Bases:
QMainWindow
A QMainWindow that closes all windows when it is closed. Be careful…
- class reborn.viewers.qtviews.padviews.PADView(frame_getter=None, data=None, pad_geometry=None, mask=None, beam=None, levels=None, percentiles=None, debug_level=0, main=True, dataframe_preprocessor=None, title=None, **kwargs)[source]¶
Bases:
QObject
This is supposed to be an easy way to view PAD data. It is a work in progress… but here is the basic concept:
PADView
relies on aFrameGetter
subclass to serve upDataFrame
instances.- Parameters:
frame_getter (
FrameGetter
subclass) – The preferred way to flip through many frames.pad_geometry (
PADGeometryList
) – PAD geometry information.mask (
ndarray
) – Data masks.beam (
Beam
) – X-ray beam parameters.levels (tuple) – The minimum and maximum levels for the colormap.
percentiles (tuple) – The minimum and maximum percentages for the colormap.
debug_level (int) – The debug level. Larger values are more verbose.
main (bool) – Set to False if you don’t want this window to close all other windows when it is closed.
hold_levels (bool) – If True, do not attempt to re-scale the colormap for each frame.
dataframe_preprocessor (function) – Upon updating the
DataFrame
instance, apply this function. Must return aDataFrame
instance.
- show_histogram = True¶
- downsample_function = None¶
- hold_pad_geometry = True¶
- hold_beam = True¶
- hold_mask = True¶
- hold_levels = False¶
- skip_empty_frames = True¶
- sig_geometry_changed¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- sig_beam_changed¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- sig_dataframe_changed¶
int = …, arguments: Sequence = …) -> PYQT_SIGNAL
types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.
- Type:
pyqtSignal(*types, name
- Type:
str = …, revision
- debug(msg='', level=1)[source]¶
Add debug message to the reborn logger. For historical reasons, the PADView debug levels are:
1: Ordinary debug message (e.g. change mask).
2: Verbose debug message (e.g. PAD ImageItem transformations).
3: Very verbose debug (e.g. mouse movement).
These levels differ from standard Python logging debug level. The above values map to Python logging as follows:
1: logging.DEBUG = 10
2: logging.DEBUG - 2 = 8
3: logging.DEBUG - 4 = 6
- get_pad_geometry() PADGeometryList [source]¶
Return the currently displayed
PADGeometryList
- set_shortcut(key_sequence, function, allow_auto_repeat=False)[source]¶
Setup one keyboard shortcut so it connects to some function, assuming no arguments are needed.
- set_colormap(preset=None)[source]¶
Change the colormap to one of the presets configured in pyqtgraph. Right-click on the colorbar to find out what values are allowed.
- set_levels(levels=None, percentiles=None, colormap=None)[source]¶
This method handles setting levels (i.e. mapping the upper and lower bounds of detector pixel values to the span of the color table).
If no arguments are provided, the default settings are used.
Level setting is a somewhat complicated matter. For both the upper and lower bounds, there are 5 ways that we presently set the levels of the display data. In order of priority, highest first:
Set the level to the particular value specified in the levels keyword argument of this method.
Set the level to the value corresponding to the Nth percentile of the current display data, using the percentiles keyword argument.
Leave the levels alone; keep the previous levels.
An additional option is to mirror the levels: i.e. set the levels to range from [-x, +x]. This is controlled via the “mirror_levels” attribute.
When determining levels from percentiles, it is possible to ignore masked pixels. This is controlled by the attribute “levels_ignore_masked”.
- update_masks(masks=None)[source]¶
Update the mask that is displayed.
Note
As a side effect, the current dataframe will be updated with the provided mask
- update_pads()[source]¶
Update only the PAD data that is displayed, including colormap. Usually you should run update_display, which will trigger this method at the appropriate time.
- update_pad_geometry(pad_geometry=None)[source]¶
Use this when you want the display to reflect a change in the geometry. Applies Qt transforms to the PAD ImageItems. Also emits the sig_geometry_changed signal.
If you are changing an entire dataframe, use the update_display method instead as it will catch geometry changes according to the geometry policy.
- Parameters:
pad_geometry (
PADGeometryList
) – PAD Geometry. If None, get the geometry from the current dataframe.
- update_beam(beam=None)[source]¶
Use this when you want the display to reflect a change in the beam properties. Affects e.g. the q values shown in the statusbar. Also emits the sig_beam_changed signal.
If you are changing an entire dataframe, use the update_display method instead as it will catch beam changes according to the beam policy.
- Parameters:
beam (
Beam
) – Beam info. If None, get the beam from the current dataframe.
- update_dataframe(dataframe, _run_preprocessor=False)[source]¶
Change the dataframe. If need be, this will trigger calls to the update_beam method, the update_pad_geometry method, and the update_mask method.
- update_display(dataframe=None, data_changed=True, beam_changed=True, geom_changed=True, mask_changed=True)[source]¶
Update display, e.g. when moving to next frame. The PAD data will always be updated, and will reflect the data in the current
DataFrame
unless it is explicitly provided in the method call. TheBeam
,PADGeometryList
, and mask will be updated but optionally these updates may be skipped using the relevant options.Side effects: self.dataframe might be modified, if a
DataFrame
is provided. When updating- Parameters:
dataframe (
DataFrame
) – Optional input dataframe. Will use self.dataframe otherwise.
- static vector_to_view_coords(vec)[source]¶
If you have a vector (or vectors) pointing in some direction in space, this function provides the point at which it intercepts with the view plane (the plane that is 1 meter away from the origin).
- get_pad_coords_from_view_coords(view_coords)[source]¶
Get PAD coordinates (slow-scan index, fast-scan index, PAD index) from view coordinates. The view coordinates correspond to the plane that is 1 meter away from the origin.
- get_pad_coords_from_mouse_pos()[source]¶
Maps mouse cursor position to view coordinates, then maps the view coords to PAD coordinates.
- get_view_coords_from_mouse_pos()[source]¶
Map the current mouse cursor position to the display plane situated 1 meter from the interaction point.
- get_view_bounding_rect()[source]¶
Bounding rectangle of everything presently visible, in view (i.e real-space, 1-meter plane) coordinates.
- mouse_moved(evt)[source]¶
Updates the status string with info about mouse position (e.g. data value under cursor).
- add_plot_item(*args, **kargs)[source]¶
Example: self.add_plot_item(x, y, pen=pg.mkPen(width=3, color=’g’))
- load_pickled_dataframe(file_name)[source]¶
Load data in pickle format. Should be a dictionary with keys:
mask_data, pad_display_data, beam, pad_geometry
- save_pickled_dataframe(file_name)[source]¶
Save dataframe in pickle format. It is a dictionary with the keys:
mask_data, pad_display_data, beam, pad_geometry
- load_npy_file(file_name)[source]¶
Load data in numpy (npy) format. Note that this format only contains the diffraction intensity data; there is no geometry or beam information.
- save_npy_file(file_name)[source]¶
Save data in numpy (npy) format. Note that this format only contains the diffraction intensity data; there is no geometry or beam information.
- vector_coords_to_2d_display_coords(vecs)[source]¶
Convert 3D vector coords to the equivalent coords in the 2D display plane. This corresponds to ignoring the “z” coordinate, and scaling the “x,y” coordinates to that of an equivalent detector located at a distance of 1 meter from the origin. Simply put: remove the z component, divide the x,y components by the z component
- panel_scatter_plot(panel_number, ss_coords, fs_coords, style=None)[source]¶
Scatter plot points given coordinates (i.e. indices) corresponding to a particular panel. This will take care of the re-mapping to the display coordinates.
- property display_editor_widget¶
- property mask_editor_widget¶
- property ring_editor_widget¶
- property runstats_widget¶
- property display_options_widget¶
- property edit_geometry_widget¶
- property swaxs_simulator_widget¶
- property beam_editor_widget¶
- reborn.viewers.qtviews.padviews.view_pad_data(data=None, pad_geometry=None, show=True, title=None, **kwargs)[source]¶
Convenience function that creates a PADView instance and starts it.
- class reborn.viewers.qtviews.padviews.DummyFrameGetter(*args, **kwargs)[source]¶
Bases:
FrameGetter
Makes a FrameGetter for a single DataFrame.
Ideally, a
DataFrame
instance is provided, which hasPADGeometry
,Beam
, etc. information.Alternatively, data can be provided as a single
ndarray
, as a list ofndarray
, or, for legacy purposes, as a dictionary with the ‘pad_data’ key in it. If so, then you should at least provide thePADGeometry
andBeam
information, else some garbage numbers will be created for you.- Parameters:
dataframe
data
pad_geometry
reborn.viewers.qtviews.qtviews module¶
- reborn.viewers.qtviews.qtviews.pens = [<PyQt5.QtGui.QPen object>, <PyQt5.QtGui.QPen object>, <PyQt5.QtGui.QPen object>, <PyQt5.QtGui.QPen object>, <PyQt5.QtGui.QPen object>, <PyQt5.QtGui.QPen object>, <PyQt5.QtGui.QPen object>, <PyQt5.QtGui.QPen object>]¶
This is supposed to have various viewers that use pyqtgraph. It’s mostly useless right now.
- reborn.viewers.qtviews.qtviews.bright_colors(i, alpha=1)[source]¶
Some nice colors. Only 8 available, which loops around as the input index increments.
- reborn.viewers.qtviews.qtviews.plot_multiple_images(images, title=None, n_rows=None, hold=True, kill=True)[source]¶
- reborn.viewers.qtviews.qtviews.MapProjection(data, axis=None, hold=True, kill=True, title=None)[source]¶
View a 3D density map as a projection along selected axes (which can be a list)
- reborn.viewers.qtviews.qtviews.MapSlices(data, axis=None, levels=None, hold=True, kill=True, title=None)[source]¶
View a 3D density map as a projection along selected axes (which can be a list)
- class reborn.viewers.qtviews.qtviews.Scatter3D(title=None)[source]¶
Bases:
object
Simple viewer for 3D scatter plots.
- app = None¶