vdat.gui.tabs.tab_widget – The tab widgets

class vdat.gui.tabs.tab_widget.UpdateIFUTask(parent=None)[source]

Bases: PyQt5.QtCore.QThread

PyQt5.QtCore.QThread that runs ifu.prepare_image on every of the ifus passed to the init() method

Custom signals
Name Signature Description
finished bool Emitted when the run() is stopped (True) or finishes normally (False)
ifu_ready str after preparing the image(s) to show, emits the signal with the ifu.ifuslot string. The main thread can then retrieve the ifu and display it.
Custom slot
Name Signature Description
stop()   stop and exit from run() before finishing the list of IFUs. If the method is processing one IFU, finishes before exiting.

Note

It is not possible to update a pixmap from withing a running QThread. Therefore we emit the ifu_ready signal when the image is ready for display. It is responsibility of the process owning the thread to pain the image into the pixmap and display it.

Parameters:
parent : QWidget or derived instance, optional

the parent of the current widget

Attributes:
ifus : list

IFUs to process. Each object must implement the prepare_image()

finished
ifu_ready
run()[source]

Run the thread. Triggered by calling the start().

Loop through all the ifus and call the prepare_image method. After it returns, the ifuslot string attribute of the processed ifu is emitted via the ifu_ready signal.

stop()[source]

Make the run() method stop when starting a new loop. This method is also a PyQt slot.

class vdat.gui.tabs.tab_widget.BaseFplanePanel(tab_type, parent=None)[source]

Bases: vdat.gui.tabs.interface.FplaneTabTemplate

Implementation of the FplaneTabTemplate that creates a working fplane panel using the ifu_widget.BaseIFUWidget. Connect all the relevant slots to be able to select/deselect the IFUs.

Custom signals
Name Signature Description
sig_thread_stop   Emitted to stop the update_thread
Custom slot
Name Signature Description
update_finished bool react to the UpdateIFUTask.finished signal. The current implementation does nothing.
ifuSelected(), selectAllIFUs(), deselectAllIFUs()   see interface.FplaneTabTemplate
update_ifus()   If the update_thread runs, stop it; then pass to it the IFUs list and start the thread.
Connections between custom signals and/or slots.
Signal Slot
UpdateIFUTask.finished update_finished()
UpdateIFUTask.ifu_ready show_ifu_image()
sig_thread_stop UpdateIFUTask.stop()
ifu_widget.BaseIFUWidget.sig_ifuToggled sig_ifuToggled
Parameters:
all :

see FplaneTabTemplate

Attributes:
update_thread : UpdateIFUTask

QThread used to update the images to show in the IFUs

ifu_widget_class

Return the name of the class to use to represent IFUs in the focal plane.

fplane : FPlane

instance of the focal plane constructed using the ifu_widget_class

main_layout : PyQt5.QtWidgets.QVBoxLayout

main layout of the widget.

fplane_layout : PyQt5.QtWidgets.QGridLayout

layout containing the IFU widgets

initialized : bool

if False, react to showEvent() drawing the tab content. It is set to False at build time and in cleanup()

others

see FplaneTabTemplate

sig_thread_stop
setup_qthread()[source]

Create and setup the UpdateIFUTask. Saves it into the update_thread attribute.

Overrides this method to use other QThread implementations. The rest of the implementation assumes that update_thread has a start() method and a ifus attibute.

This method is called during the initialisation of the object

build_gui()[source]

Build the GUI calling set_main_layout() and adding to the main layout the fplane layout from build_fplane()

set_main_layout()[source]

Create and set the default layout. The layout is saved into the main_layout.

Default to PyQt5.QtWidgets.QVBoxLayout. Override to use a different layout.

build_fplane()[source]

Create a grid layout, fill it with the IFU widgets returned by ifu_widget_class, connect the relevant signals and return the layout.

The name of the fplane file is taken from the fp_filename option of the fplane sectoin in the main vdat configuration file.

Returns:
fplane_layout : PyQt5.QtWidgets.QGridLayout instance

layout containing the IFU widgets

ifu_widget_class

Return the name of the class to use to represent IFUs in the focal plane.

Override in derived classes to use a different IFU widget.

Returns:
:class:`.ifu_widget.BaseIFUWidget`
update_finished(stopped)[source]

Do nothing method. This method is also a pyqt Slot.

Override this method in derived classes to act upon the UpdateIFUTask.finished signal

Parameters:
stopped : bool

True if the updated has been forcefully stopped, False if it finished.

