The widgets.silx_plot sub-package#

Package with subclassed silx widgets and actions.

class pydidas.widgets.silx_plot.AutoscaleToMeanAndThreeSigma(plot: PydidasPlot2d, **kwargs: dict)#

Bases: PlotAction

A new custom PlotAction to set the colormap to autoscale with mean +/- 3 sigma.

Parameters:
  • plot (silx.gui.plot.PlotWidget) – The associated plot widget.

  • **kwargs

    Supported keyword arguments are:

    parentUnion[None, QObject], optional

    The parent QObject. The default is None.

    forced_image_legendUnion[None, str], optional

    A fixed image legend to use for enforcing the rescaling, if multiple image items are in a plot. None defaults to the active image. The default is None.

class pydidas.widgets.silx_plot.ChangeCanvasToData(plot: PydidasPlot2d, **kwargs: dict)#

Bases: PlotAction

A customized silx Action to change the size of the figure canvas to the data dimensions.

class pydidas.widgets.silx_plot.CropHistogramOutliers(plot: PydidasPlot2d, **kwargs: dict)#

Bases: PlotAction, PydidasQsettingsMixin

A new custom PlotAction to crop outliers from the histogram.

This action will use the global ‘histogram_outlier_fraction’ QSettings value to determine where to limit the histogram and pick the respective value as new upper limit.

The resolution for the upper limit is 27 bit, implemented in two tiers of 12 bit and 15 bit, respective to the full range of the image. For an Eiger detector, this corresponds to minimal final bins of 32 counts.

The lower limit is implemented in two tiers of 12 bit.

Parameters:
  • plot (silx.gui.plot.PlotWidget) – The associated plot widget.

  • **kwargs

    Supported keyword arguments are:

    parentUnion[None, QObject], optional

    The parent QObject. The default is None.

    forced_image_legendUnion[None, str], optional

    A fixed image legend to use for enforcing the rescaling, if multiple image items are in a plot. None defaults to the active image. The default is None.

class pydidas.widgets.silx_plot.ExpandCanvas(plot: PydidasPlot2d, **kwargs: dict)#

Bases: PlotAction

A modified silx ResetZoomAction which also resets the figure canvas to the maximum size allowed by the widget.

class pydidas.widgets.silx_plot.PydidasGetDataInfoAction(plot: PydidasPlot2d, **kwargs: dict)#

Bases: PlotAction

Action to select a datapoint and show more information about this datapoint.

class pydidas.widgets.silx_plot.PydidasLoadImageAction(parent, caption='Select image file', ref=None)#

Bases: QAction

Action to load an image using the pydidas file dialog.

This action is used as additional option in the pyFAI calibration widgets.

Parameters:
  • caption (str, optional) – The caption string for the file dialog. The default is ‘Select image file.’

  • ref (str, optional) – The reference for a persistent QSettings reference to the directory. The default is None.

class pydidas.widgets.silx_plot.PydidasMaskToolsWidget(parent: None | QWidget = None, plot: None | QWidget = None, **kwargs: dict)#

Bases: MaskToolsWidget

A customized silx.gui.plot.MaskToolsWidget with larger buttons.

class pydidas.widgets.silx_plot.PydidasPlot1D(**kwargs: dict)#

Bases: Plot1D

A customized silx.gui.plot.Plot1D with an additional configuration.

clear_plot(clear_data: bool = True)#

Clear the plot and remove all items.

Parameters:

clear_data (bool, optional) – Flag to remove all items from the stored data dictionary as well.

plot_pydidas_dataset(data: Dataset, **kwargs: dict)#

Plot a pydidas dataset.

Parameters:
  • data (pydidas.core.Dataset) – The data to be plotted.

  • **kwargs (dict) – Additional keyword arguments to be passed to the silx plot method.

update_mpl_fonts()#

Update the plot’s fonts.

class pydidas.widgets.silx_plot.PydidasPlot2D(**kwargs: dict)#

Bases: Plot2D, PydidasQsettingsMixin

A customized silx.gui.plot.Plot2D with an additional features.

Additional features are implemented through additional SilxActions which are added to the toolbar.

addImage(data: Dataset | ndarray, **kwargs: dict)#

Add an image to the plot.

This method implements an additional dimensionality check before passing the image to the Plot2d.addImage method.

Parameters:
  • data (Union[Dataset, np.ndarray]) – The input data to be displayed.

  • **kwargs (dict) – Any supported Plot2d.addImage keyword arguments.

