vdat.gui.utils – PyQt related utilities

Utilities for qt/gui stuff

vdat.gui.utils.THUMB_DIR = 'thumbs'

Name of the directory containing thumbnails

vdat.gui.utils.THUMB_PREFIX = 'thmb_'

Prefix of the thumbnail images

vdat.gui.utils.RECON_PREFIX = 'rec_'

Prefix of the reconstructed images

vdat.gui.utils.static_directory()[source]

Return the absolute path of the static directory. Construct it from the location of vdat.gui

Returns:
string

name of the directory

vdat.gui.utils.help_collection()[source]

Return the absolute path of the collection file. If no or more than one files are found return None.

Returns:
string

name of the file

vdat.gui.utils.wait_cursor()[source]

Context manager that replaces the default cursor with a WaitCursor and then reset it upon exiting

class vdat.gui.utils.FuncQThread(func, *args, **kwargs)[source]

Bases: PyQt5.QtCore.QThread

QThread that accepts a function and its arguments in the constructor and execute it in the run method

Parameters:
func : callable

function to execute

args : arguments of the function
kwargs[‘parent’] : PyQt5.QtWidgets.QWidget or derivate

parent object of the tree view model

kwargs : keyword arguments of the function
run(self)[source]
vdat.gui.utils.delete_files(paths, matches)[source]

Loop through all the path and the matches and remove all the files matching each match in each path.

Parameters:
paths : list of strings

paths containing the files to remove

matches : list of string

file names or wildcards pattern for removal

vdat.gui.utils.run_wait_func_qthread(func, *args, **kwargs)[source]

Start a thread and wait for it to finish. The cursor is set to wait_cursor() and the thread is marked for deletion before returning

Parameters:
msecs : int, optional

if given and not None force the application to process events every ``msecs` milliseconds; otherwise wait until the thread is done

all :

see FuncQThread

vdat.gui.utils.get_reconstructed()[source]

Get a pyhetdex.het.reconstruct_ifu.QuickReconstructedIFU object. If the reconstruction fails, None will be returned.

The object is created the first time the function is called and then cached. Subsequent calls will return always the same object.

Returns:
reconstructed : pyhetdex.het.reconstruct_ifu.QuickReconstructedIFU

a newly created or cached reconstructed object

vdat.gui.utils.rebin_fits(infile, outfile=None, rebin=20, z_indx=None, ext=0)[source]

Create a thumbnail of the fits infile, save and return it.

If it is a datacube, flatten the third axis using a nan-sensitive median before rebinning.

Parameters:
infile : string

name of the fits file to use to create the thumbnail

outfile : string, optional

if not None save the thumbnail as a fits file

rebin : integer, optional

reduce the number of bins by rebin, if smaller or equal to 1, no rebinning happens

z_indx : tuple of two integers, optional

if the input file is a cube, flatten only [z_indx[0], z_indx[1])

ext : int or string, optional

extension number or name to use

Returns:
data : numpy.ndarray

rebinned data

vdat.gui.utils.bin_image(data, b)[source]

Re-bin the input data grouping b*b bins. Some pixel can be lost if the size of data is not multiple of b

Parameters:
data : numpy.ndarray

array to rebin

b : int

number of bins to join

Returns:
b_data : numpy.ndarray

rebinned data

vdat.gui.utils.line_separator(parent=None)[source]

Create and return a vertical line separator

Parameters:
parent : QWidget or derived instance, optional

the parent of the current widget

Returns:
line : PyQt5.QtWidgets.QFrame

vertical sunken line