vdat.gui.tabs.ifu_viewer
– The IFU viewer windows¶
-
exception
vdat.gui.tabs.ifu_viewer.
WindowViewerError
[source]¶ Bases:
Exception
Base exception for the viewer classes
-
exception
vdat.gui.tabs.ifu_viewer.
FitsViewerTitleTooltipError
[source]¶ Bases:
vdat.gui.tabs.ifu_viewer.WindowViewerError
,TypeError
Exception raised when the titles and/or tooltips for the fits viewer are malformed
-
exception
vdat.gui.tabs.ifu_viewer.
DistViewerFileNumberError
[source]¶ Bases:
vdat.gui.tabs.ifu_viewer.FitsViewerTitleTooltipError
Exception raised when the number of files, the titles and/or tooltips for the dist viewer are malformed
-
class
vdat.gui.tabs.ifu_viewer.
DS9Menu
(title='ds9', new_ds9_name=None, new_ds9_menu=True, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QMenu
Menu item with the
ds9
actions.¶ Name Signature Description sig_ds9
pyds9.DS9
emitted, with the ds9 instance to use, when clicking on a ds9 menu option ¶ Name Signature Description populate_ds9_menu()
dynamically create the ds9 menu pyds9_error_popup()
launch an pop up window with the explanation of the pysd9 import failure launch_ds9()
PyQt5.QtWidgets.QAction
, optionalLaunch DS9. If no action is passed, create a new window, otherwise add a new frame into an existing window; then emit sig_ds9
¶ Signal Slot aboutToShow
populate_ds9_menu()
‘There was a problem loading pyds9.’ menu entry pyds9_error_popup()
Open in DS9 menu entries launch_ds9()
Parameters: - title : string, optional
name of the menu
- new_ds9_name : list of strings, optional
list of string that are concatenated to create a name for a new DS9 window. If nothing is provided, a name will be created
- new_ds9_menu : bool, optional
add a menu to create a new DS9 window
- parent :
PyQt5.QtWidgets.QWidget
or derivate parent object of the tree view model
Attributes: - sig_ds9
-
sig_ds9
¶
Fill the DS9 menu of the IFU viewer. If ds9 instances are running, list them underneath the ‘Send selected to’ tab. Connect these so that on click the selected files are sent to that ds9 instance.
-
pyds9_error_popup
()[source]¶ Create an error popup with the pyds9 message. This method is also a PyQt slot.
-
error_popup
(error)[source]¶ Create a popup reporting the error.
Parameters: - error : list
error[0]: short error message, set as informative text; error[1]: full traceback, set as detailed text
-
launch_ds9
(action=None)[source]¶ Send files to DS9. If action is specified send to the DS9 window associated to it. Otherwise, create a new DS9 window with an automatically generated name.
Parameters: - action :
PyQt5.QtWidgets.QAction
, optional action clicked; if provided its text is used as the DS9 instance name
- action :
-
class
vdat.gui.tabs.ifu_viewer.
FitsViewerTab
(fname, tab_dict, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
Widget that display a fits file using Ginga in the upper part and the file header on the lower part.
Parameters: - fname : string
name of the file to show
- tab_dict : dictionary
dictionary with the specifications to use to build the tabs
- parent :
PyQt5.QtWidgets.QWidget
or derivate parent object of the tree view model
Attributes: - fname : string
name of the file displayed in the tab
-
class
vdat.gui.tabs.ifu_viewer.
FitsViewerWindow
(file_names, tab_dict, new_ds9_name=None, titles=None, tooltips=None, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QMainWindow
Display the given files using a ginga based viewer. Show the header information and allow to open files in DS9.
¶ Name Signature Description send_to_ds9()
pyds9.DS9
Push the file to the ds9 window passed as argument ¶ Signal Slot DS9Menu.sig_ds9
send_to_ds9()
Parameters: - file_names : list
list of files to display
- tab_dict : dictionary
dictionary with the specifications to use to build the tabs
- new_ds9_name : list of strings, optional
list of string that are concatenated to create a name for a new DS9 window. If nothing is provided, a name will be created
- titles, tooltips : list of strings, optional
if given they are used as title page and tooltip, respectively, for each of the tabs shown. If
None
the file names are used. Otherwise they must be a list with the same length offile_names
- parent :
PyQt5.QtWidgets.QWidget
or derivate parent object of the tree view model
Attributes: - ds9_menu :
PyQt5.QtWidgets.QMenu
menu containing the ds9 buttons
- tab_dict : dictionary
same as input
current_tab
Tab currently shown
-
current_tab
¶ Tab currently shown
Create a menu bar with a ds9 button.
-
send_to_ds9
(ds9)[source]¶ Send files to DS9. If action is specified send to the DS9 window associated to it. Otherwise, create a new DS9 window with an automatically generated name.
Parameters: - ds9 :
pyds9.DS9
ds9 instance to where the data are sent
- ds9 :
-
make_main_widget
(file_names, tab_dict, titles, tooltips)[source]¶ Create a tab widget and add
FitsViewerTab
classes as tabs.Parameters: - file_names : list of strings
files to display
- tab_dict : dictionary
dictionary with the specifications to use to build the tabs
- titles, tooltips : list of strings or None
if None, use the file names, otherwise check the length is the same of
file_names
Returns: - tab_widget :
PyQt5.QtWidgets.QTabWidget
widget to plug as main in the window
-
_make_title_tooltip
(file_names, titles, tooltips)[source]¶ Prepare the titles and tooltips for the tabs
Parameters: - file_names : list of strings
files to display
- titles, tooltips : list of strings or None
if None, use the file names, otherwise check the length is the same of
file_names
Returns: - file_names, titles, tooltips : list of strings
if titles and tooltips are
None
return lists with default values
Raises: - FitsViewerTitleTooltipError
when titles or tooltips is malformed
-
class
vdat.gui.tabs.ifu_viewer.
GingaWidget
(fname, tab_dict, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
Widget that display a fits file using Ginga.
Parameters: - fname : string
name of the file to show
- tab_dict : dictionary
dictionary with the specifications to use to build the tabs
- parent :
PyQt5.QtWidgets.QWidget
or derivate parent object of the tree view model
-
ginga_panel
(fn)[source]¶ Setups up a Ginga fits viewer panel.
Parameters: - fn : string
the filename of the fits file to view
Returns: - fitsview :
ImageViewCanvasQt
-
class
vdat.gui.tabs.ifu_viewer.
HeaderWidget
(fname, tab_dict, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QTextEdit
Widget that display a fits file headers.
Parameters: - fname : string
name of the file to show
- tab_dict : dictionary
dictionary with the specifications to use to build the tabs
- parent :
PyQt5.QtWidgets.QWidget
or derivate parent object of the tree view model
-
parse_fits_header
(fn, tab_dict)[source]¶ Convert a FITS header to a string and return it.
The method uses directly the following keys of the
tab_dict
argument:header_keys
(optional): list of strings. Header keywords to show on top of the others in the fits viewer window.
Parameters: - fn : string
the filename of the fits file
- tab_dict : dictionary
dictionary with the specifications to use to build the tabs
Returns: - ostr : string
The header information
-
_order_header_keys
(istr, header_keys)[source]¶ Split the incoming string on new lines and move to the beginning all the lines starting with a keyword in header_keys.
Parameters: - istr : string
string with the full headers
- header_keys : list of strings
header keywords to put at the beginning
Returns: - ostr : string
string reorganized
-
class
vdat.gui.tabs.ifu_viewer.
FileEditorWindow
(file_name, tab_dict, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QMainWindow
Simple single file editor window.
This is loosely based on https://www.binpress.com/tutorial/building-a-text-editor-with-pyqt-part-one/143
¶ Name Signature Description sig_saved
str emitted when a file is emitted ¶ Name Signature Description set_title()
str set the window title with the given file name mark_not_modified()
str, optional mark the window as not modified, input parameters ignored save_file()
str, optional save the document save_file_as()
save the document as a new file ¶ Signal Slot vdat.gui.menus_actions.QuitAction.triggered
close()
save_action.triggered
save_file()
save_as_action.triggered
save_file_as()
sig_saved
set_title()
sig_saved
mark_not_modified()
Parameters: - file_names : string
file to display
- tab_dict : dictionary
dictionary with the specifications to use to build the tabs
- parent :
PyQt5.QtWidgets.QWidget
or derivate parent object of the tree view model
Attributes: - file_name : string
name of the file to display
- text_edit :
PyQt5.QtWidgets.QTextEdit
display the text
- save_action :
PyQt5.QtWidgets.QAction
action to save the document
- save_as_action :
PyQt5.QtWidgets.QAction
action to save the document under a new name
-
sig_saved
¶
-
make_common_actions
()[source]¶ Create a number of actions than are plugged into the task and menu bars
Create and return the menu
-
set_title
(file_name)[source]¶ Set the title of the window.
This method is also a PyQt slot.
Parameters: - file_name : string
name of the file
-
mark_not_modified
(_=None)[source]¶ Mark the window as not modified. The parameter is ignored
This method is also a PyQt slot.
-
save_file
(fname=None)[source]¶ Get the text and save it to file. If
fname
isNone
, overwrite the input file.This method is also a PyQt slot
Parameters: - fname : string, optional
name of the file to use
-
save_file_as
()[source]¶ Ask for a new file name and save there the file. If no file name is given, nothing happens.
This method is also a PyQt slot
Parameters: - fname : string, optional
name of the file to use
-
closeEvent
(event)[source]¶ If the file is modified, ask what to do before closing. If
Cancel
is pressed, the window is not closed.Note
from the documentation it seems that it’s preferable to reimplement
closeEvent()
and theclose()
method.Parameters: - event :
PyQt5.QtGui.QCloseEvent
event emitted when a close attempt is made
- event :
-
class
vdat.gui.tabs.ifu_viewer.
DistTab
(dist_name, reg_name, fits_names, tab_dict, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QWidget
Widget that display a distortion solution and the region
Parameters: - dist_name : string
name of the distortion file to show
- reg_name : string
name of the region file attached to
dist_name
- fits_names : list of strings
name of the fits file that can be sent to DS9
- tab_dict : dictionary
dictionary with the specifications to use to build the tabs
- parent :
PyQt5.QtWidgets.QWidget
or derivate parent object of the tree view model
Attributes: - dist_name : string
same as input
- reg_name : string
same as input
- fits_names : list of strings
same as input
-
class
vdat.gui.tabs.ifu_viewer.
DistWindow
(dist_files, reg_files, fits_files, tab_dict, new_ds9_name=None, titles=None, tooltips=None, parent=None)[source]¶ Bases:
PyQt5.QtWidgets.QMainWindow
Show the distortion file and the region file and add button to send the distortion region to DS9.
¶ Name Signature Description send_dist_fits_to_ds9()
pyds9.DS9
Push the fits files and the regions to the ds9 window passed as argument send_dist_to_ds9()
pyds9.DS9
Push the regions to the ds9 window passed as argument ¶ Signal Slot DS9Menu.sig_ds9
(menu ‘Distortion and fits’)send_dist_fits_to_ds9()
DS9Menu.sig_ds9
(menu ‘Distortion only’)send_dist_to_ds9()
Parameters: - dist_files : list of strings
distortion files to display
- reg_files : list of strings
region files to display, must have the same size of
dist_files
- fits_names : 2d list of strings
list of list of fits files, the first dimension must have the same size of
dist_files
- tab_dict : dictionary
dictionary with the specifications to use to build the tabs
- new_ds9_name : list of strings, optional
list of string that are concatenated to create a name for a new DS9 window. If nothing is provided, a name will be created
- titles, tooltips : list of strings, optional
if given they are used as title page and tooltip, respectively, for each of the tabs shown. If
None
the file names are used. Otherwise they must be a list with the same length ofdist_files
- parent :
PyQt5.QtWidgets.QWidget
or derivate parent object of the tree view model
Attributes: - ds9_menu :
PyQt5.QtWidgets.QMenu
menu containing the ds9 buttons
current_tab
Tab currently shown
-
current_tab
¶ Tab currently shown
Create a menu bar with a ds9 button.
-
make_main_widget
(dist_files, reg_files, fits_files, tab_dict, titles, tooltips)[source]¶ Create a tab widget and add
DistTab
classes as tabs.Parameters: - dist_files : list of strings
distortion files to display
- reg_files : list of strings
region files to display, must have the same size of
dist_files
- fits_names : 2d list of strings
list of list of fits files, the first dimension must have the same size of
dist_files
- tab_dict : dictionary
dictionary with the specifications to use to build the tabs
- titles, tooltips : list of strings, optional
if given they are used as title page and tooltip, respectively, for each of the tabs shown. If
None
the file names are used. Otherwise they must be a list with the same length ofdist_files
Returns: - tab_widget :
PyQt5.QtWidgets.QTabWidget
widget to plug as main in the window
-
_make_title_tooltip
(file_names, titles, tooltips)[source]¶ Prepare the titles and tooltips for the tabs
Parameters: - file_names : list of strings
files to display
- titles, tooltips : list of strings or None
if None, use the file names, otherwise check the length is the same of
file_names
Returns: - file_names, titles, tooltips : list of strings
if titles and tooltips are
None
return lists with default values
Raises: - DistViewerFileNumberError
when titles or tooltips is malformed
-
send_dist_fits_to_ds9
(ds9)[source]¶ Send the fits files to DS9 and overplot the region files.
This method is also a PyQt slot.
Parameters: - ds9 :
pyds9.DS9
ds9 instance to where the data are sent
- ds9 :
-
send_dist_to_ds9
(ds9)[source]¶ Send the region file to a DS9 window.
This method is also a PyQt slot.
Parameters: - ds9 :
pyds9.DS9
ds9 instance to where the data are sent
- ds9 :
-
send_region_to_ds9
(ds9, regions_file, chunk_size=50)[source]¶ Send the regions from the region file to DS9.
This method assumes that each line is a region command. Because of this it cannot simply load the file into DS9, but have to send the regions in chunks of size
chunk_size
.Parameters: - ds9 :
pyds9.DS9
ds9 instance to where the data are sent
- regions_file : string
name of the file containing the regions
- chunk_size : int, optional
number of region elements to send in one go to DS9
- ds9 :