show_ifu_image(ifuslot)[source]

Call the show_image() of the ifu with ifuslot ID.

This method is also an pyqt slot.

Parameters:
ifuslot : str

ifuslot ID of the IFU to show

ifuSelected(ifuslot, val)[source]

Select or deselect an IFU. This method is also a PyQt slot.

Parameters:
ifuslot : string

SLOTID of the selected IFU

val : bool

If True selected, otherwise deselected

selectAllIFUs()[source]

Select all IFU. This method is also a PyQt slot.

It emits the sig_ifuToggled signal to make sure that all the ifus are registered as selected.

deselectAllIFUs()[source]

Deselect all IFU. This method is also a PyQt slot.

It emits the sig_ifuToggled signal to make sure that all the ifus are registered as deselected.

showEvent(e)[source]

When the tab becomes visible, this method is triggered by Qt. If initialized is False, calls update_ifus() and then set it to True.

Parameters:
e : PyQt5.QtGui.QShowEvent

the tab is show

update_ifus()[source]

If the update_thread is running, stop it. Pass to it the IFUs list and start the thread.

This method is also a PyQt slot.

stop_update_thread()[source]

Stop the thread and wait for it to return

cleanup()[source]

Call the super method, stop the running thread, set initialized to False and run the cleanup() on all the IFUs

class vdat.gui.tabs.tab_widget.BaseFplanePanelSetup(tab_type, parent=None)[source]

Bases: vdat.gui.tabs.tab_widget.BaseFplanePanel

Add a default setup implementation that set the title and the tooltip and then call the setup method for the IFUs

setup(target_dir, tab_dict, format_dict)[source]

Informations to pass to the tab and to the IFUs.

The method uses directly the following keys of the tab_dict argument:

  • title (mandatory): title of the current widget; the title is formatted using format_dict and saved in title.
  • tool_tip (optional): tool tip to show for the current widget; if present, the string is formatted using format_dict and saved in tool_tip.

Other keys might be used by the ifu widget setup method.

Parameters:
target_dir : string

directory selected by the user

tab_dict : dictionary

dictionary with the specifications to use to build the tabs

format_dict : string

dictionary with the fields and values that can be replaced in file names

class vdat.gui.tabs.tab_widget.FitsFplanePanel(tab_type, parent=None)[source]

Bases: vdat.gui.tabs.tab_widget.BaseFplanePanelSetup

Class that shows fits files in the focal plane. It allows to select the scaling for the IFUs.

Unless documented below, the class inherits signals, slots and connection from BaseFplanePanel.

Custom slot
Name Signature Description
toggle_individual_scale() bool When the input is true, redraw the IFU with individual scaling enabled
toggle_global_scale() bool When the input is true, redraw the IFU with using a global scaling enabled
toggle_custom_scale() bool, optional When the input is true, redraw the IFU using a custom scaling enabled
Connections between custom signals and/or slots.
Signal Slot
toggled of “Individual” radio button toggle_individual_scale()
toggled of “Global” radio button toggle_global_scale()
toggled of “Custom” radio button toggle_custom_scale() (with bool argument)
released of custom “Rescale” button toggle_custom_scale() (with no argument)
Parameters:
all :

see BaseFplanePanel

Attributes:
scaling_bar : PyQt5.QtWidgets.QHBoxLayout

layout containing the scaling bar

min_scale_custom

Float value shown in the minimum scale box.

max_scale_custom

Float value shown in the maximum scale box.

min_scale_global, max_scale_global : int

minimum and maximum global scale used when clicking on the global scale button

radio_individual_scale

Individual scale radio button

radio_global_scale

Global scale radio button

radio_custom_scale

Custom scale radio button

ifu_widget_class

Return the name of the class to use to represent IFUs in the focal plane.

Returns:
:class:`.ifu_widget.IFUFitsWidget`
build_gui()[source]

Add extra functionalities to the basic gui

add_scaling_bar()[source]

Create a PyQt5.QtWidgets.QHBoxLayout, add it to the main_layout. On this layout add buttons and text boxes to chose the scaling to use for the IFUs. Connect all the relevant signals and slots.

_radio_button(label, layout)[source]

Create a radio button, add it to layout and return it. The buttons are not marked by default.

Parameters:
label : string

label of the button

layout : PyQt5.QtWidgets.QLayout

layout to which the button is added

Returns:
button : PyQt5.QtWidgets.QRadioButton
_scale_box()[source]

Create and return a box where is possible to insert numbers.

