## Introduction

ACS/WFC images suffer from extreme geometric distortions due to the optical assembly of the telescope. The geometric distortion solution for the ACS/WFC has been derived employing a 5th order polynomial least squares solution combined with a new representation of the ACS/WFC linear terms time dependency. This model also includes additional distortions on the top of the ACS/WFC geometric distortion, such as the pixel grid distortion imprinted by the manufacturing process and the non-polynomial filter dependent component of the distortion. More details on the updated distortion correction can be found in ACS ISR 2015-06.  A comparison of the HST coordinate system used to generate the geometric distortion solution to GAIA DR1 is detailed in ACS ISR 2018-01, including an exploration of offsets between the two coordinate systems that need to be corrected with the greater precision of GAIA DR2. This work is currently underway.

The ACS/WFC geometric distortion and its time dependent corrections are corrected through the application of 3 reference files (IDCTAB, D2IMFILE and NPOLFILE) which are not applied by the normal CALACS processing. Distortion related corrections are instead applied in the DrizzlePac software that uses these reference files to remove distortions, populate the image header WCS keywords (linear terms) and populate SIP coefficients (high order terms). However, the time dependent distortion can only be applied using a version of the DrizzlePac software 2.0.0 or higher. For more information about DrizzlePac, please consult the DrizzlePac webpage.

## Distortion Reference Files

ACS/WFC Detector to Image File (D2IMFILE): A 2-D (two dimensional) correction for ACS/WFC pixel grid distortion in X and Y which is bilinearly interpolated within the DrizzlePac/STSDAS software. This reference file corrects for filter independent detector defects, and therefore only one file used for all ACS/WFC data. This replaces the ACS/WFC 68th column detector defect file previously used to correct for this distortion.

ACS/WFC Distortion Correction Tables (IDCTAB): Contains unique chip-dependent geometric distortion coefficients for every filter in one FITS table. Since the ACS/WFC distortion solution changed after Servicing Mission 4 in 2009, there are different IDCTAB files for ACS/WFC relating to before and after the servicing mission. While these files have the same format, each IDCTAB file contains different polynomial solutions for before and after the Servicing Mission as well as a change in time dependent coefficients. These reference files will be updated to include real solutions for other filters as new data and time allows.

ACS/WFC Non-polynomial Offset Files (NPOLFILE): Contains the high-order, filter-dependent distortion corrections for ACS/WFC in a FITS format 2-D look-up-table. This reference file is specific for each calibrated ACS/WFC filter and contains information for each chip within the file format.

More information about the creation of the IDC file can be found in ACS TIR 2014-02 (available upon request). The reference files are available for download from the HST Calibration Reference Data System (CRDS).

## Using The Reference Files

#### Basic steps

Get the resources: To use these reference files you must download the proper files (D2IMFILE, and the correct IDCTAB and NPOLFILE for your data). Make sure you have the new DrizzlePac software (version 2.0.0 or greater).

Update the global header: Set the global header keywords IDCTAB, NPOLFILE, and D2IMFILE to the path and filenames of the corresponding updated reference file.

Update the WCS: Run updatewcs to get the correct, geometrically accurate header coordinates.

In python, you would perform the first two steps as follows:

from astropy.io import fits
import glob

# First we update the headers to point to the location of the reference files on your machine

image_list = glob.glob('/path/to/your/data/*flc.fits')

for image in image_list:
with fits.open(iamge, mode='update') as hdu:

# Keep in mind that if you update one of the reference files, you should update them all.
# These files are built on one another and mixing reference files will create issues.

# With the headers updated to point to your local copies of the distortion reference files,
# we can now use the stwcs package to update the WCS information to use the new solution.

from stwcs import updatewcs
updatewcs.updatewcs(image_list)


Run the software: With the most recent distortion solution applied to the WCS, you may now run TweakReg to perform the image alignment and then AstroDrizzle to combine the observations.

LAST UPDATED: 06/10/2019