hdfviewer.viewers package

Submodules

hdfviewer.viewers.MplDataViewer module

MatPlotLib viewer for NumPy 1D, 2D and 3D NumPy data.

class hdfviewer.viewers.MplDataViewer.MplDataViewer(dataset, standAlone=True)

Bases: object

This class allows to display 1D,2D or 3D NumPy array in a matplotlib.figure.Figure

Depending on the dimensionality of the dataset the display will consist in:

  • 1D: simple MatPlotLib 1D plot
  • 2D: matrix view of the dataset
  • 3D: matrix view of the dataset

In case of 2D and 3D datasets, the matrix view is made of a 2D image of the selected frame of the dataset (always 0 for 2D datasets) with a 1D column-projection view of the dataset on its top and a 1D row-projection view of the dataset on its right. The matrix view is interactive with the following interactions:

  • 2D:
    • toggle between cross and integration 1D potting mode. In cross plot mode, the 1D projection views represents resp. the row and column of the matrix image point left-clicked by the user. In integration plot mode, the 1D projection views represents the sum over resp. the row and column of the image. To switch between those two modes, press the i key.
  • 3D:
    • toggle between cross and integration 1D potting mode. See above.
    • go to the last frame by pressing the pgdn key.
    • go to the first frame by pressing the pgup key.
    • go to the next frame by pressing the down or the right keys or wheeling down the mouse wheel
    • go to the previous frame by pressing the up or the left keys or wheeling up the mouse down
    • go the +n (n can be > 9) frame by pressing n number followed by the down or the right keys
    • go the -n (n can be > 9) frame by pressing n number followed by the up or the left keys
Example
 import numpy as np
 import matplotlib.pyplot as plt

 dataset = np.random.uniform(0,1,(100,400,30))

 d = MplDataViewer(dataset)
Parameters:
  • dataset (numpy.ndarray) –

    the NumPy array to be displayed

    The dataset will be squeezed from any dimensions equal to 1

  • standAlone (bool) – if True a cursor will be displayed when hovering over the 2D view of the dataset (only for 2D or 3D datasets)
Raises:

MplDataViewerError: if the (squeezed) dataset has a dimension different from 1, 2 or 3

viewer

Getter for the dimension specific viewer.

Returns:the dimension specific viewer
Return type:_MplDataViewer1D or _MplDataViewer2D or _MplDataViewer3D
exception hdfviewer.viewers.MplDataViewer.MplDataViewerError

Bases: Exception

MplDataViewer specific exception

hdfviewer.viewers.MplDataViewer1D module

MatPlotLib viewer for NumPy 1D NumPy data.

class hdfviewer.viewers.MplDataViewer1D._MplDataViewer1D(dataset, **kwargs)

Bases: object

This class allows to display 1D NumPy array in a matplotlib.figure.Figure

This will be a simple matplotlib plot.

Parameters:
  • dataset (numpy.ndarray) –

    the NumPy array to be displayed

    The dataset will be squeezed from any dimensions equal to 1

  • kwargs (dict) – the keyword arguments
_initLayout()

Initializes the figure layout.

dataset

Getter/setter for the dataset to be displayed.

Getter:returns the dataset to be displayed
Setter:sets the dataset to be displayed
Type:numpy.ndarray
figure

Getter for the figure to be displayed.

Returns:returns the figure to be displayed in the jupyter output widget
Return type:matplotlib.figure.Figure
update()

Update the figure.

hdfviewer.viewers.MplDataViewer2D module

MatPlotLib based viewer for 2D NumPy data.

class hdfviewer.viewers.MplDataViewer2D._MplDataViewer2D(dataset, standAlone=True)

Bases: object

This class allows to display 2D NumPy array in a matplotlib.figure.Figure

The figure is made of an central image surrounded on top by the column-view of the dataset and on the right by a row-view of the dataset which depending on the plotting mode corresponds to:

  • slices along the row and column of a selected pixel using left-click mouse button when the cross-plot mode is set
  • integrations of the 2D image along the X and Y axis when the integration mode is set

The figure is interactive with the following interactions:

  • toggle between cross and integration 1D potting mode. In cross plot mode, the 1D projection views represents resp. the row and column of the matrix image point left-clicked by the user. In integration plot mode, the 1D projection views represents the sum over resp. the row and column of the image. To switch between those two modes, press the i key.
Parameters:
  • dataset (numpy.ndarray) –

    the NumPy array to be displayed

    The dataset will be squeezed from any dimensions equal to 1

  • standAlone (bool) – if True a cursor will be displayed when hovering over the 2D view of the dataset
_initActions()

Setup all the actions and their corresponding callbacks.

_initLayout()

Initializes the figure layout.

_onChangeAxesLimits(event)

