QADImView

class sofia_redux.pipeline.gui.qad.qad_imview.QADImView[source]

Bases: object

View FITS images in DS9.

Attributes:
ds9pyds9.DS9

DS9 instance to display images to.

specviewerEyeViewer

Eye instance to display spectra to.

plotviewerMatplotlibPlot

Plot viewer widget.

fileslist of str

Currently displayed FITS files.

regionslist of str

Currently displayed region files.

headersdict

FITS file headers for currently displayed files. Keys are filenames; values are lists of headers (astropy.io.fits.Header)

radial_datalist of dict

Radial flux data, for the radial_plot method to display.

histogram_datalist of dict

Histogram data, for the histogram_plot method to display.

p2p_datalist of dict

Pixel-to-pixel data, for the p2p_plot method to display.

ptableastropy.table.Table

Photometry data table.

disp_parametersdict

Display settings.

phot_parametersdict

Photometry settings.

plot_parametersdict

Plot settings.

cs{‘image’, ‘wcs’, ‘none’}

Coordinate system for DS9 display and frame locks.

Initialize the viewer.

Methods Summary

default_parameters(ptype)

Retrieve default display, photometry, and plot parameters.

get_extension_param()

Retrieve the extension setting from the display parameters.

histogram(ctr1, ctr2)

Create a histogram of pixel values at the selected location.

histogram_plot()

Plot radial fluxes in a separate window.

imexam()

Start event loop for photometry in DS9.

load(fitsfiles[, regfiles])

Load FITS files into DS9.

lock([cs, ltype, off])

Lock DS9 frames to the desired coordinate system.

overlay()

Overlay photometry aperture regions.

overlay_aperture(hdr[, hwcs])

Overlay spectroscopic aperture regions.

photometry(ctr1, ctr2)

Perform aperture photometry at a selected position.

pix2pix(ctr1, ctr2)

Create a comparison of pixel values at the selected location.

pix2pix_plot()

Plot pixel-to-pixel comparison in a separate window.

quit()

Quit DS9.

radial_plot()

Plot radial fluxes in a separate window.

reload()

Reload previously loaded FITS files.

reset()

Reset to starting state.

reset_ptable()

retrieve_data(ctr1, ctr2[, cube, photometry])

Extract a sub region from the active frame.

run(cmd[, buf, via, allframes])

Send an XPA command to DS9.

set_defaults()

Reset DS9 configuration from display parameters.

spec_test(hdul)

Test for a spectrum the Eye can display.

startup()

Start up DS9.

Methods Documentation

default_parameters(ptype)[source]

Retrieve default display, photometry, and plot parameters.

Parameters:
ptype{‘display’, ‘photometry’, ‘plot’}

Parameter type to retrieve.

Returns:
dict

Parameter settings dictionary.

get_extension_param()[source]

Retrieve the extension setting from the display parameters.

histogram(ctr1, ctr2)[source]

Create a histogram of pixel values at the selected location.

If the cursor is over an enclosed region (circle, box, etc.), then the histogram is computed for the enclosed data. Otherwise, the histogram is computed for an analysis window centered on the cursor position. The window width can be set in the plot parameter dialog; if set to a blank value, the entire image is used to compute the histogram. The binning strategy can also be set in the parameters. Accepted values are any string accepted by the matplotlib hist function, or else an integer number of bins. The range of data for the histogram can also be set in parameters, as min,max values.

Parameters:
ctr1float

RA (if DS9 coordinate system is ‘wcs’) or x-position (if DS9 coordinate system is ‘image’) at selected image location.

ctr2float

Dec (if DS9 coordinate system is ‘wcs’) or y-position (if DS9 coordinate system is ‘image’) at selected image location.

histogram_plot()[source]

Plot radial fluxes in a separate window.

imexam()[source]

Start event loop for photometry in DS9.

The following keypress values (over the DS9 window) are accepted:

  • a: Perform photometry at the cursor position.

  • p: Plot a pixel-to-pixel comparison of all loaded frames at the cursor location.

  • s: Compute statistics and plot a histogram of the data at the cursor location.

  • c: Clear active plots and photometry data.

  • h: Show a help message.

  • q: Clear previous results and close the imexam event loop.

load(fitsfiles, regfiles=None)[source]

Load FITS files into DS9.

Spectral files will be loaded into the Eye viewer if possible. Spectra are determined by the spec_test method.

If only headers are provided, they are just stored in the headers attribute.

Otherwise, all images and region files are loaded into DS9.

Parameters:
fitsfileslist of str, astropy.io.fits.HDUList, or astropy.io.fits.Header

FITS file paths to load. May also be HDUList instances or just Header instances, if the data is already in memory.

regfileslist of str, optional

DS9 region file paths to load.

lock(cs=None, ltype=None, off=False)[source]

Lock DS9 frames to the desired coordinate system.

