tran
- drizzlepac.pixtopix.tran(inimage, outimage, direction='forward', x=None, y=None, coordfile=None, colnames=None, separator=None, precision=6, output=None, verbose=True)[source]
Primary interface to perform coordinate transformations in pixel coordinates between 2 images using STWCS and full distortion models read from each image’s header.
- Parameters:
- inimagestr
Full filename with path of input image, an extension name
['sci',1]should be provided if input is a multi-extension FITS file.- outimagestr, optional
Full filename with path of output image, an extension name
['sci',1]should be provided if output is a multi-extension FITS file. If no image gets specified, the input image will be used to generate a default output WCS usingstwcs.distortion.util.output_wcs().- directionstr
Direction of transform (forward or backward). The ‘forward’ transform takes the pixel positions (assumed to be from the ‘input’ image) and determines their position in the ‘output’ image. The ‘backward’ transform converts the pixel positions (assumed to be from the ‘output’ image) into pixel positions in the ‘input’ image.
- xfloat, optional
X position from image
- yfloat, optional
Y position from image
- coordfilestr, optional
Full filename with path of file with starting x,y coordinates
- colnamesstr, optional
Comma separated list of column names from ‘coordfile’ files containing x,y coordinates, respectively. Will default to first two columns if None are specified. Column names for ASCII files will use ‘c1’,’c2’,… convention.
- separatorstr, optional
Non-blank separator used as the column delimiter in the coordfile file
- precisionint, optional
Number of floating-point digits in output values
- outputstr, optional
Name of output file with results, if desired
- verbosebool
Print out full list of transformation results (default: False)
- Returns:
- outxfloat
X position of transformed pixel. If more than 1 input value, then it will be a numpy array.
- outyfloat
Y position of transformed pixel. If more than 1 input value, then it will be a numpy array.
Notes
This module performs a full distortion-corrected coordinate transformation based on all WCS keywords and any recognized distortion keywords from the input image header.
It can be called from within Python using the syntax:
>>> from drizzlepac import pixtopix >>> outx,outy = pixtopix.tran("input_flt.fits[sci,1]", ... "output_drz.fits[sci,1]", "forward", 100, 100)
Examples
The following command will transform the position 256,256 from ‘input_flt.fits[sci,1]’ into a position on the output image ‘output_drz.fits[sci,1]’ using:
>>> from drizzlepac import pixtopix >>> outx,outy = pixtopix.tran("input_file_flt.fits[sci,1]", ... "output_drz.fits[sci,1]", "forward", 256, 256)
2. The set of X,Y positions from ‘output_drz.fits[sci,1]’ stored as the 3rd and 4th columns from the ASCII file ‘xy_sci1.dat’ will be transformed into pixel positions from ‘input_flt.fits[sci,1]’ and written out to ‘xy_flt1.dat’ using:
>>> from drizzlepac import pixtopix >>> x,y = pixtopix.tran("input_flt.fits[sci,1]", "output_drz.fits[sci,1]", ... "backward", coordfile='xy_sci1.dat', colnames=['c3','c4'], ... output="xy_flt1.dat")