addNonUniformImage(data: Dataset, **kwargs: dict)#

Add a non-uniform image to the plot.

This method implements an additional dimensionality check before passing the image to the Plot2d.addImage method.

Parameters:
  • data (Dataset) – The input data to be displayed.

  • **kwargs (dict) – Any supported Plot2d.addImage keyword arguments.

clear_plot()#

Clear the plot and remove all items.

enable_cs_transform()#

Enable or disable the coordinate system transformations.

The CS transform is enabled if the image has the same shape as the detector configured in the DiffractionExperimentContext.

plot_pydidas_dataset(data: Dataset, **kwargs: dict)#

Plot a pydidas Dataset.

Parameters:
  • data (pydidas.core.Dataset) – The data to be plotted.

  • **kwargs (dict) – Additional keyword arguments to be passed to the silx plot method.

update_cs_units(x_unit: str, y_unit: str)#

Update the coordinate system units.

Note: Any changes to the CS transform will overwrite these settings.

Parameters:
  • x_unit (str) – The unit for the data x-axis.

  • y_unit (str) – The unit for the data y-axis

update_exp_setup_params()#

Check that the detector is valid for a CS transform.

update_mpl_fonts()#

Update the plot’s fonts.

user_config_update(key: str, value: str)#

Handle a user config update.

Parameters:
  • key (str) – The name of the updated key.

  • value – The new value of the updated key.

class pydidas.widgets.silx_plot.PydidasPlot2DwithIntegrationRegions(**kwargs: dict)#

Bases: PydidasPlot2D

An extended PydidasPlot2D which allows to show integration regions.

draw_circle(radius: float, legend: str, center: None | Tuple[float, float] = None)#

Draw a circle with the given radius and store it as the given legend.

Parameters:
  • radius (float) – The circle radius in pixels.

  • legend (str) – The shape’s legend for referencing it in the plot.

  • center (Union[None, Tuple[float, float]], optional) – The center of the circle. If None, this defaults to the DiffractionExperiment beamcenter. The default is None.

draw_integration_region(radial: None | Tuple[float, float], azimuthal: None | Tuple[float, float])#

Draw the given integration region.

Parameters:
  • radial (Union[None, Tuple[float, float]]) – The radial integration region. Use None for the full detector or a tuple with (r_inner, r_outer) in pixels to select a region.

  • azimuthal (Union[None, Tuple[float, float]]) – The azimuthal integration region. Use None for the full detector or a tuple with (azi_start, azi_end) in radians for a region.

draw_line_from_beamcenter(chi: float, legend: str)#

Draw a line from the beamcenter in the direction given by the angle chi.

Parameters:
  • chi (float) – The pointing angle, given in rad.

  • legend (str) – The reference legend entry for this line.

set_marker_color(color: str)#

Set the new marker color.

Parameters:

color (str) – The marker color name.

class pydidas.widgets.silx_plot.PydidasPlotStack(**kwargs: dict)#

Bases: QStackedWidget

A stack with two plots for 1d and 2d data which selects the correct to display.

Parameters:

**kwargs (dict) –

Supported keyword arguments are:

parentUnion[QtWidgets.QWidget, None]

The parent widget.

use_data_info_actionbool, optional

Flag to use the PydidasGetDataInfoAction to display information about a result datapoint. The default is False.

diffraction_expDiffractionExperiment, optional

The DiffractionExperiment instance to be used in the PydidasPlot2D for the coordinate system. The default is the generic DiffractionExperimentContext.

cs_transformbool, optional

Flag to enable coordinate system transformations.

clear_plots()#

Clear all plots.

plot_data(data: Dataset, **kwargs: dict)#

Plot the given data.

Parameters:
  • data (pydidas.core.Dataset) – The data to be plotted.

  • **kwargs (dict) – Any additional keywords to be passed to the plot.

pydidas.widgets.silx_plot.get_2d_silx_plot_ax_settings(data: Dataset) tuple[float, float]#

Get the axis settings to have pixels centered at their values.

Parameters:

data (Dataset) – The dataset to get the axis settings from.

Returns:

  • origins (tuple[float, float]) – The values for the axis origins.

  • scales (tuple[float, float]) – The values for the axis scales to squeeze it into the correct dimensions for silx plotting.

pydidas.widgets.silx_plot.user_config_update_func(self, key: str, value: str)#

Handle a user config update.

Parameters:
  • key (str) – The name of the updated key.

  • value – The new value of the updated key.