Parameters:
cs{‘image’, ‘wcs’, ‘none’}, optional

Coordinate system to lock to. Display parameters will be used if not provided.

ltype{‘frame’, ‘crosshair’, ‘crop’, ‘slice’, ‘bin’, ‘scale’, ‘colorbar’, ‘smooth’}, optional

Lock type. If not provided, all will be locked.

offbool

If True, locks will be turned off.

overlay()[source]

Overlay photometry aperture regions.

Aperture parameters are read from the SRCPOSX/Y, STCENTX/Y, PHOTAPER, PHOTSKAP, STAPFLX, and STAPSKY header keywords in the FITS data in the currently displayed frame.

overlay_aperture(hdr, hwcs=None)[source]

Overlay spectroscopic aperture regions.

Aperture parameters are determined from the FITS header keywords APPOSO01, APRADO01, PSFRAD01, and BGR. A primary spectral WCS is required.

Parameters:
hdrastropy.io.fits.Header

FITS header to read apertures from.

photometry(ctr1, ctr2)[source]

Perform aperture photometry at a selected position.

For each active frame, the following steps are performed:

  • A window around the selected position is extracted from the FITS image.

  • NaNs in the extracted data are removed, the absolute value of the extracted data is taken, and the median value of the extracted data is subtracted.

  • The brightest peak in the window is located.

  • A model is fit to the extracted data, centered at the peak location. The model is either a 2-D Moffat or Gaussian, depending on the current photometry parameters.

  • A circular aperture and sky annulus are placed at the fit position, and fluxes are extracted.

  • Model fit parameters (centroid, FWHM, etc.) and fluxes are printed to the log at INFO level.

Parameters:
ctr1float

RA (if DS9 coordinate system is ‘wcs’) or x-position (if DS9 coordinate system is ‘image’) at selected image location.

ctr2float

Dec (if DS9 coordinate system is ‘wcs’) or y-position (if DS9 coordinate system is ‘image’) at selected image location.

pix2pix(ctr1, ctr2)[source]

Create a comparison of pixel values at the selected location.

Two or more frames must be loaded to generate a pixel comparison plot. The reference frame is Frame 1 by default, but can be changed in the plot parameters.

If the cursor is over an enclosed region (circle, box, etc.), then the comparison is computed for the enclosed data. Otherwise, the comparison is computed for an analysis window centered on the cursor position. The window width can be set in the plot parameter dialog; if set to a blank value, the entire image is used to compute the comparison.

Parameters:
ctr1float

RA (if DS9 coordinate system is ‘wcs’) or x-position (if DS9 coordinate system is ‘image’) at selected image location.

ctr2float

Dec (if DS9 coordinate system is ‘wcs’) or y-position (if DS9 coordinate system is ‘image’) at selected image location.

pix2pix_plot()[source]

Plot pixel-to-pixel comparison in a separate window.

quit()[source]

Quit DS9.

radial_plot()[source]

Plot radial fluxes in a separate window.

reload()[source]

Reload previously loaded FITS files.

reset()[source]

Reset to starting state.

reset_ptable()[source]
retrieve_data(ctr1, ctr2, cube=False, photometry=True)[source]

Extract a sub region from the active frame.

Parameters:
ctr1float

RA (if DS9 coordinate system is ‘wcs’) or x-position (if DS9 coordinate system is ‘image’) at selected image location.

ctr2float

Dec (if DS9 coordinate system is ‘wcs’) or y-position (if DS9 coordinate system is ‘image’) at selected image location.

cubebool, optional

If True, extract a region from the full data cube. Otherwise, extract from the current slice only.

photometrybool, optional

If True, the photometry parameters are used to determine the data window. Otherwise, the plot parameters are used.

Returns:
dict

Extracted data for the current frame. Keys are: ‘cs’, ‘pix_scale’, ‘wcs’, ‘window’, ‘xstart’, ‘ystart’, ‘xctr’, ‘yctr’, ‘data’, ‘fulldata’, ‘header’

run(cmd, buf=None, via='set', allframes=False)[source]

Send an XPA command to DS9.

Parameters:
cmdstr

Command to send.

buflist, str, or file-like; optional

Additional buffers to send. May be a string or a file handler, or a list of those.

via{‘get’, ‘set’}, optional

Command method.

allframesbool

If True, the command should be run once for each active frame.

Returns:
str

DS9 command exit status.

set_defaults()[source]

Reset DS9 configuration from display parameters.

spec_test(hdul)[source]

Test for a spectrum the Eye can display.

The data is considered spectral if a ‘spectral_flux’ extension is present. It is ‘spectrum_only’ if NAXIS1 is greater than 0 and NAXIS2 is less than 6. Otherwise, it is ‘image’.

Parameters:
headerastropy.io.fits.Header

FITS header to test.

Returns:
str

‘spectrum’, ‘spectrum_only’, or ‘image’.

startup()[source]

Start up DS9.