histogram

class pdsspect.histogram.HistogramModel(image_view, cut_low=None, cut_high=None, bins=100)[source]

Bases: object

Model for a Histogram which can apply cut levels to an image

Any View that utilizes this model must define the following methods: set_data, change_cut_low, change_cut_high, change_cuts, warn, and change_bins. The warn method must return a boolean and if more than one view utilizes this model, you should consider only one actually creating a warning box and return True while the others just return False.

Parameters:
  • image_view (ImageViewCanvas) – The image view canvas
  • cut_low (float) – The lower cut level
  • cut_high (float) – The higher cut level
  • bins (int) – The number of bins the histogram uses
bins

int The number of bins the histogram uses

Setting the bins will notify the views that the bins have changed

cut_high

float The higher cut level

Setting the high cut value will adjust the cut values in the image view and notify the views that the high cut value changed.

cut_low

float The lower cut level

Setting the low cut value will adjust the cut values in the image view and notify the views that the low cut value changed

cuts

tuple The lower and higher cut levels.

Setting the cuts will adjust the cut levels in the image viewer and notify the views that the cuts have changed. The low cut must be less than the high cut, otherwise they will be switched to satisfy that condition.

data

ndarray The current image data

image_view

ImageViewCanvas The image view canvas

Setting the image view will reset the data

register(view)[source]

Register a view with the model

Parameters:view (QtWidgets.QWidget) – A view that utilizes this model
restore()[source]

Restore the cut levels

set_data()[source]

Set the data the histogram is to display

unregister(view)[source]

Unregister a view with the model

Parameters:view (QtWidgets.QWidget) – A view that utilizes this model
view_cuts

tuple The image_view cut levels

warn(title, message)[source]

Display a warning box

Each view must define a warn method that returns a boolean value: True when a warning box is displayed and False when a warning box not displayed. Only one display box will be displayed. This is because multiple views should not have different handling for the same errors.

class pdsspect.histogram.HistogramController(model, view)[source]

Bases: object

Controller for histogram views

Parameters:
model

HistogramModel – histogram model

view

object – View with HistogramModel as its model

restore()[source]

Restore the histogram

set_bins(bins)[source]

Change the number of bins the histogram uses

Parameters:bins (int) – The number number of bins for the histogram
set_cut_high(cut_high)[source]

Set the high cut level to a new value

Parameters:cut_high (float) – New high cut value
set_cut_low(cut_low)[source]

Set the low cut level to a new value

Parameters:cut_low (float) – New low cut value
set_cuts(cut_low, cut_high)[source]

Set both the low and high cut levels

Parameters:
  • cut_low (float) – New low cut value
  • cut_high (float) – New high cut value
class pdsspect.histogram.HistogramWidget(model, parent=None)[source]

Bases: PyQt5.QtWidgets.QWidget

View to display the histogram with text boxes for cuts and bins

Parameters:model (HistogramModel) – The view’s model
model

HistogramModel – The view’s model

controller

HistogramController – The view’s controller

histogram

Histogram – The histogram itself

change_bins()[source]

Change the bins box text

change_cut_high()[source]

Set the high cut box text

change_cut_low()[source]

Set the low cut box text

change_cuts()[source]

Set the low and high cut boxes’ text

keyPressEvent(event)[source]

When the enter button is pressed, adjust the cut levels and bins

warn(title, message)[source]

Displayed a timed message box the warning

class pdsspect.histogram.Histogram(model)[source]

Bases: matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg

The Histogram View

Parameters:model (HistogramModel) – The view’s model
model

HistogramModel – The view’s model

controller

HistogramController – The view’s controller

change_bins()[source]

Adjust the number of bins without adjusting the lines

change_cut_high(draw=True)[source]

Change the position of the right line to the high cut level

change_cut_low(draw=True)[source]

Change the position of the left line to the low cut level

change_cuts()[source]

Change the position of the left & right lines to respective cuts

set_data(reset_vlines=True)[source]

Set the histogram’s data

Parameters:reset_vlines (bool) – Reset the vertical lines to the default cut levels if True, otherwise False. True by default