Space Telescope Science Institute
Intro to HST Data Handbooks 8.0 May 2011
Table of Contents Previous Next Index Print

Introduction to the HST Data Handbooks > Chapter 3: Analyzing HST Data > 3.4 Analyzing HST Images

Analyzing HST Images
This section describes methods for using STSDAS and IRAF to work with two-dimensional HST data. Subjects include:
This section describes how to determine the orientation of an HST image and the RA and Dec of any pixel or source within it, including:
Positional Information
The header of every calibrated HST two-dimensional image contains a linear astrometric plate solution, written in terms of the standard FITS astrometry header keywords: reference pixel values (CRPIX1, CRPIX2, CRVAL1, CRVAL2), and the CD matrix (CD1_1, CD1_2, CD2_1, and CD2_2). IRAF/STSDAS tasks can use this information to convert between pixel coordinates and RA and Dec. Two simple tasks that draw on these keywords to relate your image to sky coordinates are:
disconlab: Displays your image with contours and grid of RA and Dec. Simply open an SAOimage window and type, for example:
xy2rd: Translates x- and y-pixel coordinates to RA and Dec. (The task rd2xy inverts this operation.) DS9 displays the current x,y pixel location of the cursor in the upper-left corner of the window. These tasks will only give accurate results when they are run on images which have been corrected for distortion. To find the RA and Dec of the current pixel, you supply these coordinates to xy2rd by typing:
Note, the hms option formats the results in hours, minutes, and seconds.
Observers should be aware that these tasks do not correct for geometric distortion. Only ACS, FOC, STIS, WFC31, and WFPC2 images currently undergo geometric correction during standard pipeline processing. Table 3.2 lists some additional tasks that make use of the standard astrometry keywords.
Table 3.2: Additional IRAF and STSDAS Astrometry Tasks
(rimexamine) Mutli-purpose tool for examining images - statistics, photometry, and astrometry.
Improving Astrometric Accuracy
Differential astrometry (measuring a position of one object relative to another in an image) is easy and relatively accurate for HST images. Absolute astrometry, on the other hand, is more difficult, owing to uncertainties in the locations of the instrument apertures relative to the Optical Telescope Assembly (OTA or V1 axis) and the inherent uncertainty in guide star positions. Generally, observations obtained during the same visit using the same guide star acquisition are well-registered. Observations separated by one or more guide star acquisitions will typically have small shifts. However, if you can determine an accurate position for any single star in your HST image, then your absolute astrometric accuracy will be limited only by the accuracy with which you know that star’s location and the image orientation.
If there is a star on your image suitable for astrometry, you may wish to find its absolute position from the Guide Star Catalog II (GSC2), which is on the IAU recommended International Celestial Reference Frame, and has a typical error of 0.3". Contact the Help Desk if you require further assistance.
This section describes implot and imexamine, two basic IRAF tools for studying the characteristics of an image. Table 3.4 lists many useful IRAF/STSDAS tasks for manipulating images. The list is not exhaustive, just a sample of what is available.
The IRAF implot task (in the plot package) allows you to examine an image interactively by plotting data along a given line (x-axis) or column (y-axis). When you run the task, a number of commands are available in addition to the usual cursor mode commands common to most IRAF plotting tasks. A complete listing of commands is found in the online help, but those most commonly used are listed in Table 3.3. Figure 3.3 shows an example of how to use the implot task to plot a row of data.
Table 3.3: Basic Implot ­Commands
Figure 3.3: Plotting Image Data with Implot (Step 2 Only Works in IRAF)
The imexamine task (in the package) is a powerful IRAF task that integrates image display with various types of plotting capabilities. Commands can be passed to the task using the image display cursor and the graphics cursor. A complete description of the task and its usage are provided in the online help, available from within the IRAF environment by typing help imexamine.
ACS, COS, NICMOS, STIS, and WFC3 data files contain groups of images, called imsets, associated with each individual exposure. See Table 2.2 and the Data Structures chapters in Part II for more details on imsets.
Table 3.4: Image Manipulation Tasks.
Extension of gcombine for HST FITS imsets1
Extension of gstatistics for HST FITS imsets1