Returns:
scale_box : PyQt5.QtWidgets.QLineEdit

box with width of 80 and a double validator

_custom_scale_setter(layout)[source]

Setup all the parts needed to set the custom scale.

Parameters:
layout : PyQt5.QtWidgets.QLayout

layout to which the pieces are added

custom_scale_set_enabled(enable)[source]

Enable/disable the labels, input boxes and button used to set the custom scaling.

Parameters:
enable : bool

whether to enable or disable the widgets.

min_scale_custom

Float value shown in the minimum scale box. Clear the text box with del min_scale_custom

max_scale_custom

Float value shown in the maximum scale box. Clear the text box with del max_scale_custom

radio_individual_scale

Individual scale radio button

radio_global_scale

Global scale radio button

radio_custom_scale

Custom scale radio button

toggle_individual_scale(enabled=True)[source]

When enabled is True redraw the IFUs using the individual scaling.

This method is also a PyQt slot.

Parameters:
enabled : bool

whether the individual scaling is enabled or not

toggle_global_scale(enabled)[source]

When enabled is True redraw the IFUs using the global scaling, saved in min_scale_global and max_scale_global.

This method is also a PyQt slot.

Parameters:
enabled : bool

whether the global scaling is enabled or not

toggle_custom_scale(enabled=True)[source]

When enabled is True redraw the IFUs using the minimum and maximum values provided by the user.

This method is also a PyQt slot.

Parameters:
enabled : bool

whether the custom scaling is enabled or not

_zscale_to_ifus(zmin, zmax)[source]

Loop over all the IFUs setting ifu.zmin_global and ifu.zmax_global to the input values.

Parameters:
zmin, zmax : float or None

values to set

reset_individual_scale()[source]

Reset the individual scale to checked

update_finished(stopped)[source]

If the update of the IFUs finished without being stopped, collect all the zmin/zmax from the IFUs and save it for the global scaling. If none of the IFUs has such values disable the global scaling button.

This method is also a pyqt Slot.

Override this method in derived classes to act upon the UpdateIFUTask.finished signal

Parameters:
stopped : bool

True if the updated has been forcefully stopped, False if it finished.

get_global_scale()[source]

Try to get the zmin and zmax from the IFUs.

If none of the IFU have those values, disable the global button. Otherwise save the values in the zmin_global and zmax_global and add their values into a tool tip and to the text boxes if they are empty

cleanup()[source]

Call the parent class implementation and unset all the min/max scales

class vdat.gui.tabs.tab_widget.QuickReconFplanePanel(tab_type, parent=None)[source]

Bases: vdat.gui.tabs.tab_widget.FitsFplanePanel

Do a quick reconstruction with the input files

Unless documented below, the class inherits signals, slots and connection, as well as attributes from FitsFplanePanel.

Parameters:
all :

see BaseFplanePanel

Attributes:
enabled : bool

if the reconstruction object exists, is set to True, else to False

ifu_widget_class

Return the name of the class to use to represent IFUs in the focal plane.

Returns:
:class:`.ifu_widget.IFUQuickReconWidget`
basenames(basenames)[source]

Set the basenames in all the ifus

setup(target_dir, tab_dict, format_dict)[source]

Informations to pass to the tab and to the IFUs.

See FitsFplanePanel.setup() for the keys of tab_dict used here.

Parameters:
target_dir : string

directory selected by the user

tab_dict : dictionary

dictionary with the specifications to use to build the tabs

format_dict : string

dictionary with the fields and values that can be replaced in file names

cleanup()[source]

On top of what FitsFplanePanel.cleanup() does, reset enabled to True

class vdat.gui.tabs.tab_widget.FitsAndReconFplanePanel(tab_type, parent=None)[source]

Bases: vdat.gui.tabs.interface.FplaneTabTemplate

This class provides a tab grouping a FitsFplanePanel and a QuickReconFplanePanel and providing a button to switch between them.

Unless documented below, the class inherits signals, slots and connection from interface.FplaneTabTemplate.

Custom slot
Name Signature Description
next_widget()   go to the next widget
Connections between custom signals and/or slots.
Signal Slot
“Reconstructed” checkbox added in the lower right corner of the widgets next_widget()
Parameters:
all :

see FplaneTabTemplate

Attributes:
others

see FplaneTabTemplate

_make_widget(Widget, tab_type, is_checked)[source]

Create a Widget instance, connect the sig_ifuToggled, add a check box with “Reconstructed” as text and connect it to a next_widget().

Parameters:
Widget : class derived from BaseFplanePanel

