Welcome to pdsspect’s documentation!¶
pdsspect - A Python PDS Image Region of Interest Selection Tool¶
NOTE: This is Alpha quality software that is being actively developed, use at your own risk. This software is not produced by NASA.
- Free software: BSD license
- Documentation: https://pdsspect.readthedocs.org.
Features¶
- NASA PDS Image Viewer
NOTE: This is alpha quality software. It lacks many features and lacks support for many PDS image types. This software is not produced by NASA.
Install¶
On OS X you must first install the Qt UI toolkit using Homebrew (http://brew.sh/). After installing Homebrew, issue the following command:
brew install qt
Install Using Pip¶
Install pdsspect using pip:
pip install pdsspect
Then install your choice of pyside, pyqt4, or pyqt5
Install for Development¶
Create a new virtual environment, install the pdsspect module with git, and setup the PySide environment. You must install either PySide, PyQt5, or PyQt4 as well (recommend PyQt5):
Make a clone of ``pdsspect`` and change to main directory. We recommend
making a virtual environment for to install ``pdsspect`` in.
pip install -e .
pip install PyQt5
Now you should be able to run the pdsspect program.
This works on Linux as well (Ubuntu 14.04).
Quick Tutorial¶
Open an image in the command line:
pdsspect tests/mission_data/2m132591087cfd1800p2977m2f1.img
This will open the default window:



The bottom left window is considered the main window. In this window, the user
can adjust the position of the pan and open other windows. The bottom right
window is the basic
window. Pressing the basic
button will open this
window if closed. However, it starts out open. In this window, the user can
change the image in the views and adjust the cut levels by either moving the
red lines or typing in the numbers in the cut boxes:


The top window is the pan window
which displays the data in the main
window’s red box. The main function of this window is to make Region of
Interest (ROI) selections.
In the zoom
box in the main window, the user can change the size of the box
and the data in the pan view:


the mouse wheel can also be used to change the zoom. Rolling the wheel foward
and backwards will adjust the zoom amount by +1
or -1
respectively.
The user can adjust the position of the box by clicking in the main window
where the center of the pan should be. Using the arrow keys will also adjust
the position of the box by 1
in the direction of the arrow key.
Clicking the Add Window
button will open another view. This view will have
the same image, cut levels, and zoom by default.

If the image’s are the same, chaning the cut levels on one image will automatically change the cut levels on another image. However, one can change the zoom on one view without changing the zoom another view.



When the images are different, adjusting the cut levels on one image will only change the cut levels on that image:


The user can create separate ROIs in each view:

Clicking the Selection
button will open the Selections Window
:

In this window, the user can choose the color of the ROI. The possible choices
for colors: red
, brown
, lightblue
, lightcyan
, darkgreen
,
yellow
, pink
, teal
, goldenrod
, sienna
, darkblue
,
crimson
, maroon
, purple
, and eraser (black)
. The selection type
can be changed in this window as well. The possible types are filled
rectangle
, filled polygon
, and pencil
(single points).
Furthermore, in this window, the user can clear the current color or clear all
ROIs. Most importantly, the user can export ROIs to .npz
files. These files
contain boolean masks and of the images and a list of files open at the time
of export. The ROIs in the 2nd, 3rd, 4th, etc. views will be labeled as
color#view
while the ROIs in the first view is still labeled as color
.
For example, to see the data in an example file example.npz
, use numpy
load method
to view and utilize data.
>>> import numpy as np
>>> selections = np.load('example.npz')
>>> selections['red'][114:118, 142:146]
array([[ True, True, True, True],
[ True, True, True, True],
[ True, True, True, True],
[ True, True, True, True]], dtype=bool)
>>> selections['purple2'][48:52, 146:150]
array([[False, False, False, False],
[False, True, True, True],
[ True, True, True, True],
[ True, True, True, True]], dtype=bool)
The user can also import ROI selections. However the images that are open must
be in the files
list in the .npz
file.
Changing the opacity in the Selecitons window will change the opacity on all the ROIs in every view:


You can view the data within the ROIs with the ROI Histogram
window. Open
the window by pressing the ROI Histogram
button in the main viewer.

Display the data in the ROI by color by checking the checkbox next to the color. When the image in the menu and the current image in the checked view are the same, the plot will be a histogram:

When the menu and the current image are different, the plot will compare the data:

To view the data in the other view, check the view number:

Overlay ROIs by checking other boxes. The order (depth) of the histogram data will be in the order that the user checks the boxes (i.e., checking red and then purple will result in purple overlaying the red).
To perform multispectral analysis use ROI Line Plot
.
If analyzing images that are not fully supported (see here for list of
instruments supported by pdsspect) the user must
manually input the image wavelength with Set Wavelength
widget:

ROI Line Plot
works similar to that of the histogram plot except it will
compare each image with an associated wavelength.



The user can flip the image over different axis with the Transforms window. The transformation will apply to each image in all the views:



Note that when opening multiple images at the same time, it is best practice
that they are all the same shape. Otherwise the images will have the smallest
common shape and not look as expected (i.e., If when loading two images where
one image has a shape of (63, 36)
and the other image has a shape of
(24, 42)
, the displayed shape will be (24, 36)
. This will cause the
first image to have the right side cut off and the second image to have the
top cut off). This is done so all ROIs created can apply to the entire list
of images. To avoid this behavior, either only open images that have the same
shape or open images one at a time.
Supported Instruments¶
- MER
- Pancam
- MSL
- Mastcam
- Cassini
- Imaging Science Subsystem (ISS)
Adding More Instruments¶
We welcome anyone to create more models for instruments that are not yet supported. Please follow the Pull Request guide to make sure your model is compatible with the rest of the models. See Pull Request #20 as an example.
Pull Request Checklist¶
Please include the following checklist in your PR so we know you have completed each step:
- [ ] Created model as subclass of [InstrumentBase](https://github.com/planetarypy/pdsspect/blob/master/instrument_models/instrument.py#L7)
- [ ] Added model to [get_wavelength](https://github.com/planetarypy/pdsspect/blob/master/instrument_models/get_wavelength.py)
- [ ] Documented Model
- [ ] Tested Model
- [ ] Added model to [test_get_wavelength](https://github.com/planetarypy/pdsspect/blob/master/tests/test_get_wavelength.py) test
- [ ] Added instrument to supported_instruments.rst list
Style¶
- Set PR label to
Instrument Model
- If an issue was created, please include
Fixes #<issue_number>
at the top of the PR to automatically close the issue - Please include a link to any documents used to find the filter wavelength. Follow the example for Mastcam and/or Pancam
- When documenting your model, use numpy docs.See these examples. Also add to instrument_models.rst following the format of the other models
- For tests, if one of the core mission_data images is not from your instrument, create a minimal label in the tests\__init__.py. You must test the model itself and test that it works in test_get_wavelength
- Add the mission and instrument to the
supported_instruments.rst
file following the set format.
pdsspect¶
-
class
pdsspect.pdsspect.
PDSSpect
(image_set)[source]¶ Bases:
PyQt5.QtWidgets.QMainWindow
,pdsspect.pdsspect_image_set.PDSSpectImageSetViewBase
Main Window of pdsspect
Parameters: image_set ( PDSSpectImageSet
) – pdsspect model-
image_set
¶ PDSSpectImageSet
– The model for each view
-
pdsspect_view
¶ PDSSpectViewWidget
– The main viewer for panning
-
selection_btn
¶ QtWidgets.QPushButton
– Button to open the selections window
-
basic_btn
¶ QtWidgets.QPushButton
– Button to open the basic window
-
basic_window
¶ BasicWidget
– Window to adjust cut levels and change images
-
transforms_btn
¶ QtWidgets.QPushButton
– Open Transforms window
-
transforms_window
¶ Transforms
– Window to flip x axis, flip y axis, or switch x and y axis
-
roi_histogram_btn
¶ QPushButton
– Open ROI Histogram window
-
roi_histogram_window
¶ ROIHistogramWidget
– The ROI Histogram Window
-
roi_line_plot_btn
¶ QPushButton
– Open ROI Line Plot window
-
roi_line_plot_window
¶ ROILinePlotWidget
– The ROI Line Plot Window
-
add_window_btn
¶ QPushButton
– Add another window
-
quit_btn
¶ QtWidgets.QPushButton
– Quit
QtWidgets.QHBoxLayout
– Layout for the buttons. If you want to re-adjust where the buttons go, override this attribute
QtWidgets.QHBoxLayout
– Layout for the buttons. If you want to re-adjust where the buttons go, override this attribute
-
main_layout
¶ QtWidgets.QVBoxLayout
– Place the image viewer over the buttons. Overide this attribute if changing overall layout
-
image_sets
¶ list
– All the image sets, including the current one
-
-
pdsspect.pdsspect.
pdsspect
(inlist=None)[source]¶ Run pdsspect from python shell or command line with arguments
Parameters: inlist ( list
) – A list of file names/paths to display in the pdsspectExamples
From the command line:
To view all images from current directory
pdsspect
To view all images in a different directory
pdsspect path/to/different/directory/
This is the same as:
pdsspect path/to/different/directory/*
To view a specific image or types of images
pdsspect 1p*img
To view images from multiple directories:
pdsspect * path/to/other/directory/
From the (i)python command line:
>>> from pdsspect.pdsspect import pdsspect >>> pdsspect() Displays all of the images from current directory >>> pdsspect('path/to/different/directory') Displays all of the images in the different directory >>> pdsspect ('1p*img') Displays all of the images that follow the glob pattern >>> pdsspect('a1.img, b*.img, example/path/x*img') You can display multiple images, globs, and paths in one window by separating each item by a command >>> pdsspect(['a1.img, b3.img, c1.img, d*img']) You can also pass in a list of files/globs pdsspect returns a dictionary of the ROIs: >>> rois = pdsspect(['a1.img, b3.img, c1.img, d*img']) >>> rois['red'][:2, :2] array( [ [False, False], [False, False] ], dtype=bool )
pdsspect_image_set¶
The main model for all the views in pdsspect
-
class
pdsspect.pdsspect_image_set.
ImageStamp
(filepath, metadata=None, logger=None, wavelength=nan, unit='nm')[source]¶ Bases:
ginga.BaseImage.BaseImage
BaseImage for the image view canvas
Parameters: - filepath (
str
) – The path to the image to be opened - metadata (None) – Metadata for BaseImage
- logger (None) – logger for BaseImage
- wavelength (
float
[nan
]) – Image’s filter wavelength. Ifnan
, will try to useinstrument_models.get_wavelength.get_wavelength()
to get the wavelength - unit (
str
[nm
]) – Wavelength unit. Must be one ofaccepted_units
-
accepted_units
¶ list
– List of accepted units:nm
,um
, andAA
-
data
¶ numpy.ndarray
– Image data
-
get_wavelength
()[source]¶ astropy.units.quantity.Quantity
Copy of the wavelength
-
unit
¶ astropy.units.Unit
– Thewavelength
unitSetting the unit will convert the wavelength value as well. The new unit must also be one of the
accepted_units
- filepath (
-
class
pdsspect.pdsspect_image_set.
PDSSpectImageSet
(filepaths)[source]¶ Bases:
object
Model for each view is pdsspect
The images loaded should all have the same shape. Otherwise the images will have the smallest common shape and not look as expected (i.e., If when loading two images where one image has a shape of
(63, 36)
and the other image has a shape of(24, 42)
, the displayed shape will be(24, 36)
. This will cause the first image to have the right side cut off and the second image to have the top cut off). This is done so all ROIs created can apply to the entire list of images. To avoid this behavior, either only open images that have the same shape or open images one at a time.Parameters: filepaths ( list
) – List of filepaths to images-
colors
¶ list
ofstr
– List of possible color names to make ROIs.The possible choices for colors:
red
,brown
,lightblue
,lightcyan
,darkgreen
,yellow
,pink
,teal
,goldenrod
,sienna
,darkblue
,crimson
,maroon
,purple
, anderaser (black)
-
selection_types
¶ list
ofstr
– Selection types for making ROIs. The possible types areFilled Rectangle
,Filled Polygon
, andFilled Rectangle
, (single points).
-
accepted_units
¶ list
– List of accepted units:nm
,um
, andAA
-
images
¶ list
ofImageStamp
– Images to view and make selections. Must all have the same dimensions
-
filepaths
¶ list
– List of filepaths to images
-
current_color_index
¶ int
– Index of the current color incolors
list for ROI creation (Default is 0)
-
add_coords_to_roi_data_with_color
(coordinates, color)[source]¶ Add coordinates to ROI data in the with the given color
Parameters: - coordinates (
numpy.ndarray
ortuple
) –Either a
(m x 2)
array or a tuple of two arraysIf an array, the first column are the x coordinates and the second are the y coordinates. If a tuple of arrays, the first array are x coordinates and the second are the corresponding y coordinates.
- color (
str
) – The name a color incolors
- coordinates (
-
add_subset
(subset)[source]¶ Add a subset to the list of subsets
Parameters: subset ( SubPDSSpectImageSet
) – Subset to add to the list of subsets
-
all_rois_coordinates
¶ tuple
of twonumpy.ndarray
– Coordinates of where there is a pixel selected in a ROI
-
alpha
¶ float
– The alpha value between 0 and 1Setting the alpha value will change the opacity of all the ROIs and then set the data in the views
-
center
¶ tuple
of twofloat
– x and y coordinate of the center of the pan.Setting the center will move the pan to the new center. The center points cannot result in the pan being out of the image. If they are they will be changed so the pan only goes to the edge.
-
color
¶ str
– The current color in thecolors
list determined bycurrent_color_index
-
create_subset
()[source]¶ Create a subset and add it to the list of subsets
Returns: subset – The newly created subset Return type: SubPDSSpectImageSet
-
current_image
¶ ImageStamp
– The current image determined bycurrent_image_index
-
current_image_index
¶ int
– Index of the current image inimages
Setting the index will set the image in the views
-
delete_rois_with_color
(color)[source]¶ Delete the ROIs with the given color
Parameters: color ( str
) – The name a color incolors
-
flip_x
¶ bool
– If True, flip the x axisSetting the
flip_x
will display the transformation in the views
-
flip_y
¶ bool
– If True, flip the y axisSetting the
flip_y
will display the transformation in the views
-
get_coordinates_of_color
(color)[source]¶ The coordinates of the ROI with the given color
Parameters: color ( str
) – The name a color incolors
Returns: coordinates – The first array are the x coordinates and the second are the corresponding y coordinates Return type: tuple
of twonumpy.ndarray
-
map_zoom_to_full_view
()[source]¶ Get the change in x and y values to the center of the image
Returns:
-
pan_data
¶ numpy.ndarray
– The data within the pan
-
pan_roi_data
¶ numpy.ndarray
– The ROI data in the pan
-
remove_subset
(subset)[source]¶ Remove a subset to the list of subsets
Parameters: subset ( SubPDSSpectImageSet
) – Subset to remove to the list of subsets
-
selection_type
¶ str
– The current selection type inselection_types
determined byselection_index
-
simultaneous_roi
¶ bool
– If true, new ROIs appear in every viewSetting
simultaneous_roi
will set all windows to have the same ROIs as the first window. Any new ROI created will appear in each window
-
subsets
¶ list
ofSubPDSSpectImageSet
– The list of subsets
-
-
class
pdsspect.pdsspect_image_set.
SubPDSSpectImageSet
(parent_set)[source]¶ Bases:
pdsspect.pdsspect_image_set.PDSSpectImageSet
A Subset of an
PDSSpectImageSet
Parameters: parent_set ( PDSSpectImageSet
) – The subset’s parent-
parent_set
¶ PDSSpectImageSet
– The subset’s parent
-
add_coords_to_roi_data_with_color
(coordinates, color)¶ Add coordinates to ROI data in the with the given color
Parameters: - coordinates (
numpy.ndarray
ortuple
) –Either a
(m x 2)
array or a tuple of two arraysIf an array, the first column are the x coordinates and the second are the y coordinates. If a tuple of arrays, the first array are x coordinates and the second are the corresponding y coordinates.
- color (
str
) – The name a color incolors
- coordinates (
-
add_subset
(subset)¶ Add a subset to the list of subsets
Parameters: subset ( SubPDSSpectImageSet
) – Subset to add to the list of subsets
-
all_rois_coordinates
¶ tuple
of twonumpy.ndarray
– Coordinates of where there is a pixel selected in a ROI
-
alpha
¶ float
– The alpha value between 0 and 1Setting the alpha value will change the opacity of all the ROIs and then set the data in the views
-
center
¶ tuple
of twofloat
– x and y coordinate of the center of the pan.Setting the center will move the pan to the new center. The center points cannot result in the pan being out of the image. If they are they will be changed so the pan only goes to the edge.
-
create_subset
()¶ Create a subset and add it to the list of subsets
Returns: subset – The newly created subset Return type: SubPDSSpectImageSet
-
current_image
¶ ImageStamp
– The current image determined bycurrent_image_index
-
current_image_index
¶ int
– Index of the current image inimages
Setting the index will set the image in the views
-
delete_all_rois
()¶ Delete all of the ROIs
-
delete_rois_with_color
(color)¶ Delete the ROIs with the given color
Parameters: color ( str
) – The name a color incolors
-
flip_x
¶ bool
– If True, flip the x axisSetting the
flip_x
will display the transformation in the views
-
flip_y
¶ bool
– If True, flip the y axisSetting the
flip_y
will display the transformation in the views
-
get_coordinates_of_color
(color)¶ The coordinates of the ROI with the given color
Parameters: color ( str
) – The name a color incolors
Returns: coordinates – The first array are the x coordinates and the second are the corresponding y coordinates Return type: tuple
of twonumpy.ndarray
-
map_zoom_to_full_view
()¶ Get the change in x and y values to the center of the image
Returns:
-
pan_data
¶ numpy.ndarray
– The data within the pan
-
pan_roi_data
¶ numpy.ndarray
– The ROI data in the pan
-
register
(view)¶ Register a View with the model
-
remove_subset
(subset)¶ Remove a subset to the list of subsets
Parameters: subset ( SubPDSSpectImageSet
) – Subset to remove to the list of subsets
-
reset_center
()¶ Reset the pan to the center of the image
-
selection_type
¶ str
– The current selection type inselection_types
determined byselection_index
-
simultaneous_roi
¶ bool
– If true, new ROIs appear in every viewSetting
simultaneous_roi
will set all windows to have the same ROIs as the first window. Any new ROI created will appear in each window
-
subsets
¶ list
ofSubPDSSpectImageSet
– The list of subsets
-
swap_xy
¶ bool
– If True, swap the x and y axisSetting the
swap_xy
will display the transformation in the views
-
unregister
(view)¶ Unregister a View with the model
-
pdsspect_view¶
Window to pan the main image and open other dialog windows
-
class
pdsspect.pdsspect_view.
PDSSpectViewController
(model, view)[source]¶ Bases:
object
Controller for the
PDSSpectView
Parameters: - image_set (
PDSSpectImageSet
) – pdsspect model - view (
PDSpectView
) – View to control
- image_set (
-
class
pdsspect.pdsspect_view.
PDSSpectView
(image_set)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
,pdsspect.pdsspect_image_set.PDSSpectImageSetViewBase
View to pan the main image
Parameters: image_set ( PDSSpectImageSet
) – pdsspect model-
image_set
¶ PDSSpectImageSet
– pdsspect model
-
controller
¶
-
main_layout
¶
-
zoom_layout
¶ QtWidgets.QHBoxLayout
– Layout forzoom_label
andzoom_text
-
zoom_label
¶ QtWidgets.QLabel
– Label thezoom_text
text box
-
zoom_text
¶ QtWidgets.QLineEdit
– Text box to enter the zoom factor. Zoom will change onreturn key
-
view_canvas
¶ PDSImageViewCanvas
– canvas to place the image on
-
pan
¶ ginga.canvas.types.basic.Box
– Pan that represents the pan. Data inside the pan is displayed inPanView
-
arrow_key_move_center
(view_canvas, keyname)[source]¶ Adjust center with arrow press by a single pixel
Parameters: - view_canvas (
view_canvas
) – The view canvas - keyname (
str
) – Name of the key
- view_canvas (
-
change_center
(view_canvas, button, data_x, data_y)[source]¶ Adjust center to mouse position. Arguments supplied by callback
Parameters: - view_canvas (
view_canvas
) – The view canvas - button (
qtpy.QtCore.QMouseButton
) – The mouse button pressed - data_x (
float
) – x coordinate of mouse - data_y (
float
) – y coordinate of the mouse
- view_canvas (
-
redraw
()[source]¶ Redraw the
view_canvas
-
set_image
()[source]¶ Set image on
view_canvas
-
zoom_with_scroll
(view_canvas, zoom_event)[source]¶ Change the zoom by 1 with the mouse wheel
Parameters: - view_canvas (
view_canvas
) – The view canvas - zoom_event (
ginga.Bindings.ScrollEvent
) – The zoom event
- view_canvas (
-
-
class
pdsspect.pdsspect_view.
PDSSpectViewWidget
(image_set)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
Widget to hold the the differen
PDSSpectView
Parameters: image_set ( PDSSpectImageSet
) – pdsspect model-
image_set
¶ PDSSpectImageSet
– pdsspect model
-
create_spect_view
(image_set)[source]¶ Create a
PDSSpectView
and add to the widgetParameters: image_set ( PDSSpectImageSet
) – pdsspect modelReturns: spect_view – PDSSpectView
added to the widgetReturn type: PDSSpectView
-
pan_view¶
Display data in pan and make ROI selections
-
class
pdsspect.pan_view.
PanViewController
(image_set, view)[source]¶ Bases:
object
Controller for the
PanView
Parameters: - image_set (
PDSSpectImageSet
) – pdsspect model - view (
PanView
) – View to control
-
image_set
¶ PDSSpectImageSet
– pdsspect model
-
add_ROI
(coordinates)[source]¶ Add a region of interest
Parameters: coordinates ( numpy.ndarray
ortuple
) –Either a
(m x 2)
array or a tuple of two arraysIf an array, the first column are the x coordinates and the second are the y coordinates. If a tuple of arrays, the first array are x coordinates and the second are the corresponding y coordinates.
-
erase_ROI
(coordinates)[source]¶ Erase any region of interest inside coordinates
Parameters: coordinates ( numpy.ndarray
ortuple
) –Either a
(m x 2)
array or a tuple of two arraysIf an array, the first column are the x coordinates and the second are the y coordinates. If a tuple of arrays, the first array are x coordinates and the second are the corresponding y coordinates.
- image_set (
-
class
pdsspect.pan_view.
PanView
(image_set, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
,pdsspect.pdsspect_image_set.PDSSpectImageSetViewBase
View of the image inside the pan
Parameters: - image_set (
PDSSpectImageSet
) – pdsspect model - parent (None) – The parent of the view
-
image_set
¶ PDSSpectImageSet
– pdsspect model
-
controller
¶ PanViewController
– The view’s controller
-
parent
¶ None – The view’s parent
-
main_layout
¶ QtWidgets.QVBoxLayout
– The main layout of the view
-
view_canvas
¶ PDSImageViewCanvas
– Canvas to view the image
-
redraw
()[source]¶ Redraw
view_canvas
- image_set (
-
class
pdsspect.pan_view.
PanView
(image_set, parent=None)[source] Bases:
PyQt5.QtWidgets.QWidget
,pdsspect.pdsspect_image_set.PDSSpectImageSetViewBase
View of the image inside the pan
Parameters: - image_set (
PDSSpectImageSet
) – pdsspect model - parent (None) – The parent of the view
-
image_set
PDSSpectImageSet
– pdsspect model
-
controller
PanViewController
– The view’s controller
-
parent
None – The view’s parent
-
main_layout
QtWidgets.QVBoxLayout
– The main layout of the view
-
view_canvas
PDSImageViewCanvas
– Canvas to view the image
-
check_ROI_in_pan
(func)[source] Wrapper to make sure ROI stays inside the current view
-
check_roi_in_process
(func)[source] Wrapper to make sure the roi making is in process
-
continue_ROI
(view_canvas, button, data_x, data_y)[source] Continue the ROI making on click
-
extend_ROI
(view_canvas, button, data_x, data_y)[source] Extend the ROI on mouse motion
-
is_erasing
bool
– True if current color iseraser
false otherwise
-
move_pan
()[source] Set the data when the pan is moved
-
redraw
()[source] Redraw
view_canvas
-
save_frame
()[source] Save current frame as image
-
set_data
()[source] Set pan data on the canvas
-
set_image
()[source] Set the data
-
set_roi_data
()[source] Set the ROI data on the canvas
-
start_ROI
(view_canvas, button, data_x, data_y)[source] Start the ROI at the mouse location
-
stop_ROI
(view_canvas, button, data_x, data_y)[source] Stop ROI on right click
- image_set (
pds_image_view_canvas¶
-
class
pdsspect.pds_image_view_canvas.
PDSImageViewCanvas
[source]¶ Bases:
ginga.qtw.ImageViewCanvasQt.ImageViewCanvas
ImageViewCanvas
forpdsspect
views-
add_subview
(subview)[source]¶ Add a
ImageViewCanvas
as a subviewParameters: subview ( ginga.qtw.ImageViewCanvasQt
) – View canvas to add as a subviewRaises: TypeError
– When subview is not anImageViewCanvas
object
-
selection¶
Window to pick selection type/color, load/export ROIs and clear ROIS
-
class
pdsspect.selection.
SelectionController
(image_set, view)[source]¶ Bases:
object
Controller for
Selection
Parameters: - image_set (
PDSSpectImageSet
) – pdsspect model - view (
Selection
) – View to control
-
image_set
¶ PDSSpectImageSet
– pdsspect model
-
add_ROI
(coordinates, color, image_set=None)[source]¶ Add ROI with the given coordinates and color
Parameters: - coordinates (
numpy.ndarray
ortuple
) –Either a
(m x 2)
array or a tuple of two arraysIf an array, the first column are the x coordinates and the second are the y coordinates. If a tuple of arrays, the first array are x coordinates and the second are the corresponding y coordinates.
- color (
str
) – The name a color incolors
- coordinates (
-
change_alpha
(new_alpha)[source]¶ Change the alpha value to a new alpha value
Parameters: new_alpha ( float
) – Value between 0 and 100
-
change_current_color_index
(index)[source]¶ Change the current color index to a new index
Parameters: index ( int
) – The new color index
- image_set (
-
class
pdsspect.selection.
Selection
(image_set, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
,pdsspect.pdsspect_image_set.PDSSpectImageSetViewBase
Window to make/clear/load/export ROIs and choose selection mode/color
Parameters: - image_set (
PDSSpectImageSet
) – pdsspect model - parent (None) – Parent of the view
-
image_set
¶ PDSSpectImageSet
– pdsspect model
-
parent
¶ None – Parent of the view
-
controller
¶ SelectionController
– View controller
-
type_label
¶ QtWidgets.QLabel
– Label for the selection menu
QtWidgets.QComboBox
– Drop down menu of selection types
-
type_layout
¶ QtWidgets.QHBoxLayout
– Horizontal box layout for selection
-
color_label
¶ QtWidgets.QLabel
– Label for thecolor_menu
QtWidgets.QComboBox
– Drop down menu for color selection
-
color_layout
¶ QtWidgets.QHBoxLayout
– Horizontal box layout for color selection
-
opacity_label
¶ QtWidgets.QLabel
– Label for theopacity_slider
-
opacity_slider
¶ QtWidgets.QSlider
– Slider to determine opacity for ROIs
-
opacity_layout
¶ QtWidgets.QHBoxLayout
– Horizontal box layout for opacity slider
-
clear_current_color_btn
¶ QtWidgets.QPushButton
– Button to clear all ROIs will the current color
-
clear_all_btn
¶ QtWidgets.QPushButton
– Button to clear all ROIs
-
export_btn
¶ QtWidgets.QPushButton
– Export ROIs to.npz
file
-
load_btn
¶ QtWidgets.QPushButton
– Load ROIs from.npz
file
-
simultaneous_roi_box
¶ QtWidgets.QPushButton
– When checked, new ROIs appear in every window
-
main_layout
¶ QtWidgets.QVBoxLayout
– Vertical Box layout for main layout
-
change_alpha
(new_alpha)[source]¶ Change alpha value when
opacity_slider
value changes
-
change_color
(index)[source]¶ Change the color when color selected in
color_menu
-
change_selection_type
(index)[source]¶ Change selection type when selected in
selection_menu
-
export
(save_file)[source]¶ Export ROIS to the given filename
Parameters: save_file ( str
) – File with.npz
extension to save ROIs
- image_set (
transforms¶
Apply simple tranformations to the views
-
class
pdsspect.transforms.
TransformsController
(image_set, view)[source]¶ Bases:
object
Controller for
Transforms
Parameters: - image_set (
PDSSpectImageSet
) – pdsspect model - view (
Transforms
) – View to control
-
image_set
¶ PDSSpectImageSet
– pdsspect model
-
view
¶ Transforms
– View to control
-
set_flip_x
(flip_x)[source]¶ Set
flip_x
Parameters: flip_x ( bool
) – True to flip x axis, otherwise, False
- image_set (
-
class
pdsspect.transforms.
Transforms
(image_set, view_canvas)[source]¶ Bases:
PyQt5.QtWidgets.QDialog
,pdsspect.pdsspect_image_set.PDSSpectImageSetViewBase
Window to apply simple transformations
Parameters: - image_set (
PDSSpectImageSet
) – pdsspect model - view_canvas (
pds_image_view_canvas.PDSImageViewCanvas
) – The view canvas to apply transformations to
-
image_set
¶ PDSSpectImageSet
– pdsspect model
-
view_canvas
¶ pds_image_view_canvas.PDSImageViewCanvas
– The view canvas to apply transformations to
-
controller
¶ TransformsController
– The view’s controller
-
flip_x_label
¶ QtWidgets.QLabel
– Label forflip_x_box
-
flip_x_box
¶ QtWidgets.QCheckBox
– Flip x axis when checked
-
flip_y_label
¶ QtWidgets.QLabel
– Label forflip_y_box
-
flip_y_box
¶ QtWidgets.QCheckBox
– Flip y axis when checked
-
swap_xy_label
¶ QtWidgets.QLabel
– Label forswap_xy_box
-
swap_xy_box
¶ QtWidgets.QCheckBox
– Swap x and y axis when checked
-
layout
¶ QtWidgets.QGridLayout
– Layout for widget
-
flip_x_checked
(state)[source]¶ Flip x axis when checked
Parameters: state ( int
) – The state of the checkbox (this argument is ignored and the state is checked in a more explicit way)
- image_set (
roi¶
Region of interest creation
-
class
pdsspect.roi.
ROIBase
(image_set, view_canvas, color='red', linewidth=1, linestyle='solid', showcap=False, fill=True, fillcolor=None, alpha=1.0, drawdims=False, font='Sans Serif', fillalpha=1.0, **kwargs)[source]¶ Bases:
ginga.canvas.types.basic.Polygon
Base class for all ROI shapes
-
contains_arr
(x_arr, y_arr)[source]¶ Determine whether the points in the ROI are in arrays
The arrays must be the same shape. The arrays should be result of
np.mgrid[y1:y2:1, x1:x2:1]
Parameters: - x_arr (
numpy.ndarray
) – Array of x coodinates - y_arr (
numpy.ndarray
) – Array of y coordinates
Returns: result – Boolean array where coordinates that are in ROI are True
Return type: - x_arr (
-
create_ROI
(points=None)[source]¶ Create a Region of interest
Parameters: points ( list
oftuple
of twoint
) – Points that make up the vertices of the ROIReturns: coordinates – m x 2
array of coordinates.Return type: numpy.ndarray
-
lock_coords_to_pixel
(data_x, data_y)[source]¶ Lock the coordinates to the bottom-left corner of the pixel
The center of the pixel has integer coordinates and the edges of the pixel are 0.5 units away. We choose to lock to the bottom left corner or each pixel. If the decimal value of the coordinate is less than or equal to 0.5 then the coordinate is to the left/below the center of the pixel. To lock we round the coordinate down and add 0.5. If the decimal value is greater than 0.5 then the coordinate is to the right/above the center. To lock we round the coordinate down and subtract 0.5. For example, if the coordinate is (2.3, 4.7) the pixel coordinate is (2, 4) and the corresponding locked coordinate is (2.5, 4.5).
Parameters: Returns:
-
static
lock_coords_to_pixel_wrapper
(func)[source]¶ Wrapper to lock data coordinates to the corresponding pixels
-
-
class
pdsspect.roi.
Polygon
(image_set, view_canvas, color='red', linewidth=1, linestyle='solid', showcap=False, fill=True, fillcolor=None, alpha=1.0, drawdims=False, font='Sans Serif', fillalpha=1.0, **kwargs)[source]¶ Bases:
pdsspect.roi.ROIBase
Polygon Region of Interest
-
extend_ROI
(data_x, data_y)[source]¶ Extend the current edge of the polygon on mouse motion
Parameters:
-
-
class
pdsspect.roi.
Rectangle
(image_set, view_canvas, color='red', linewidth=1, linestyle='solid', showcap=False, fill=True, fillcolor=None, alpha=1.0, drawdims=False, font='Sans Serif', fillalpha=1.0, **kwargs)[source]¶ Bases:
pdsspect.roi.ROIBase
Rectangle Region of interest
-
extend_ROI
(data_x, data_y)[source]¶ Exend the rectangle on region of interest on mouse motion
Parameters:
-
-
class
pdsspect.roi.
Pencil
(*args, **kwargs)[source]¶ Bases:
pdsspect.roi.ROIBase
Select individual pixels
-
move_delta
(delta_x, delta_y)[source]¶ Override the move_delta function to move all the points
Parameters:
-
basic¶
-
class
pdsspect.basic.
BasicHistogramModel
(*args, **kwargs)[source]¶ Bases:
pdsspect.histogram.HistogramModel
Model for the hhistograms in the Basic Widgets
-
connected_models
¶ list
– OtherBasicHistogramModel
for other histograms
-
bins
¶ int
The number of bins the histogram usesSetting the bins will notify the views that the bins have changed
-
connect_model
(model)[source]¶ Connect another model to this model
-
model
¶ BasicHistogramModel
– Connect the model to current model
Raises: ValueError
– Whenmodel
is notBasicHistogramModel
-
-
cut_high
¶ float
The higher cut levelSetting 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 levelSetting 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
-
disconnect_model
(model)[source]¶ Disconnect another model from this model
-
model
BasicHistogramModel
– Disconnect the model from current model
Raises: ValueError
– Whenmodel
is notBasicHistogramModel
-
-
image_view
¶ ImageViewCanvas
The image view canvasSetting the image view will reset the data
-
register
(view)¶ Register a view with the model
Parameters: view ( QtWidgets.QWidget
) – A view that utilizes this model
-
restore
()¶ Restore the cut levels
-
set_data
()¶ Set the data the histogram is to display
-
unregister
(view)¶ Unregister a view with the model
Parameters: view ( QtWidgets.QWidget
) – A view that utilizes this model
-
warn
(title, message)¶ 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.basic.
BasicHistogramController
(model, view)[source]¶ Bases:
pdsspect.histogram.HistogramController
Controller for histogram views
Parameters: - model (
BasicHistogramModel
) – histogram model - view (
object
) – View withBasicHistogramModel
as its model
-
model
¶ BasicHistogramModel
– histogram model
-
view
¶ object
– View withBasicHistogramModel
as its model
-
set_cut_high
(cut_high)[source]¶ Set the high cut level to a new value
Parameters: cut_high ( float
) – New high cut value
- model (
-
class
pdsspect.basic.
BasicHistogramWidget
(*args, **kwargs)[source]¶ Bases:
pdsspect.histogram.HistogramWidget
HistogramWidget
in a different layout
-
class
pdsspect.basic.
BasicController
(image_set, view)[source]¶ Bases:
object
Controller for
Basic
windowParameters: - image_set (
PDSSpectImageSet
) – pdsspect model - view (
Basic
) – View to control
-
image_set
¶ PDSSpectImageSet
– pdsspect model
- image_set (
-
class
pdsspect.basic.
BasicWidget
(image_set, view_canvas)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
Widget to hold each basic window
Parameters: - image_set (
PDSSpectImageSet
) – pdsspect model - view_canvas (
PDSImageViewCanvas
) – view canvas
-
image_set
¶ PDSSpectImageSet
– pdsspect model
-
add_basic
(image_set, view_canvas)[source]¶ Add a
Basic
to the widgetParameters: - image_set (
PDSSpectImageSet
) – pdsspect model - view_canvas (
PDSImageViewCanvas
) – view canvas
- image_set (
- image_set (
-
class
pdsspect.basic.
Basic
(image_set, view_canvas, basic_widget)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
,pdsspect.pdsspect_image_set.PDSSpectImageSetViewBase
Window to apply cut levels and choose the current image
Parameters: - image_set (
PDSSpectImageSet
) – pdsspect model - view_canvas (
PDSImageViewCanvas
) – Canvas to view the image
-
image_set
¶ PDSSpectImageSet
– pdsspect model
-
view_canvas
¶ PDSImageViewCanvas
– Canvas to view the image
-
controller
¶ BasicController
– Controller for view
QtWidgets.QComboBox
– Drop down menu to pick the current image
-
histogram
¶ HistogramModel
– Model for thehistogram_widget
-
histogram_widget
¶ BasicHistogramWidget
– The histogram widget to adjust the cut levels
-
layout
¶ QtWidgets.QVBoxLayout
– The main layout
-
change_image
(new_index)[source]¶ Change the image when new image selected in
image_menu
Parameters: new_index ( int
) – The new index to determine the current image
- image_set (
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
, andchange_bins
. Thewarn
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 returnTrue
while the others just returnFalse
.Parameters: -
bins
¶ int
The number of bins the histogram usesSetting the bins will notify the views that the bins have changed
-
cut_high
¶ float
The higher cut levelSetting 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 levelSetting 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 canvasSetting 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
-
unregister
(view)[source]¶ Unregister a view with the model
Parameters: view ( QtWidgets.QWidget
) – A view that utilizes this model
-
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 withHistogramModel
as its model
-
model
¶ HistogramModel
– histogram model
-
view
¶ object
– View withHistogramModel
as its model
-
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
- model (
-
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
-
-
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
-
roi_plot¶
Parent classes for any widget that plots data
-
class
pdsspect.roi_plot.
ROIPlotModel
(image_set)[source]¶ Bases:
object
Model for ROI Plot and accompanying widget
Parameters: image_set ( PDSSpectImageSet
) – pdsspect model-
selected_colors
¶ list
– Colors to display in the histogram
-
latex_units
¶ list
of 3str
– The latex strings ofpdsspect_image_set.PDSSpectImageSet.accepted_units
-
add_selected_color
(color)[source]¶ Select a color and inform views to display new color
Parameters: color ( str
) – The color to add
-
image_set
¶ PDSSpectImageSet
– Image set that corresponds with the current view
-
image_sets
¶ list
– All the image sets, including the current one
-
remove_selected_color
(color)[source]¶ Remove a selected color and inform views to not display the color
Parameters: color ( str
) – The color to remove
-
unit
¶ str
– Latex version ofpdsspect_image_set.PDSSpectImageSet.unit
-
-
class
pdsspect.roi_plot.
ROIPlotController
(model, view)[source]¶ Bases:
object
Controller for ROI plot and accompanying widget
Parameters: - model (
ROIPlotModel
) – The model - view (
QtWidgets.QWidget
) – The view
-
model
¶ ROIPlotModel
– The model
-
view
¶ QtWidgets.QWidget
– The view
- model (
-
class
pdsspect.roi_plot.
ROIPlotWidget
(model)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
,pdsspect.pdsspect_image_set.PDSSpectImageSetViewBase
Widget to hold the histogram and checkboxs
Checkboxes are created in
create_color_checkbox()
which is why they do not appear in the__init__()
method.Parameters: model ( ROIPlotModel
) – The model-
model
¶ ROIPlotModel
– The model
-
controller
¶ ROIPlotController
– The controller
-
checkbox_layout
¶ QtWidgets.QVBoxLayout
– Place the checkboxes vertically
-
main_layout
¶ QtWidgets.QGridLayout
– Place in grid layout so histogram stretches while boxes are stationary
-
save_btn
¶ QtWidgets.QPushButton
– Save the plot as an image
-
red_checkbox
¶ ColorCheckBox
– Red checkbox that displays red ROI data when checked
-
brown_checkbox
¶ ColorCheckBox
– Brown checkbox that displays brown ROI data when checked
-
lightblue_checkbox
¶ ColorCheckBox
– Lightblue checkbox that displays lightblue ROI data when checked
-
lightcyan_checkbox
¶ ColorCheckBox
– Lightcyan checkbox that displays lightcyan ROI data when checked
-
darkgreen_checkbox
¶ ColorCheckBox
– Darkgreen checkbox that displays darkgreen ROI data when checked
-
yellow_checkbox
¶ ColorCheckBox
– Yellow checkbox that displays yellow ROI data when checked
-
pink_checkbox
¶ ColorCheckBox
– Pink checkbox that displays pink ROI data when checked
-
teal_checkbox
¶ ColorCheckBox
– Teal checkbox that displays teal ROI data when checked
-
goldenrod_checkbox
¶ ColorCheckBox
– Goldenrod checkbox that displays goldenrod ROI data when checked
-
sienna_checkbox
¶ ColorCheckBox
– Sienna checkbox that displays sienna ROI data when checked
-
darkblue_checkbox
¶ ColorCheckBox
– Darkblue checkbox that displays darkblue ROI data when checked
-
crimson_checkbox
¶ ColorCheckBox
– Crimson checkbox that displays crimson ROI data when checked
-
maroon_checkbox
¶ ColorCheckBox
– Maroon checkbox that displays maroon ROI data when checked
-
purple_checkbox
¶ ColorCheckBox
– Purple checkbox that displays purple ROI data when checked
-
add_view
(index=None)[source]¶ Add a view box to the widget
Parameters: index ( int
[Default None]) – The index to add the view to
-
check_color
(checkbox_color)[source]¶ Called when the state a checkbox is changed
Parameters: checkbox_color ( str
) – The color label of the check box
-
check_view_checkbox
(view_checkbox)[source]¶ Check the view box at the given index
Parameters: view_checkbox ( ViewCheckBox
) – The view check box whose state changed
-
-
class
pdsspect.roi_plot.
ROIPlot
(model)[source]¶ Bases:
matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg
,pdsspect.pdsspect_image_set.PDSSpectImageSetViewBase
Plot of the data in each ROI color
Parameters: - model (
ROIPlotModel
) – The model - image_set (
PDSSpectImageSet
) – pdsspect model
-
model
¶ ROIPlotModel
– The model
-
image_set
¶ PDSSpectImageSet
– pdsspect model
- model (
-
class
pdsspect.roi_plot.
ColorCheckBox
(color)[source]¶ Bases:
PyQt5.QtWidgets.QCheckBox
Custom checkbox that emits its color (
str
) when toggledParameters: color ( str
) – The color to name the checkbox-
stateChanged
¶ QtCore.Signal
– Signal that emits a string when check box changes its stateRead more about Signals here
-
-
class
pdsspect.roi_plot.
ViewCheckBox
(index)[source]¶ Bases:
PyQt5.QtWidgets.QCheckBox
Custom checkbox that emits its index (
int
) when toggledParameters: index ( int
) – The index of the view-
stateChanged
¶ QtCore.Signal
– Signal that emits the box itself when check box changes its stateRead more about Signals here
-
roi_histogram¶
-
class
pdsspect.roi_histogram.
ROIHistogramModel
(image_set)[source]¶ Bases:
pdsspect.roi_plot.ROIPlotModel
Model for ROI histogram and accompanying widget
-
add_selected_color
(color)¶ Select a color and inform views to display new color
Parameters: color ( str
) – The color to add
-
compare_data
¶ bool
– True ifimage_index
is not-1
-
image_index
¶ int
– The index of the image to which to compare data withWhen setting
image_index
, it may be changed to-1
if the image is the same as the current image. Furthermore, when setting theview_index
, theimage_index
may be changed to-1
if theview_index
and thecurrent_image_index
are the same.
-
image_set
¶ PDSSpectImageSet
– Image set that corresponds with the current view
-
image_sets
¶ list
– All the image sets, including the current one
-
register
(view)¶ Register view with the model
-
remove_selected_color
(color)¶ Remove a selected color and inform views to not display the color
Parameters: color ( str
) – The color to remove
-
unit
¶ str
– Latex version ofpdsspect_image_set.PDSSpectImageSet.unit
-
unregister
(view)¶ Unregister view with the model
-
view_index
¶ int
– The index of the view to display the ROI dataIf there are not multiple views, view_index is automatically
-1
.
-
xdata
(color)[source]¶ Data inside a ROI with the given color for the current image
Parameters: color ( str
) – The color of the ROIReturns: data – Data in ROI color for the xaxis Return type: numpy.ndarray
-
ydata
(color)[source]¶ Data inside a ROI with the given color for the image in the menu
Parameters: color ( str
) – The color of the ROIReturns: data – Data in ROI color for the yaxis Return type: numpy.ndarray
-
-
class
pdsspect.roi_histogram.
ROIHistogramController
(model, view)[source]¶ Bases:
pdsspect.roi_plot.ROIPlotController
Controller for ROI histogram and accompanying widget
Parameters: - model (
ROIHistogramModel
) – The model - view (
ROIHistogramWidget
orROIHistogram
) – The view
-
model
¶ ROIHistogramModel
– The model
-
view
¶ ROIHistogramWidget
orROIHistogram
– The view
-
color_state_changed
(color)¶ Select or remove the color when a checkbox color changes
Parameters: color ( str
) – The name of the checkbox whose state changed
- model (
-
class
pdsspect.roi_histogram.
ROIHistogramWidget
(model)[source]¶ Bases:
pdsspect.roi_plot.ROIPlotWidget
Widget to hold the histogram and check boxes
Parameters: model ( ROIHistogramModel
) – The model-
model
¶ ROIHistogramModel
– The model
-
controller
¶ ROIHistogramController
– The controller
QtWidgets.QComboBox
– Menu to select image for y axis
-
-
class
pdsspect.roi_histogram.
ROIHistogram
(model)[source]¶ Bases:
pdsspect.roi_plot.ROIPlot
Histogram view of the data in each ROI color
Parameters: model ( ROIHistogramModel
) – The model-
model
¶ ROIHistogramModel
– The model
-
roi_line_plot¶
-
class
pdsspect.roi_line_plot.
ROILinePlotModel
(image_set)[source]¶ Bases:
pdsspect.roi_plot.ROIPlotModel
Model for ROI Line plot and widget
-
add_selected_color
(color)¶ Select a color and inform views to display new color
Parameters: color ( str
) – The color to add
-
data_with_color
(color)[source]¶ Get the data inside the ROI color if the image has a wavelength
Parameters: color ( str
) – The color of the ROIReturns: data – Sorted list of arrays of data by wavelength Return type: list
ornumpy.ndarray
-
image_set
¶ PDSSpectImageSet
– Image set that corresponds with the current view
-
image_sets
¶ list
– All the image sets, including the current one
-
register
(view)¶ Register view with the model
-
remove_selected_color
(color)¶ Remove a selected color and inform views to not display the color
Parameters: color ( str
) – The color to remove
-
unit
¶ str
– Latex version ofpdsspect_image_set.PDSSpectImageSet.unit
-
unregister
(view)¶ Unregister view with the model
-
-
class
pdsspect.roi_line_plot.
ROILinePlotController
(model, view)[source]¶ Bases:
pdsspect.roi_plot.ROIPlotController
Controller for
ROILinePlotWidget
-
class
pdsspect.roi_line_plot.
ROILinePlotWidget
(model)[source]¶ Bases:
pdsspect.roi_plot.ROIPlotWidget
Widget to hold line plot and check boxes
Parameters: model ( ROILinePlotModel
) – The model-
model
¶ ROILinePlotModel
– The model
-
controller
¶ ROILinePlotController
– The controller
-
-
class
pdsspect.roi_line_plot.
ROILinePlot
(model)[source]¶ Bases:
pdsspect.roi_plot.ROIPlot
Line plot of ROI data
Parameters: model ( ROILinePlotModel
) – The model-
model
¶ ROILinePlotModel
– The model
-
set_wavelength¶
-
class
pdsspect.set_wavelength.
SetWavelengthModel
(image_set)[source]¶ Bases:
object
Model for
SetWavelengthWidget
Parameters: image_set ( PDSSpectImageSet
) – pdsspect model-
image_set
¶ PDSSpectImageSet
– pdsspect model
-
accepted_units
¶ list
– List of accepted units –nm
,um
, andAA
-
current_image
¶ ImageStamp
– Current image in menu
-
unit_index
¶ int
Index of – attr`unit` inaccepted_units
-
-
class
pdsspect.set_wavelength.
SetWavelengthController
(model, view)[source]¶ Bases:
object
Controller for
SetWavelengthWidget
Parameters: - model (
SetWavelengthModel
) – Model forSetWavelengthWidget
- view (
SetWavelengthWidget
) – The view to control
-
model
¶ SetWavelengthModel
– Model forSetWavelengthWidget
-
view
¶ SetWavelengthWidget
– The view to control
-
change_unit
(index)[source]¶ Set the model’s
SetWavelengthModel.unit
Parameters: index ( int
) – Index ofSetWavelengthModel.accepted_units
to change theSetWavelengthModel.unit
to
-
set_current_image_index
(index)[source]¶ Set the model’s
SetWavelengthModel.current_image_index
Parameters: index ( int
) – Index to changeSetWavelengthModel.current_image_index
to
-
set_image_wavelength
(wavelength)[source]¶ Set the model’s
SetWavelengthModel.current_image
wavelengthParameters: wavelength ( float
) – The model’sSetWavelengthModel.current_image
new wavelength
- model (
-
class
pdsspect.set_wavelength.
SetWavelengthWidget
(model)[source]¶ Bases:
PyQt5.QtWidgets.QMainWindow
Widget to set images wavelength
Using a
QtWidgets.QMainWindow
for the status bar at the bottom.Parameters: model ( SetWavelengthModel
) – Model forSetWavelengthWidget
-
model
¶ SetWavelengthModel
– Model forSetWavelengthWidget
-
controller
¶ SetWavelengthController
– The widgets controller
QtWidgets.QComboBox
– Menu to choose the image to set the wavelength
-
wavelength_text
¶ QtWidgets.QLineEdit
– Text box to enter and display wavelength
QtWidgets.QComboBox
– Menu to choose unit of wavelength
-
main_layout
¶ QtWidgets.QHBoxLayout
– Main layout of widget
-
change_unit
(index)[source]¶ Change
SetWavelengthModel.unit
to unit inunits_menu
Parameters: index ( int
) – Index ofSetWavelengthModel.accepted_units
to change theSetWavelengthModel.unit
to
-
display_current_wavelength
()[source]¶ Display the
SetWavelengthModel.current_image
wavelength inwavelength_text
-
select_image
(index)[source]¶ Select current image
Parameters: index ( int
) – Index to changeSetWavelengthModel.current_image_index
to
-
set_wavelength
()[source]¶ Set the
SetWavelengthModel.current_image
wavelength to value inwavelength_text
-
Instrument Models¶
Supported Instruments¶
- MER
- Pancam
- MSL
- Mastcam
- Cassini
- Imaging Science Subsystem (ISS)
get_wavelength¶
Get the wavelength from an image’s label
-
instrument_models.get_wavelength.
get_wavelength
(label, unit)[source]¶ Get the filter wavelength from the label of an image
See Supported Instruments for full list of supported missions and instruments. If the instrument is not supported,
get_wavelength()
will returnnan
.Parameters: - label (
pvl.PVLModule
) – Image’s label - unit (
str
[nm
]) – The wavelength unit. Best practice forunit
to exist inpdsspect.pdsspect_image_set.ImageStamp.accepted_units
Returns: wavelength – The filter wavelenth from the image rounded to 3 decimal places.
If image does not have a wavelength or the instrument is not supported, wavelength with be
nan
Return type: See also
instrument_models.mastcam.Mastcam.get_wavelength()
- Get Mastcam wavelength
instrument_models.pancam.Pancam.get_wavelength()
- Get Pancam wavelength
instrument_models.cassini_iss.CassiniISS.get_wavelength()
- Get Cassini ISS wavelength
- label (
-
instrument_models.get_wavelength.
is_pancam
(label)[source]¶ Determine if label is for a Pancam image
Parameters: label ( pvl.PVLModule
) – Image’s labelReturns: is_pancam – True
if label is from a Pancam image,False
otherwiseReturn type: bool
instrument¶
Provide base class for all instrument models
-
class
instrument_models.instrument.
InstrumentBase
(label)[source]¶ Abstract Base Class for all instrument models
Parameters: label ( pvl.PVLModule
) – Image’s label-
label
¶ pvl.PVLModule
– Image’s label
-
get_wavelength
(unit, *args, **kwargs)[source]¶ Abstract method to get the image’s wavelength
Parameters: unit ( str
[nm
]) – The wavelength unit. Best practice forunit
to exist inpdsspect.pdsspect_image_set.ImageStamp.accepted_units
Returns: wavelength – The image’s filter wavelength Return type: float
-
mastcam¶
-
class
instrument_models.mastcam.
Mastcam
(label)[source]¶ Bases:
instrument_models.instrument.InstrumentBase
Model to get the filter wavelength of a Mastcam image
See Mastcam Multispectral Imaging on the Mars Science Laboratory Rover: Wavelength Coverage and Imaging Strategies at the Gale Crater Field Site for more details on Mastcam’s filter wavelengths
-
get_wavelength
(unit='nm')[source]¶ Get the wavelength from mastcam image
Parameters: unit ( str
[nm
]) – The wavelength unit. Best practice forunit
to exist inpdsspect.pdsspect_image_set.ImageStamp.accepted_units
Returns: wavelength – Filter wavelength of the mastcam image Return type: float
-
pancam¶
-
class
instrument_models.pancam.
Pancam
(label)[source]¶ Bases:
instrument_models.instrument.InstrumentBase
Model to get the filter wavelength of a Patcam image
See Pancam for more details on Pancam’s filter wavelengths.
-
camera
¶ bool
– Images camera. Should either beleft_filters
orright_filters
-
get_wavelength
(unit='nm')[source]¶ Get the filter wavelength from the image
Parameters: unit ( str
[nm
]) – The wavelength unit. Best practice forunit
to exist inpdsspect.pdsspect_image_set.ImageStamp.accepted_units
Returns: wavelength – The image’s filter wavelength Return type: float
-
cassini_iss¶
-
class
instrument_models.cassini_iss.
CassiniISS
(label)[source]¶ Bases:
instrument_models.instrument.InstrumentBase
Model to get the filter wavelength from Cassini ISS image
See Cassini Imaging Science Subsystem (ISS) Data User’s Guide (Page 149) for table of filter name and corresponding wavelengths. We use the effective wavelength rather than the center wavelength.wavelength
-
NA_filters
¶ dict
– Dictionary of the ISS Narrow Angle Camera filter names and wavelengthsKey is the two filternames and the value is the wavelength in nm
-
WA_filters
¶ dict
– Dictionary of the ISS Wide Angle Camera filter names and wavelengthsKey is the two filternames and the value is the wavelength in nm
-
filter_name
¶ str
– The image’s filter names joined by a comma and spaceFor example, in the label the filtername appears as
("CL1","UV3")
and sofilter_name
returns'CL1, UV3'
-
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given. To understand and better read the code, you should have an understanding of the Model-View-Controller (MVC) architecture.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/planetarypy/pdsspect/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “feature” is open to whoever wants to implement it.
Write Documentation¶
pdsspect could always use more documentation, whether as part of the official pdsspect docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/planetarypy/pdsspect/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up pdsspect for local development.
Fork the pdsspect repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/pdsspect.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv pdsspect $ cd pdsspect/ $ pip install -r requirements.txt
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ make lint $ make test $ make test-all
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.6, 2.7, 3.3, and 3.4, and for PyPy. Check https://travis-ci.org/planetarypy/pdsspect/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- PlanetaryPy Developers <contact@planetarypy.com>
Contributors¶
- Perry Vargas <perrybvargas@gmail.com>
- Austin Godber <godber@uberhip.com>