- NAME
HEXTRACT
- PURPOSE
Extract a subimage from an array and update astrometry in FITS header
- EXPLANATION
Extract a subimage from an array and create a new FITS header with
updated astrometry for the subarray
- CALLING SEQUENCE
HEXTRACT, Oldim, Oldhd, [ Newim, Newhd, x0, x1, y0, y1, /SILENT ]
or
HEXTRACT, Oldim, Oldhd, [x0, x1, y0, y1, /SILENT, ERRMSG = ]
- INPUTS
Oldim - the original image array
Oldhd - the original image header
- OPTIONAL INPUTS
x0, x1, y0, y1 - respectively, first and last X pixel, and first and
last Y pixel to be extracted from the original image, integer scalars.
HEXTRACT will convert these values to long integers.
If omitted, HEXTRACT will prompt for these parameters
- OPTIONAL OUTPUTS
Newim - the new subarray extracted from the original image
Newhd - header for newim containing updated astrometry info
If output parameters are not supplied or set equal to
-1, then the HEXTRACT will modify the input parameters
OLDIM and OLDHD to contain the subarray and updated header.
- OPTIONAL INPUT KEYWORD
ALT - Single character 'A' through 'Z' or ' ' specifying which astrometry
system to modify in the FITS header. The default is to use the
primary astrometry or ALT = ' '. See Greisen and Calabretta (2002)
for information about alternate astrometry keywords.
/SILENT - If set and non-zero, then a message describing the extraction
is not printed at the terminal. This message can also be
suppressed by setting !QUIET.
- OPTIONAL KEYWORD OUTPUT
ERRMSG - If this keyword is supplied, then any error mesasges will be
returned to the user in this parameter rather than depending on
on the MESSAGE routine in IDL. If no errors are encountered
then a null string is returned.
- PROCEDURE
The FITS header parameters NAXIS1, NAXIS2, CRPIX1, and CRPIX2 are
updated for the extracted image.
- EXAMPLE
Read an image from a FITS file 'IMAGE', extract a 512 x 512 subimage
with the same origin, and write to a new FITS file 'IMAGENEW'
IDL> im = READFITS( 'IMAGE', hdr ) ;Read FITS files into IDL arrays
IDL> hextract, im, h, 0, 511, 0, 511 ;Extract 512 x 512 subimage
IDL> writefits, 'IMAGENEW', im ,h ;Write subimage to a FITS file
- PROCEDURES CALLED
CHECK_FITS, STRN(), SXPAR(), SXADDPAR, SXADDHIST
- MODIFICATION HISTORY
Written, Aug. 1986 W. Landsman, STX Corp.
Use astrometry structure, W. Landsman Jan, 1994
Minor fix if bad Y range supplied W. Landsman Feb, 1996
Added /SILENT keyword W. Landsman March, 1997
Added ERRMSG keyword W. Landsman May 2000
Work for dimensions larger than 32767 W.L., M.Symeonidis Mar 2007
Added ALT keyword W.L. April 2007
Use V6.0 notation W.L. October 2012
Fix for SFL projection W.L. September 2015
- heck # of parameters
- oes user want to return error messages?
Check for valid 2-D image & header
- pdate old array?
- lternative calling sequence ?
- ew dimensions
- SSS image uses CNPIX instead of CRPIX
- hift position of reference pixel
- Update astrometry info if it exists
- andle SFL projection separately in case it was originally GLS