TWEAKUTILS: Utility Functions for TWEAKREG

The functions in this module support the various aspects of TweakReg, including finding the objects in the images and plotting the residuals.

Authors:

Warren Hack

License:

License

drizzlepac.tweakutils.build_pos_grid(start, end, nstep, mesh=False)[source]

Deprecated since version 3.0.0: The build_pos_grid function is deprecated and may be removed in a future version.

Return a grid of positions starting at X,Y given by ‘start’, and ending at X,Y given by ‘end’. The grid will be completely filled in X and Y by every ‘step’ interval.

drizzlepac.tweakutils.build_xy_zeropoint(imgxy, refxy, searchrad=3.0, histplot=False, figure_id=1, plotname=None, interactive=True)[source]

Deprecated since version 3.0.0: The build_xy_zeropoint function is deprecated and may be removed in a future version.

Create a matrix which contains the delta between each XY position and

each UV position.

drizzlepac.tweakutils.createWcsHDU(wcs)[source]

Generate a WCS header object that can be used to populate a reference WCS HDU.

For most applications, stwcs.wcsutil.HSTWCS.wcs2header() will work just as well.

drizzlepac.tweakutils.find_xy_peak(img, center=None, sigma=3.0)[source]

Deprecated since version 3.0.0: The find_xy_peak function is deprecated and may be removed in a future version.

Find the center of the peak of offsets

drizzlepac.tweakutils.gauss(x, sigma)[source]

Compute 1-D value of gaussian at position x relative to center.

drizzlepac.tweakutils.gauss_array(nx, ny=None, fwhm=1.0, sigma_x=None, sigma_y=None, zero_norm=False)[source]

Computes the 2D Gaussian with size nx*ny.

Parameters:
nxint
nyint [Default: None]

Size of output array for the generated Gaussian. If ny == None, output will be an array nx X nx pixels.

fwhmfloat [Default: 1.0]

Full-width, half-maximum of the Gaussian to be generated

sigma_xfloat [Default: None]
sigma_yfloat [Default: None]

Sigma_x and sigma_y are the stddev of the Gaussian functions.

zero_normbool [Default: False]

The kernel will be normalized to a sum of 1 when True.

Returns:
gauss_arrarray

A numpy array with the generated gaussian function

drizzlepac.tweakutils.idlgauss_convolve(image, fwhm)[source]

Deprecated since version 3.0.0: The idlgauss_convolve function is deprecated and may be removed in a future version.

drizzlepac.tweakutils.isfloat(value)[source]

Return True if all characters are part of a floating point value

drizzlepac.tweakutils.make_vector_plot(coordfile, columns=[1, 2, 3, 4], data=None, figure_id=None, title=None, axes=None, every=1, labelsize=8, ylimit=None, limit=None, xlower=None, ylower=None, output=None, headl=4, headw=3, xsh=0.0, ysh=0.0, fit=None, scale=1.0, vector=True, textscale=5, append=False, linfit=False, rms=True, plotname=None)[source]

Convert a XYXYMATCH file into a vector plot or set of residuals plots.

This function provides a single interface for generating either a vector plot of residuals or a set of 4 plots showing residuals. The data being plotted can also be adjusted for a linear fit on-the-fly.

Parameters:
coordfilestring

Name of file with matched sets of coordinates. This input file can be a file compatible for use with IRAF’s geomap.

columnslist [Default: [0,1,2,3]]

Column numbers for the X,Y positions from each image

datalist of arrays

If specified, this can be used to input matched data directly

titlestring

Title to be used for the generated plot

axeslist

List of X and Y min/max values to customize the plot axes

everyint [Default: 1]

Slice value for the data to be plotted

limitfloat

Radial offset limit for selecting which sources are included in the plot

labelsizeint [Default: 8] or str

Font size to use for tick labels, either in font points or as a string understood by tick_params().

ylimitfloat

Limit to use for Y range of plots.

xlowerfloat
ylowerfloat

Limit in X and/or Y offset for selecting which sources are included in the plot

outputstring

Filename of output file for generated plot

headlint [Default: 4]

Length of arrow head to be used in vector plot

headwint [Default: 3]

Width of arrow head to be used in vector plot

xshfloat
yshfloat