Will process all groups of a multi-group GEIS file.

Here we describe several STSDAS tasks, located in the stsdas.toolbox.imgtools.mstools package, that have been designed to work with imsets as units and to deconstruct and rebuild them.
This tool is an extension of the IRAF task imarith to include error and data quality propagation. The msarith task supports the four basic arithmetic operations (+, -, *, /) and can operate on individual or multiple imsets. The input operands can be either files or numerical constants; the latter can have associated errors, which will propagate into the error array(s) of the output file.
This task runs the STSDAS task gcombine on ACS, COS, NICMOS, STIS, and WFC3 data files. It separates each imset into its basic components (e.g., SCI, ERR, DQ, SAMP, TIME). The SCI extensions then become the inputs for the underlying gcombine task, and the ERR extensions become the error maps. The DQ extensions are first combined with a user-specified Boolean mask allowing selective pixel masking and are then combined into the data quality maps. If scaling by exposure time is requested, the exposure times of each imset are read from the header keyword PIXVALUE in the TIME extensions (NICMOS and WFC3/IR data only).
Once gcombine has finished, mscombine then reassembles the individual output images into imsets and outputs them as one data file. The output images and error maps from gcombine form the SCI and ERR extensions of the output imset(s). The DQ extension will be a combination of the masking operations and the rejection algorithms executed in gcombine. TIME extensions will be the sum of the TIME values from the input files minus the rejected values, divided on a pixel-by-pixel basis by the number of valid pixels in the output image. The final TIME array will be consistent with the output SCI image (average or median of the science data). The SAMP extension is built from all the input SAMP values, minus the values discarded by masking or rejection.
This tool is an extension of gstatistics in the STSDAS package, which is in turn an extension of imstatistics. The main feature is the inclusion of the error and data quality information included with HST FITS images in computing statistical quantities.
In addition to the standard statistical quantities (min, max, sum, mean, standard deviation, median, mode, skewness, kurtosis), two additional quantities have been added to take advantage of the error information: the weighted mean and the weighted variance of the pixel distribution. If xi is the value at the i-th pixel, with associated error σi, the weighted mean and variance used in the task are:
The data quality information in the imset is used to reject pixels in the statistical computation. Users can supply additional masks to reject objects or regions from the science arrays.
mssplit and msjoin
The mssplit task extracts user-specified imsets from a FITS data file and copies them into separate files. Each output file contains a single imset along with the primary header of the original file. You might find this task useful for reducing the size of a file containing many imsets or for performing analysis on a specific imset. The msjoin task does the opposite of mssplit: it assembles separate imsets into a single data file.
There are other tasks in this package for deleting and sorting imsets, as well as tasks for addressing a specific image class within an imset.
Included in this section are:
A list of IRAF/STSDAS tasks useful for determining source flux.
A brief description of synphot, the STSDAS synthetic photometry ­package.
IRAF and STSDAS Photometry Tasks
The following are some useful IRAF/STSDAS packages and tasks for performing photometry on HST images:
apphot: aperture photometry package.
daophot: stellar photometry package useful for crowded fields.
isophote: package for fitting elliptical isophotes.
imexamine: performs simple photometry measurements.
imstat: computes image pixel statistics.
imcnts: sums counts over a specified region, subtracting background.
plcreate: creates pixel masks.
Consult the online help for more details on these tasks and packages. The document “Photometry using IRAF” by Lisa A. Wells, provides a general guide to performing photometry with IRAF; it is available through the IRAF Web page:
The apphot package allows you to measure fluxes within a series of concentric apertures. This technique can be used, for example, to determine the flux in the wings of the PSF, which is useful if you wish to estimate the flux of a saturated star by scaling the flux in the wings of the PSF to an unsaturated PSF.
Converting to Units of Flux or Magnitude
Calibrated HST images obtained from the HDA store signal in various units. Table 3.5 lists a selection of HST instrument image units. Refer to the instrument specific Data Handbooks for instruments not included in this list.
Table 3.5: Examples of Calibrated HST Image Units

