# 4.6 Analyzing HST Images

## 4.6.1 Basic Astrometry

The header of every calibrated HST two-dimensional image contains information to translate pixel positions in the image onto the World Coordinate System (WCS). Python can use this information to convert between pixel coordinates and right ascension and declination using the Astropy wcs package. For example, using WFC3/UVIS, we can convert from pixel position to WCS coordinates, and back again:

from astropy.io import fits
from astropy.wcs import WCS

with fits.open('icdm0a070_drc.fits') as hdu:

# Pixel position in (y, x)
pixel = (1000, 1200)

# Convert
ra, dec = wcs.all_pix2world(pixel[0], pixel[1], 1, ra_dec_order=True)
y, x = wcs.all_world2pix(ra, dec, 1, adaptive=False, ra_dec_order=True)

# Print results
print('Pixel ({}, {}) converts to RA: {}, Dec:{}'.format(y, x, ra, dec))

This yields the result:

Pixel (1000.0000000014072, 1200.0000000008781) converts to RA: 60.91377790287812, Dec:-43.370117840192

As you can see, our input pixel position of (y, x) = (1000, 1200) converted to (RA, Dec) in decimal degrees and back to (y, x). The optional argument adaptive=False in wcs.all_world2pix is advised for all HST data. By using the wcs.all_* functions, all WCS corrections contained within the headers will be used including SIP distortion keywords and lookup tables. For instruments that have geometric distortion corrections applied by the pipeline, these keywords will be present and the corrections will be applied during pixel-WCS coordinate transformations.

Differential astrometry 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) and inherent uncertainty in the guide star positions. Generally, observations obtained during the same visit using the same guide star acquisitions will typically have small shifts (< ~10 milli-arcseconds; see, e.g., TEL ISR 2005-02 and ACS ISR 2006-05).

The DrizzlePac notebooks contain an example of aligning HST images to an absolute reference catalog, e.g., Gaia DR2. For more information and an example, please see the "Align to Catalogs" Jupyter noteboook (a compiled HTML version is also available).

## 4.6.2 Photometry

In this subsection, we discuss aspects of HST data that are important for photometry, but we do not provide a comprehensive example of photometric analysis. The Python package photutils provides tools for aperture photometry and background estimation. Other options for photometric measurements include, e.g., dolphot and Source Extractor.

No photometry software is officially supported by STScI. Users should find an option that works best for their scientific needs and consult the documentation for those tools as necessary.

Calibrated HST images obtained from MAST store signal in various units. Table 4.1 lists a selection of HST instrument image units. Refer to the appropriate instrument-specific data handbooks for more information.

Table 4.1: Selection of HST Instrument Image Units

Instrument

Calibrated

Data Units

Drizzled

Data Units

ACS/WFCelectronselectrons / second
COSDN / secondN/A
NICMOSDN / secondDN / second
STISDNN/A
WFC3/UVISelectronselectrons / second
WFC3/IR1electrons / secondelectrons / second
WFPC2DNDN / second
1. WFC3/IR SCAN mode data have calibrated units of electrons.

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 zeropoint (PHOTZPT) into the header keywords in the calibrated data.

In some cases, instruments with multiple CCDs have different photometric calibrations for each individual CCD, e.g., in the case of WFCP2. Users should consult the appropriate instrument-specific data handbook for more information concerning if re-normalization of the sensitivity of the detectors is required.

PHOTFLAM is defined as the mean flux density Fλ in units of erg cm-2 s-1 Angstrom-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 electrons or to data numbers (DN; also called analog digital unit or ADU) depending on the instrument used. Flux values measured from calibrated images (in units of counts s-1) may be converted to physical fluxes in units of erg cm-2 s-1 Angstrom-1 by multiplying the count rate by the PHOTFLAM value. If a PHOTNU header keyword is present, then it may similarly be used to convert the count rate to a flux in units of Janskies.

If the Fλ of your spectrum 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 pysynphot. WF/PC-1 and WFPC2 users should note that the PHOTFLAM values calculated during pipeline processing did not include a correction for temporal variations in throughput owing to contamination buildup or charge transfer efficiency effects. Keywords were added to WFCP2 headers to allow users to correct for contamination (ZP_CORR) and charge transfer efficiency (CTE1E2, CTE1E3, and 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 x 512 pixels.

Similar to the AB magnitude system, there is an ST magnitude system that is based on a reference spectrum that is flat in wavelength (as opposed to flat in frequency for the AB magnitude system). The conversion from flux Fλ to magnitude is achieved in the familiar way:

$//$,

where ZP for the ST magnitude system is -21.10. This value was chosen such that the star Vega has an ST magnitude of zero for the Johnson V filter. Further corrections are necessary for converting from the ST magnitude system to other systems like Johnson/Cousins, and depend on the spectral shape of the observed source. See specific photometry examples in the instrument-specific data handbooks.

## 4.6.3 Synthetic Photometry and Transmission Curves

The python packages PySynphot (https://pysynphot.readthedocs.io/en/latest/index.html) and Synphot (with the extension STSynphothttps://stsynphot.readthedocs.io/en/latest/index.html) can simulate HST observations of astronomical targets with known spectra. They make use of tables that contain throughput information for all of the HST optical components, such as mirror, filters, gratings, apertures, and detectors, and can generate passband shapes for any combination of these elements. They 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 the HST 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.

There is functionally no difference in the results yielded by using PySynphot compared with Synphot STSynphot. The latter two packages contain some quality of life improvements over PySynphot such as use of Astropy models and Astropy quantity objects to attach units to input and output values. At STScI, PySynphot is used in the exposure time calculators.

For HST instruments, the complete path through the optical elements from the pupil to the detector of interest is specified using the "obsmode." The obsmode contains information about the instrument, detector, filter elements, and in some cases additional specifications about the date of the observation (for time-dependent sensitivity) and central wavelength of the observation.

Appendix B in both the PySynphot (https://pysynphot.readthedocs.io/en/latest/appendixb.html) and Synphot (https://stsynphot.readthedocs.io/en/latest/stsynphot/appendixb.html#stsynphot-appendixb) documentation contains information on the obsmode specification. For example, an observation using the ACS/WFC detector (specifically we will choose the WFC1 CCD for this example) using the ramp filter FR782N tuned to wavelength 7730 Angstroms and obtained on date January 1, 2019 (MJD 58484) is specified as "acs,wfc1,fr782n#7730,mjd#58484".