Shift in X and Y from linear fit to be applied to source positions from the first image

scalefloat

Scale from linear fit to be applied to source positions from the first image

fitarray

Array of linear coefficients for rotation (and scale?) in X and Y from a linear fit to be applied to source positions from the first image

vectorbool [Default: True]

Specifies whether or not to generate a vector plot. If False, task will generate a set of 4 residuals plots instead

textscaleint [Default: 5]

Scale factor for text used for labelling the generated plot

appendbool [Default: False]

If True, will overplot new plot on any pre-existing plot

linfitbool [Default: False]

If True, a linear fit to the residuals will be generated and added to the generated residuals plots

rmsbool [Default: True]

Specifies whether or not to report the RMS of the residuals as a label on the generated plot(s).

plotnamestr [Default: None]

Write out plot to a file with this name if specified.

drizzlepac.tweakutils.parse_atfile_cat(input)[source]

Return the list of catalog filenames specified as part of the input @-file

drizzlepac.tweakutils.parse_colname(colname)[source]

Common function to interpret input column names provided by the user.

This function translates column specification provided by the user into a column number.

Parameters:
colname

Column name or names to be interpreted

Returns:
colslist

The return value will be a list of strings.

Notes

This function will understand the following inputs:

'1,2,3' or   'c1,c2,c3' or ['c1','c2','c3']
'1-3'   or   'c1-c3'
'1:3'   or   'c1:c3'
'1 2 3' or   'c1 c2 c3'
'1'     or   'c1'
1
drizzlepac.tweakutils.parse_exclusions(exclusions)[source]

Read in exclusion definitions from file named by ‘exclusions’ and return a list of positions and distances

drizzlepac.tweakutils.parse_skypos(ra, dec)[source]

Function to parse RA and Dec input values and turn them into decimal degrees

Input formats could be:

[“nn”,”nn”,”nn.nn”] “nn nn nn.nnn” “nn:nn:nn.nn” “nnH nnM nn.nnS” or “nnD nnM nn.nnS” nn.nnnnnnnn “nn.nnnnnnn”

drizzlepac.tweakutils.plot_zeropoint(pars)[source]

Plot 2d histogram.

Pars will be a dictionary containing:

data, figure_id, vmax, title_str, xp,yp, searchrad

drizzlepac.tweakutils.radec_hmstodd(ra, dec)[source]

Function to convert HMS values into decimal degrees.

This function relies on the astropy.coordinates package to perform the conversion to decimal degrees.

Parameters:
ralist or array

List or array of input RA positions

declist or array

List or array of input Dec positions

Returns:
posarr

Array of RA,Dec positions in decimal degrees

Notes

This function supports any specification of RA and Dec as HMS or DMS; specifically, the formats:

["nn","nn","nn.nn"]
"nn nn nn.nnn"
"nn:nn:nn.nn"
"nnH nnM nn.nnS" or "nnD nnM nn.nnS"
drizzlepac.tweakutils.read_ASCII_cols(infile, cols=[1, 2, 3])[source]

Interpret input ASCII file to return arrays for specified columns.

Returns:
outarrlist of arrays

The return value will be a list of numpy arrays, one for each ‘column’.

Notes

The specification of the columns should be expected to have lists for each ‘column’, with all columns in each list combined into a single entry.

For example:

cols = ['1,2,3','4,5,6',7]

where ‘1,2,3’ represent the X/RA values, ‘4,5,6’ represent the Y/Dec values and 7 represents the flux value for a total of 3 requested columns of data to be returned.

drizzlepac.tweakutils.read_FITS_cols(infile, cols=None)[source]

Read columns from FITS table

drizzlepac.tweakutils.readcols(infile, cols=None)[source]

Function which reads specified columns from either FITS tables or ASCII files

This function reads in the columns specified by the user into numpy arrays regardless of the format of the input table (ASCII or FITS table).

Parameters:
infilestring

Filename of the input file

colsstring or list of strings

Columns to be read into arrays

Returns:
outarrarray

Numpy array or arrays of columns from the table

drizzlepac.tweakutils.write_shiftfile(image_list, filename, outwcs='tweak_wcs.fits')[source]

Write out a shiftfile for a given list of input Image class objects