No drizzled products from the pipeline.

The pipeline calibration tasks do not alter the units in the images when performing the photometric correction step. Instead they calculate and write the sensitivity conversion factor (PHOTFLAM) and the ST magnitude scale zero point (PHOTZPT) into header keywords in the calibrated data. WF/PC-1 and WFPC2 observers should note that the four chips are calibrated individually, so these photometry keywords belong to the group parameters for each chip. For ACS observers, the PHOTFLAM values for the two WFC chips are defined to be the same.
PHOTFLAM is defined as the mean flux density Fλ in units of erg cm-2 s-1 Ĺ-1 that produces 1 count per second in the HST observing mode (PHOTMODE) used for the observation. (Note that the word “counts” may refer to DN or electrons, depending on the instrument used.) For example, calibrated ACS images are already corrected for the instrumental gain, and the PHOTFLAM values are computed accordingly. The PHOTFLAM values for WFPC2, on the other hand, are dependent on the gain.
Calibrated images, in units of DN or electrons (e.g., STIS or WFPC2), may be converted to flux in units of erg cm-2 s-1 Ĺ-1 by multiplying the image by the value of the PHOTFLAM header keyword and dividing by the value of the EXPTIME keyword (exposure time). Calibrated images in units of signal rates (e.g., NICMOS data in DN s-1 and drizzled ACS data in electrons s-1), may simply be multiplied by the PHOTFLAM value to obtain the flux in units of erg cm-2 s-1 Ĺ-1. NICMOS and WFC3/IR image headers also contain the keyword PHOTFNU in units of Janskys. Multiplying these images by the PHOTFNU value will therefore yield fluxes in Janskys.
The STSDAS task imcalc may be used to convert an image from counts to flux units. For example, to create a flux-calibrated output image outimg.fits from an input image inimg.fits[1] with header keywords PHOTFLAM = 2.5E-18 and EXPTIME = 1000.0, type:
If the Fλ spectrum of your source is significantly sloped across the bandpass or contains prominent features, such as strong emission lines, you may wish to recalculate the inverse sensitivity PHOTFLAM using synphot, described below. WF/PC-1 and WFPC2 observers should note that the PHOTFLAM values calculated during pipeline processing do not include a correction for temporal variations in throughput owing to contamination buildup, or Charge Transfer Efficiency (CTE) effects. However, for WFPC2, new header keywords provide parameters that can be used to derive corrections for each chip, in units of magnitude, for contamination (ZP_CORR) and CTE (CTE1E2, CTE_1E3, CTE1E4). Likewise, FOC observers should note that PHOTFLAM values determined by the pipeline before May 18, 1994 do not account for sensitivity differences in formats other than 512 × 512. Consult the instrument section (Part II) of the Data Handbook for more information.
If your HST image contains a source whose flux you know from ground based measurements, you may choose to calibrate the final photometry of your HST image from the counts observed for this source.
To convert a measured flux F, in units of erg cm-2 s-1 Ĺ-1, to an ST magnitude, the following equation may be used:
m = –2.5 x log10 (F) + PHOTZPT
where the value of the PHOTZPT keyword is the zero point of the ST magnitude (STMAG) scale. The STMAG system is based on constant flux per unit wavelength. The zero point of the STMAG system is equal to –21.10, a value chosen so that Vega has an ST magnitude of zero for the Johnson V passband (see Figure 3.4; Koornneef et al., 1986; Horne 1988; and the Synphot User’s Guide).
Figure 3.4: Standard Photometric Systems Illustrated.
Further zeropoint corrections are necessary for converting from STMAG to other systems like Johnson/Cousins, and depend on the color of your sources. See specific photometry examples in the instrument sections of this Handbook (Part II).
The STSDAS synthetic photometry package, called synphot, can simulate HST observations of astronomical targets with known spectra. It makes use of a data set that contains throughput curves of all HST optical components, such as mirrors, filters, gratings, apertures, and detectors, and it can generate passband shapes for any combination of these elements. It can also generate synthetic spectra of many different types of sources, including stellar, blackbody, power-law and H II regions, and can convolve these spectra with the throughputs of HST’s instruments. You can therefore use it to compare results in many different bands, to cross-calibrate one instrument with another, or to relate your observations to theoretical models.
One useful application of synphot is to recalculate the value of PHOTFLAM for a given observation using the latest HST sensitivity tables. The bandpar task may be used to compute the photometric parameters of a passband using the combined throughputs of the individual HST components. For example, to recalculate PHOTFLAM for an ACS observation, type:
where the observation mode string is a comma separated list consisting of the instrument and its configuration, in this case the ACS detector with the WFC chip 1 and the F555W filter. (See the obsmode task in synphot and the Synphot User’s Guide for help with these observation mode keywords.) To see a list of observation mode keywords for the ACS, type:
Using the default parameters, the bandpar command shown above will print to the screen a table of photometric parameters. The URESP parameter contains the flux (in Fλ) of a source that produces a response of one count per second in this passband and is therefore identical to PHOTFLAM.
Please see the Synphot User’s Guide for more details on this package. See the Synphot Data User’s Guide and Section 4.5 for more information on how to use and obtain the synphot data set, which is not included with STSDAS.
Combining Dithered HST Datasets with MultiDrizzle
Many HST observations make use of the technique of dithering, or offsetting the telescope to different locations in order to move the target around the detector. This is done for several reasons, including sub-pixel offsets to improve PSF sampling, offsets to move bad pixels around to different locations on the sky, or large shifts comparable to the detector size, to create large mosaics of the target field.
The recommended software to combine dithered HST datasets is MultiDrizzle (Koekemoer et al. 2002), which is a PyRAF script designed to provide fully automated image registration, cosmic ray cleaning, and final image combination using the drizzle software (Fruchter & Hook 2002) and PyDrizzle. MultiDrizzle is currently available within STSDAS and has been tested on a representative set of commonly-used ACS, NICMOS, STIS, WFPC2, and WFC3 observing modes.
The only required input to MultiDrizzle is a list of calibrated science images. The user may also choose to provide additional input such as bad pixel masks, a delta-shift file, or a reference image. The script performs the following steps:
Determine shifts from the WCS information in the image headers. If the user has supplied a delta-shift file, those shifts are applied in addition to the header offsets. The user may also choose to provide the absolute shifts to use for each image, ignoring the header information.
Drizzle each input image onto a separate output image. All images remain in the same reference plane such that any pixel (x,y) is the same logical coordinate in each image. During the drizzling process, each image is corrected for any geometric distortion that might be present.
Transform sections of the median image, corresponding to the location of each input image, back to the original distorted input frames and calculate the derivative of each image.
Compare the original input image against the transformed median and its derivative in order to create a cosmic ray mask for each exposure.
Combine the cosmic ray masks with any additional user-supplied bad pixel masks and finally drizzle all the original input exposures onto a single output image.
The various steps can each be turned on or off by the user, since there may be cases where not all the steps need to be run, or some of them may have already been run. In addition, parameters controlling the behavior of each step can be adjusted by the user. The default parameter values are set such that the script should produce a scientifically-useful combined, drizzled image in a single operation. However, this may not be the optimal scientific image for a given set of exposures, therefore access is provided to parameters of drizzle and other steps for fine-tuning the results.
Please refer to the MultiDrizzle Handbook v3.0 (Fruchter & Sosey et al. 2009), and the online help documentation for MultiDrizzle within PyRAF, for further information about the various parameters for the script. The handbook also contains basic examples for each of the current instruments.
In general, the code has been tested on a wide variety of the most commonly used observing modes and should produce useful results with the default parameters. Since the software is actively being improved, it is important to check for updates if you find problems with a particular dataset. Users are encouraged to send e-mail to for assistance.
We are currently developing a replacement for MultiDrizzle which will rely on an extended image header for all the astrometric and distortion information used to geometrically correct and align the images. This new task will be announced as soon as a version has been successfully tested with data from the current imaging instruments on HST.

After installation on HST during Servicing Mission 4.

Table of Contents Previous Next Index Print