Callback called when the axis of the matrix view have changed.

This will update the cross plot according to the reduced row and/or column range.

Parameters:event (matplotlib.axes.SubplotBase) – the axes whose axis have been changed
_onKeyPress(event)

Callback called when a keyboard key is pressed.

Parameters:event (matplotlib.backend_bases.KeyEvent) – the keyboard keypress event
_onSelectPixel(event)

Callback called when a mouse buttton is clicked.

Parameters:event (matplotlib.backend_bases.MouseEvent) – the mouse click event
_updateCrossPlot()

Update the cross plots.

dataset

Getter/setter for the dataset to be displayed.

Getter:returns the dataset to be displayed
Setter:sets the dataset to be displayed
Type:numpy.ndarray
figure

Getter for the figure to be displayed.

Returns:returns the figure to be displayed in the jupyter output widget
Return type:matplotlib.figure.Figure
selectPixel(row, col)

Select a pixel on the image.

This will update the croos plots.

Parameters:
  • row – the pixel row
  • row – the pixel column
setXYIntegrationMode(xyIntegration)

Switch between slice plot mode and integration mode.

Parameters:xyIntegration (bool) – if True, the croos plots will be resp. the integral over y and x axis otherwise the cross plots will be resp. slices along the selected pixel
update()

Update the figure.

hdfviewer.viewers.MplDataViewer3D module

MatPlotLib based viewer for 2D NumPy data.

class hdfviewer.viewers.MplDataViewer3D._MplDataViewer3D(dataset, standAlone=True)

Bases: object

This class allows to display 3D NumPy array in a matplotlib.figure.Figure

The figure is made of an central image surrounded on top by the column-view of the dataset and on the right by a row-view of the dataset which depending on the plotting mode corresponds to:

  • slices along the row and column of a selected pixel using left-click mouse button when the cross-plot mode is set
  • integrations of the 2D image along the X and Y axis when the integration mode is set

The figure is interactive with the following interactions:

  • toggle between cross and integration 1D potting mode. In cross plot mode, the 1D projection views represents resp. the row and column of the matrix image point left-clicked by the user. In integration plot mode, the 1D projection views represents the sum over resp. the row and column of the image. To switch between those two modes, press the i key.
  • toggle between cross and integration 1D potting mode. See above.
  • go to the last frame by pressing the pgdn key.
  • go to the first frame by pressing the pgup key.
  • go to the next frame by pressing the down or the right keys or wheeling down the mouse wheel
  • go to the previous frame by pressing the up or the left keys or wheeling up the mouse down
  • go the +n (n can be > 9) frame by pressing n number followed by the down or the right keys
  • go the -n (n can be > 9) frame by pressing n number followed by the up or the left keys
Parameters:
  • dataset (numpy.ndarray) –

    the NumPy array to be displayed

    The dataset will be squeezed from any dimensions equal to 1

  • standAlone (bool) – if True a cursor will be displayed when hovering over the 2D view of the dataset
_initActions()

Setup all the actions and their corresponding callbacks.

_initLayout()

Initializes the figure layout.

_onChangeAxesLimits(event)

Callback called when the axis of the matrix view have changed.

This will update the cross plot according to the reduced row and/or column range.

Parameters:event (matplotlib.axes.SubplotBase) – the axes whose axis have been changed
_onKeyPress(event)

Callback called when a keyboard key is pressed.

Parameters:event (matplotlib.backend_bases.KeyEvent) – the keyboard keypress event
_onScrollFrame(event)

Callback called when the mouse wheel is rolled.

This will scroll to previous/next frame according to the mouse wheel direction.
Parameters:event (matplotlib.backend_bases.MouseEvent) – the mouse wheel event event
_onSelectPixel(event)

Callback called when a mouse buttton is clicked.

Parameters:event (matplotlib.backend_bases.MouseEvent) – the mouse click event
_updateCrossPlot()

Update the cross plots.

dataset

Getter/setter for the dataset to be displayed.

Getter:returns the dataset to be displayed
Setter:sets the dataset to be displayed
Type:numpy.ndarray
figure

Getter for the figure to be displayed.

Returns:returns the figure to be displayed in the jupyter output widget
Return type:matplotlib.figure.Figure
selectPixel(row, col)

Select a pixel on the image.

This will update the croos plots.

Parameters:
  • row – the pixel row
  • row – the pixel column
setSelectedFrame(selectedFrame)

Set the frame to be displayed.

Parameters:selectedFrame (int) – the new frame to be displayed
setXYIntegrationMode(xyIntegration)

Switch between slice plot mode and integration mode.

Parameters:xyIntegration (bool) – if True, the croos plots will be resp. the integral over y and x axis otherwise the cross plots will be resp. slices along the selected pixel
update()

Update the figure.

Module contents