the widget to create

tab_type : string

name of the tab

is_checked : bool

whether the checkbox needs to be always checked or not

Returns:
w : instance of Widget
button : PyQt5.QtWidgets.QPushButton

button added to the Widget

setup(target_dir, tab_dict, format_dict)[source]

Informations to pass to the stacked widgets and to the IFUs.

Make sure that the FitsFplanePanel is always shown first. If the reconstruction object does not exist, disable the checkbox to switch to the reconstructed widget. The title and tool tip, if present, are taken from the first widget.

Parameters:
target_dir : string

directory selected by the user

tab_dict : dictionary

dictionary with the specifications to use to build the tabs

format_dict : string

dictionary with the fields and values that can be replaced in file names

cleanup()[source]

Cleanup the widgets

next_widget()[source]

Switch to the next widget.

This method is also a Qt slot.

ifuSelected(ifuslot, val)[source]

Select or deselect an IFU. This method is also a PyQt slot.

Call the corresponding method in the stacked widgets.

Parameters:
ifuslot : string

SLOTID of the selected IFU

val : bool

If True selected, otherwise deselected

selectAllIFUs()[source]

Select all IFU. This method is also a PyQt slot.

Call the corresponding method in the stacked widgets.

deselectAllIFUs()[source]

Deselect all IFU. This method is also a PyQt slot.

Call the corresponding method in the stacked widgets.

class vdat.gui.tabs.tab_widget.CubeFplanePanel(tab_type, parent=None)[source]

Bases: vdat.gui.tabs.tab_widget.FitsFplanePanel

Class that shows data cube fits files in the focal plane.

Unless documented below, the class inherits signals, slots and connection from FitsFplanePanel.

Parameters:
all :

see FitsFplanePanel

Attributes:
all :

see FitsFplanePanel

ifu_widget_class

Return the name of the class to use to represent IFUs in the focal plane.

Returns:
:class:`.ifu_widget.IFUCubeWidget`
class vdat.gui.tabs.tab_widget.MultiExtFplanePanel(tab_type, parent=None)[source]

Bases: vdat.gui.tabs.tab_widget.FitsFplanePanel

Class that shows one desired extension from fits files in the focal plane.

Unless documented below, the class inherits signals, slots and connection from FitsFplanePanel.

Parameters:
all :

see FitsFplanePanel

Attributes:
all :

see FitsFplanePanel

ifu_widget_class

Return the name of the class to use to represent IFUs in the focal plane.

Returns:
:class:`.ifu_widget.IFUMultiExtWidget`
class vdat.gui.tabs.tab_widget.StaticCheckBox(text, is_checked, parent=None)[source]

Bases: PyQt5.QtWidgets.QCheckBox

A checkbox always checked or un-checked

Custom slot
Name Signature Description
stay_checked()   Keep the “checked” state of the button always the same
Connections between custom signals and/or slots.
Signal Slot
clicked stay_checked()
Parameters:
text : string

text showing in the button

is_checked : bool

whether the checkbox must stay checked or not

parent : QWidget or derived instance, optional

the parent of the current widget

stay_checked(state)[source]

Force the checkbox to stay checked or unchecked.

This method is also a Qt Slot.

class vdat.gui.tabs.tab_widget.TextFilesPanel(tab_type, parent=None)[source]

Bases: vdat.gui.tabs.tab_widget.BaseFplanePanelSetup

Tab to show the content of a text file.

The IFU in the focal plane shows the number of lines in the file. A double click on the widget brings up a window with the content of the file

Unless documented below, the class inherits signals, slots and connection from BaseFplanePanel.

Parameters:
all :

see FplaneTabTemplate

ifu_widget_class

Return the class to use to represent IFUs in the focal plane.

Returns:
:class:`.ifu_widget.TextFileWidget`
class vdat.gui.tabs.tab_widget.DistPanel(tab_type, parent=None)[source]

Bases: vdat.gui.tabs.tab_widget.BaseFplanePanelSetup

Show the number of lines in the distortion file in the IFUs. A double click on the widget brings up a window with the content of the file. From the window, it is possible to send a region file computed from the distortion to the ds9.

Unless documented below, the class inherits signals, slots and connection from BaseFplanePanel.

Parameters:
all :

see FplaneTabTemplate

ifu_widget_class

Return the class to use to represent IFUs in the focal plane.

Returns:
:class:`.ifu_widget.BaseIFUWidget`

Inheritance scheme

Inheritance diagram of vdat.gui.tabs.tab_widget