Pixel-based ACS/WFC CTE Forward Model#
This notebook demonstrates preparing data for input into the ACS/WFC pixel-based CTE forward model and running the model.
Table of Contents#
Introduction
0. Install/update stenv
1. Imports
2. Download data and reference files
3. Create an image of artificial stars
Option A: Start with an observed FLC image
4. Add artificial stars
5. Reverse the flat and dark correction
6. Run CTE forward model
7. (Optional) Run CTE correction
8. Apply flat and dark correction
Option B: Start with a synthetic image
4. Create your image
5. Run CTE forward model
6. (Optional) Run CTE correction
7. Apply flat and dark correction
About this Notebook
Introduction#
The charge transfer efficiency (CTE) of the Advanced Camera for Surveys (ACS) Wide Field Channel (WFC) has been decreasing over the lifetime of the instrument. Radiation damage from cosmic rays and other sources leads to charge traps within the detector. These traps remove electrons from charge packets as they are transferred between rows of the detector, and release the electrons in subsequent pixels. This causes flux to be removed from bright features and released into pixels behind the features (relative to the row closest to the amplifier), creating bright trails.
A pixel-based CTE correction model for the ACS/WFC detector is fully described in Anderson & Bedin (2010), and a recent update to the model is presented in ACS ISR 2018-04. The model is based on an empirical determination of the number and depth of charge traps distributed across the detector. It simulates detector readout of an input image, removes the result from the input, and iterates five times. In this way, a reverse model is successively approximated by the forward model. Electrons released in trails are removed and added back to the bright feature in which they originated.
The pixel-based correction was implemented in the calibration pipeline code for ACS (CALACS
) in 2012 and the algorithm was updated and improved in 2018. The CTE correction step within CALACS
runs on bias-corrected images, blv_tmp
files, producing blc_tmp
files, which lack the bright trails due to poor CTE. Further calibration, including dark correction and flat-fielding, produces flt
and flc
files from the blv_tmp
and blc_tmps
files, respectively. For more information on calibration of ACS/WFC data, see the ACS Data Handbook.
Users desiring to more fully understand the effects of pixel-based CTE correction on their science may wish to run the forward model (i.e., the detector readout simulation) on data containing artificial stars. Here we demonstrate two methods for running the CTE forward model. In Option A, we begin with an observed flc
image, whereas in Option B, we begin with a raw
image and generate synthetic data on which to run the forward model.
Note: The forward model, like the CTE correction step in CALACS
, adds 10% of the difference between the input and output SCI
extensions to the ERR
extensions to account for uncertainty in the CTE model. Below, we provide guidance for properly repopulating the ERR
extensions of forward-modeled data.
0. Install/update stenv#
*AstroConda is no longer supported and is superseded by stenv.#
stenv will include most packages from AstroConda and is recommended to process and analyze data from the Hubble Space Telescope (HST) and James Webb Space Telescope (JWST). To install and activate stenv, please refer to the documentation. NOTE: stenv requires Python 3.8 or greater.
If you already use stenv, make sure the versions of hstcal
and acstools
are both at least 2.1.0. The version of CALACS
should be at least 10.1.0. Check the versions of all three on the command line:
$ conda list hstcal
$ conda list acstools
$ calacs.e --version
It is recommended, however, that you use the most up-to-date versions of these packages. To update these packages, run the following via the command line:
$ conda update hstcal
$ conda update acstools
1. Imports#
Start by importing several packages:
matplotlib notebook for creating interactive plots
os for setting environment variables
shutil for managing directories
numpy for math and array calculations
collections OrderedDict for making dictionaries easily
matplotlib pyplot for plotting
matplotlib.colors LogNorm for scaling images
astropy.io fits for working with FITS files
photutils datasets for creating synthetic stars and images
astroquery.mast Observations for downloading data from MAST
acstools acsccd for performing bias correction
acstools acscte for performing CTE correction (reversing CTE trailing)
acstools acs2d for performing dark correction and flat-fielding
acstools acscteforwardmodel for running CTE forward model (generating CTE trailing)
import os
import shutil
import numpy as np
from collections import OrderedDict
import matplotlib.pyplot as plt
from astropy.io import fits
from photutils import datasets
from astroquery.mast import Observations
from acstools import acsccd
from acstools import acscte
from acstools import acs2d
from acstools import acscteforwardmodel
/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/acstools/utils_findsat_mrt.py:24: UserWarning: skimage not installed. MRT calculation will not work: ModuleNotFoundError("No module named 'skimage'")
warnings.warn(f'skimage not installed. MRT calculation will not work: {repr(e)}') # noqa
/opt/hostedtoolcache/Python/3.11.10/x64/lib/python3.11/site-packages/acstools/utils_findsat_mrt.py:30: UserWarning: scipy not installed. Kernel generation will not work
warnings.warn('scipy not installed. Kernel generation will not work')
Top of Page
2. Download data and reference files#
Full-frame, new-mode subarray, and 2K old-mode subarray ACS/WFC images can be run through the CTE forward model. New-mode subarrays were added to the HST flight software at the beginning of Cycle 24. These subarrays have APERTURE
keywords of the type WFC1A-512, WFC1A-1K, WFC1A-2K
, etc. Old-mode subarrays have APERTURE
keywords of the type WFC1-512, WFC1-1K, WFC1-2K
, etc. WFC apertures are also listed in Table 7.7 of the ACS IHB.
We recommend that the CTE forward model be run on data that has been bias-corrected, but not dark-corrected or flat-fielded. The flat and dark should be present in the image input into the CTE forward model because these features are present in the image when it is read out, and are therefore affected by CTE losses. The forward model can be run on flc
files, but the results will technically be incorrect. Photometric tests of forward modeled data of both types show minor differences. Post-SM4 subarray data must be destriped with acs_destripe_plus
, which will also perform the other calibration steps. Note: At this time, acs_destripe_plus
only produces flt
/flc
images.
We download a full-frame 47 Tuc image, jd0q14ctq
, from the ACS CCD Stability Monitor program (PI: Coe, 14402) from the Mikulski Archive for Space Telescopes (MAST) using astroquery. This image was taken in March 2016, and so it is strongly affected by CTE losses. We download the flc
image for Option A and the raw
image for Option B into the current directory.
obs_table = Observations.query_criteria(obs_id='jd0q14ctq')
dl_table = Observations.download_products(obs_table['obsid'], mrp_only=False,
productSubGroupDescription=['FLC', 'RAW'])
for row in dl_table:
oldfname = row['Local Path']
unique_fname = np.unique(oldfname)
newfname = os.path.basename(oldfname)
print(row)
os.rename(oldfname, newfname)
shutil.rmtree('mastDownload')
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/hst_14402_14_acs_wfc_f775w_jd0q14ct_flc.fits to ./mastDownload/HST/hst_14402_14_acs_wfc_f775w_jd0q14ct/hst_14402_14_acs_wfc_f775w_jd0q14ct_flc.fits ...
[Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/jd0q14ctq_flc.fits to ./mastDownload/HST/jd0q14ctq/jd0q14ctq_flc.fits ...
[Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/jd0q14ctq_raw.fits to ./mastDownload/HST/jd0q14ctq/jd0q14ctq_raw.fits ...
[Done]
Local Path Status Message URL
--------------------------------------------------------------------------------------------------- -------- ------- ----
./mastDownload/HST/hst_14402_14_acs_wfc_f775w_jd0q14ct/hst_14402_14_acs_wfc_f775w_jd0q14ct_flc.fits COMPLETE None None
Local Path Status Message URL
----------------------------------------------- -------- ------- ----
./mastDownload/HST/jd0q14ctq/jd0q14ctq_flc.fits COMPLETE None None
Local Path Status Message URL
----------------------------------------------- -------- ------- ----
./mastDownload/HST/jd0q14ctq/jd0q14ctq_raw.fits COMPLETE None None
Next, update and download the correct flat and dark reference files for the jd0q14ctq
dataset from the Calibration Reference Data System (CRDS). We use the CRDS command line tools to do this.
os.environ['CRDS_SERVER'] = 'https://hst-crds.stsci.edu'
os.environ['CRDS_PATH'] = './crds_cache'
os.environ['jref'] = './crds_cache/references/hst/acs/'
!crds bestrefs --update-bestrefs --sync-references=1 --files jd0q14ctq_flc.fits
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfpc2_wf4tfile_0250.rmap 678 bytes (1 / 142 files) (0 / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfpc2_shadfile_0250.rmap 977 bytes (2 / 142 files) (678 / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfpc2_offtab_0250.rmap 642 bytes (3 / 142 files) (1.7 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfpc2_maskfile_0250.rmap 685 bytes (4 / 142 files) (2.3 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfpc2_idctab_0250.rmap 696 bytes (5 / 142 files) (3.0 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfpc2_flatfile_0250.rmap 30.0 K bytes (6 / 142 files) (3.7 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfpc2_dgeofile_0250.rmap 801 bytes (7 / 142 files) (33.7 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfpc2_darkfile_0250.rmap 178.4 K bytes (8 / 142 files) (34.5 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfpc2_biasfile_0250.rmap 3.3 K bytes (9 / 142 files) (212.8 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfpc2_atodfile_0250.rmap 874 bytes (10 / 142 files) (216.1 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfpc2_0250.imap 782 bytes (11 / 142 files) (217.0 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_snkcfile_0003.rmap 681 bytes (12 / 142 files) (217.8 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_satufile_0002.rmap 1.0 K bytes (13 / 142 files) (218.5 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_pfltfile_0253.rmap 34.2 K bytes (14 / 142 files) (219.5 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_pctetab_0004.rmap 698 bytes (15 / 142 files) (253.7 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_oscntab_0250.rmap 747 bytes (16 / 142 files) (254.4 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_npolfile_0254.rmap 4.0 K bytes (17 / 142 files) (255.1 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_nlinfile_0250.rmap 726 bytes (18 / 142 files) (259.2 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_mdriztab_0254.rmap 845 bytes (19 / 142 files) (259.9 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_imphttab_0256.rmap 683 bytes (20 / 142 files) (260.7 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_idctab_0254.rmap 661 bytes (21 / 142 files) (261.4 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_flshfile_0256.rmap 5.8 K bytes (22 / 142 files) (262.1 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_drkcfile_0194.rmap 234.8 K bytes (23 / 142 files) (267.9 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_dfltfile_0002.rmap 17.1 K bytes (24 / 142 files) (502.7 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_darkfile_0492.rmap 276.0 K bytes (25 / 142 files) (519.8 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_d2imfile_0251.rmap 605 bytes (26 / 142 files) (795.8 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_crrejtab_0250.rmap 803 bytes (27 / 142 files) (796.4 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_ccdtab_0250.rmap 799 bytes (28 / 142 files) (797.2 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_bpixtab_0310.rmap 11.7 K bytes (29 / 142 files) (798.0 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_biasfile_0267.rmap 23.4 K bytes (30 / 142 files) (809.7 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_biacfile_0003.rmap 692 bytes (31 / 142 files) (833.1 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_atodtab_0250.rmap 651 bytes (32 / 142 files) (833.8 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_wfc3_0595.imap 1.3 K bytes (33 / 142 files) (834.4 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_synphot_tmttab_0002.rmap 745 bytes (34 / 142 files) (835.7 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_synphot_tmgtab_0012.rmap 767 bytes (35 / 142 files) (836.4 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_synphot_tmctab_0053.rmap 743 bytes (36 / 142 files) (837.2 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_synphot_thruput_0057.rmap 329.6 K bytes (37 / 142 files) (837.9 K / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_synphot_thermal_0003.rmap 20.4 K bytes (38 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_synphot_obsmodes_0004.rmap 743 bytes (39 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_synphot_0068.imap 579 bytes (40 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_xtractab_0250.rmap 815 bytes (41 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_wcptab_0251.rmap 578 bytes (42 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_teltab_0250.rmap 745 bytes (43 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_tdstab_0254.rmap 921 bytes (44 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_tdctab_0252.rmap 650 bytes (45 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_srwtab_0250.rmap 745 bytes (46 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_sptrctab_0251.rmap 895 bytes (47 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_sdctab_0251.rmap 889 bytes (48 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_riptab_0254.rmap 877 bytes (49 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_phottab_0258.rmap 1.6 K bytes (50 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_pfltfile_0250.rmap 23.7 K bytes (51 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_pctab_0250.rmap 3.1 K bytes (52 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_mofftab_0250.rmap 747 bytes (53 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_mlintab_0250.rmap 601 bytes (54 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_lfltfile_0250.rmap 11.8 K bytes (55 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_lamptab_0250.rmap 610 bytes (56 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_inangtab_0250.rmap 815 bytes (57 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_imphttab_0252.rmap 616 bytes (58 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_idctab_0251.rmap 775 bytes (59 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_halotab_0250.rmap 747 bytes (60 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_gactab_0250.rmap 651 bytes (61 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_exstab_0250.rmap 745 bytes (62 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_echsctab_0250.rmap 749 bytes (63 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_disptab_0250.rmap 813 bytes (64 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_darkfile_0354.rmap 59.9 K bytes (65 / 142 files) (1.2 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_crrejtab_0250.rmap 711 bytes (66 / 142 files) (1.3 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_cdstab_0250.rmap 745 bytes (67 / 142 files) (1.3 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_ccdtab_0252.rmap 893 bytes (68 / 142 files) (1.3 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_bpixtab_0250.rmap 845 bytes (69 / 142 files) (1.3 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_biasfile_0356.rmap 119.9 K bytes (70 / 142 files) (1.3 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_apertab_0250.rmap 588 bytes (71 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_apdestab_0252.rmap 636 bytes (72 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_stis_0370.imap 1.7 K bytes (73 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_zprattab_0250.rmap 646 bytes (74 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_tempfile_0250.rmap 1.1 K bytes (75 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_tdffile_0250.rmap 8.9 K bytes (76 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_saadfile_0250.rmap 771 bytes (77 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_saacntab_0250.rmap 594 bytes (78 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_rnlcortb_0250.rmap 771 bytes (79 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_pmskfile_0250.rmap 603 bytes (80 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_pmodfile_0250.rmap 603 bytes (81 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_phottab_0250.rmap 862 bytes (82 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_pedsbtab_0250.rmap 594 bytes (83 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_noisfile_0250.rmap 2.6 K bytes (84 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_nlinfile_0250.rmap 1.7 K bytes (85 / 142 files) (1.4 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_maskfile_0250.rmap 1.2 K bytes (86 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_illmfile_0250.rmap 5.8 K bytes (87 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_idctab_0250.rmap 767 bytes (88 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_flatfile_0250.rmap 11.0 K bytes (89 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_darkfile_0250.rmap 14.9 K bytes (90 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_nicmos_0250.imap 1.1 K bytes (91 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_ywlkfile_0003.rmap 922 bytes (92 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_xwlkfile_0002.rmap 922 bytes (93 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_xtractab_0269.rmap 1.6 K bytes (94 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_wcptab_0257.rmap 1.3 K bytes (95 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_twozxtab_0277.rmap 990 bytes (96 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_tracetab_0276.rmap 998 bytes (97 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_tdstab_0271.rmap 803 bytes (98 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_spwcstab_0255.rmap 1.1 K bytes (99 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_spottab_0006.rmap 766 bytes (100 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_proftab_0276.rmap 1.0 K bytes (101 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_phatab_0250.rmap 668 bytes (102 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_lamptab_0264.rmap 1.4 K bytes (103 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_hvtab_0259.rmap 567 bytes (104 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_hvdstab_0002.rmap 1.0 K bytes (105 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_gsagtab_0261.rmap 712 bytes (106 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_geofile_0250.rmap 670 bytes (107 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_fluxtab_0282.rmap 1.7 K bytes (108 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_flatfile_0264.rmap 1.8 K bytes (109 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_disptab_0276.rmap 1.7 K bytes (110 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_dgeofile_0002.rmap 909 bytes (111 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_deadtab_0250.rmap 711 bytes (112 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_brsttab_0250.rmap 696 bytes (113 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_brftab_0250.rmap 614 bytes (114 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_bpixtab_0260.rmap 773 bytes (115 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_badttab_0252.rmap 643 bytes (116 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_cos_0358.imap 1.4 K bytes (117 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_spottab_0251.rmap 641 bytes (118 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_snkcfile_0098.rmap 7.4 K bytes (119 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_shadfile_0251.rmap 531 bytes (120 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_satufile_0002.rmap 1.2 K bytes (121 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_pfltfile_0253.rmap 69.2 K bytes (122 / 142 files) (1.5 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_pctetab_0253.rmap 615 bytes (123 / 142 files) (1.6 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_oscntab_0251.rmap 781 bytes (124 / 142 files) (1.6 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_npolfile_0253.rmap 3.2 K bytes (125 / 142 files) (1.6 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_mlintab_0250.rmap 646 bytes (126 / 142 files) (1.6 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_mdriztab_0253.rmap 769 bytes (127 / 142 files) (1.6 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_imphttab_0260.rmap 769 bytes (128 / 142 files) (1.6 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_idctab_0256.rmap 1.5 K bytes (129 / 142 files) (1.6 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_flshfile_0268.rmap 3.4 K bytes (130 / 142 files) (1.6 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_drkcfile_0449.rmap 14.9 K bytes (131 / 142 files) (1.6 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_dgeofile_0250.rmap 3.2 K bytes (132 / 142 files) (1.6 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_darkfile_0440.rmap 86.8 K bytes (133 / 142 files) (1.6 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_d2imfile_0253.rmap 601 bytes (134 / 142 files) (1.7 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_crrejtab_0251.rmap 945 bytes (135 / 142 files) (1.7 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_cfltfile_0250.rmap 1.2 K bytes (136 / 142 files) (1.7 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_ccdtab_0256.rmap 1.4 K bytes (137 / 142 files) (1.7 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_bpixtab_0252.rmap 1.0 K bytes (138 / 142 files) (1.7 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_biasfile_0438.rmap 56.9 K bytes (139 / 142 files) (1.7 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_atodtab_0251.rmap 528 bytes (140 / 142 files) (1.8 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_acs_0539.imap 1.3 K bytes (141 / 142 files) (1.8 M / 1.8 M bytes)
CRDS - INFO - Fetching ./crds_cache/mappings/hst/hst_1181.pmap 495 bytes (142 / 142 files) (1.8 M / 1.8 M bytes)
CRDS - INFO - No comparison context or source comparison requested.
CRDS - INFO - ===> Processing jd0q14ctq_flc.fits
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/17717071j_osc.fits 17.3 K bytes (1 / 16 files) (0 / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/19i16323j_cte.fits 8.6 M bytes (2 / 16 files) (17.3 K / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/25e1534hj_snk.fits 68.6 M bytes (3 / 16 files) (8.7 M / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/25g1256nj_bpx.fits 23.0 K bytes (4 / 16 files) (77.2 M / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/37g1550cj_mdz.fits 247.7 K bytes (5 / 16 files) (77.3 M / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/4af1559ij_imp.fits 953.3 K bytes (6 / 16 files) (77.5 M / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/4bb1536cj_idc.fits 285.1 K bytes (7 / 16 files) (78.5 M / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/4bb15371j_d2i.fits 51.8 K bytes (8 / 16 files) (78.8 M / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/4bb15376j_npl.fits 51.8 K bytes (9 / 16 files) (78.8 M / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/5331917aj_sat.fits 171.4 M bytes (10 / 16 files) (78.9 M / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/66418280j_bia.fits 171.5 M bytes (11 / 16 files) (250.3 M / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/72m1821dj_ccd.fits 49.0 K bytes (12 / 16 files) (421.7 M / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/78f18443j_drk.fits 268.5 M bytes (13 / 16 files) (421.8 M / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/78g0300bj_dkc.fits 268.5 M bytes (14 / 16 files) (690.3 M / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/qb12257oj_pfl.fits 167.8 M bytes (15 / 16 files) (958.8 M / 1.3 G bytes)
CRDS - INFO - Fetching ./crds_cache/references/hst/acs/qbu16428j_dxy.fits 134.3 M bytes (16 / 16 files) (1.1 G / 1.3 G bytes)
CRDS - INFO - 0 errors
CRDS - INFO - 0 warnings
CRDS - INFO - 160 infos
Next, we obtain the filenames of the flat (PFLTFILE
), CTE-corrected dark (DRKCFILE
), and superbias (BIASFILE
) reference files from the image header. The flat will be used to add the effects of the flat field back into the image. If the data were post-flashed, then the flash file (FLSHFILE
) is needed as well. This is shown in the commented line below. The CTE-corrected dark will be used to add dark current to the flc
file and the synthetic data. The superbias will be used to repopulate the ERR
extensions of the forward-modeled image.
hdr = fits.getheader('jd0q14ctq_flc.fits')
flat = hdr['PFLTFILE'].split('$')[-1]
dkc = hdr['DRKCFILE'].split('$')[-1]
bias = hdr['BIASFILE'].split('$')[-1]
# flash = hdr['FLSHFILE'].split('$')[-1]
We open the flat and dark images and obtain the SCI
extensions of both CCDs, which are extension 1 for WFC2 and extension 4 for WFC1. We open the superbias image and obtain the ERR
extensions of both CCDs, which are extension 2 for WFC2 and extension 5 for WFC2. If the flash file is needed, obtain the SCI
extensions for both CCDs. This is shown in the commented out lines below.
# The jref environment variable gives the directory containing the reference files
flat_hdu = fits.open('{}/{}'.format(os.environ['jref'], flat))
flat_wfc1 = flat_hdu[4].data
flat_wfc2 = flat_hdu[1].data
dkc_hdu = fits.open('{}/{}'.format(os.environ['jref'], dkc))
dkc_wfc1 = dkc_hdu[4].data
dkc_wfc2 = dkc_hdu[1].data
# Darks can sometimes have negative pixels because they have been flash-corrected
# and CTE-corrected. Set all negative pixels to zero
dkc_wfc1[dkc_wfc1 < 0.] = 0.
dkc_wfc2[dkc_wfc2 < 0.] = 0.
bias_hdu = fits.open('{}/{}'.format(os.environ['jref'], bias))
err_bias_wfc1 = bias_hdu[5].data
err_bias_wfc2 = bias_hdu[2].data
dq_bias_wfc1 = bias_hdu[6].data
dq_bias_wfc2 = bias_hdu[3].data
# flash_dhu = fits.open('{}/{}'.format(os.environ['jref'], flash))
# flash_wfc1 = flash_hdu[4].data
# flash_wfc2 = flash_hdu[1].data
Top of Page
3. Create image of artificial stars#
We will need an image containing artificial stars on zero background for both options presented below. Artificial stars are typically generated using models that do not include the flat field, or are produced from data that have been flat-fielded. If this is the case, artificial stars should be added to the image at the flc
stage.
Users of this notebook may have a preferred method for generating artificial stars and adding them to data, so here we simply add several Gaussians to the image using utilities within photutils.datasets
in astropy
. These Gaussians are not representative of the true ACS/WFC PSF, and are added here for illustrative purposes only. Please note that artificial sources with peak values approaching or exceeding the WFC CCD full well value of about 80,000 electrons are not recommended for simulated data. Blooming of charge from saturated pixels is not implemented in this example.
There are many tools for generating artificial stars, including Tiny Tim, effective PSFs, or EPSFBuilder
in photutils
. A recent study of PSF models for ACS/WFC can be found here.
First, we generate a table of random Gaussian sources of typical brightness for our 47 Tuc field with \(\mathrm{FWHM}\sim2.5\) pixels. Because \(\mathrm{FWHM} = 2.355\sigma\), we will generate Gaussian sources with \(\sigma \sim 1.06\) pixels in both \(x\) and \(y\).
n_sources = 300
param_ranges = [('amplitude', [500, 30000]),
('x_mean', [0, 4095]),
('y_mean', [0, 2047]),
('x_stddev', [1.05, 1.07]),
('y_stddev', [1.05, 1.07]),
('theta', [0, np.pi])]
param_ranges = OrderedDict(param_ranges)
sources = datasets.make_random_gaussians_table(n_sources, param_ranges,
seed=12345)
print(sources)
WARNING: AstropyDeprecationWarning: The make_random_gaussians_table function is deprecated and may be removed in a future version.
Use make_random_models_table instead. [warnings]
WARNING:astroquery:AstropyDeprecationWarning: The make_random_gaussians_table function is deprecated and may be removed in a future version.
Use make_random_models_table instead.
id amplitude ... theta flux
--- ------------------ ... ------------------- ------------------
1 7206.412662781505 ... 2.712707760579224 50652.658930963386
2 9844.37102143771 ... 1.3330571904556816 70607.2565158368
3 24022.280991315656 ... 0.3480385124846702 168613.39471682537
4 20449.512787153748 ... 1.342926033417225 145908.0418805293
5 12037.731742756316 ... 2.6122798684754893 85001.36001245494
6 10318.010872058343 ... 0.8062330648198324 72401.41372880769
7 18150.1082308221 ... 3.0094016055213455 127692.02199023766
8 6008.658475309544 ... 0.4630263808842762 42397.584907698736
9 20346.30329843133 ... 2.1903431729736735 145036.5712243056
10 28283.184525463148 ... 2.508684497439569 199351.54211949607
... ... ... ... ...
291 22460.78594543185 ... 0.23546611227724332 158793.35009852485
292 8198.588511505417 ... 1.1987208959743372 58648.959927614625
293 3811.029873895477 ... 1.8974014869765485 27065.689149000333
294 28329.932866705938 ... 2.8660981311873894 198281.18264249954
295 20665.887070474408 ... 1.2564287062720447 145810.15139285228
296 28766.302003180244 ... 0.6087139456187645 205145.3723018843
297 10220.53835528653 ... 0.5441486181817121 71118.0623848711
298 6171.619463863724 ... 1.4697029385979279 43570.257318745484
299 4535.268669686549 ... 1.0788778925254099 32044.896080348244
300 28329.64204233557 ... 0.15882860128205326 201863.7001401891
Length = 300 rows
Next, we get the shape of one of the flc
image SCI
extensions and make an image from the table of Gaussian sources. Note that this step may take a few minutes. Finally, we run the synthetic image through a Poisson sampler in order to simulate the Poisson noise of the scene.
wfc2 = fits.getdata('jd0q14ctq_flc.fits', ext=1)
shape = wfc2.shape
synth_stars_image = datasets.make_gaussian_sources_image(shape, sources)
synth_stars_image = np.random.poisson(synth_stars_image)
WARNING: AstropyDeprecationWarning: The make_gaussian_sources_image function is deprecated and may be removed in a future version.
Use make_model_image instead. [warnings]
WARNING:astroquery:AstropyDeprecationWarning: The make_gaussian_sources_image function is deprecated and may be removed in a future version.
Use make_model_image instead.
fig, ax = plt.subplots(1, 1, figsize=(9, 4))
ax.imshow(synth_stars_image, vmin=0, vmax=200, interpolation='nearest',
cmap='Greys_r', origin='lower')
ax.plot(sources['x_mean'], sources['y_mean'], marker='o', markersize=10,
markerfacecolor='none', markeredgecolor='red', linestyle='none')
[<matplotlib.lines.Line2D at 0x7f10882adc50>]
Option A: Start with an observed FLC image#
In this Option, we add synthetic stars to the scene in an flc
image and process it appropriately for use with the forward model. We use the flc
image because it is the closest approximation to a pristine image of the sky. Below we plot a portion of the downloaded 47 Tuc image. Stars of various magnitudes are visible, as well as cosmic rays.
flc = fits.getdata('jd0q14ctq_flc.fits', ext=1)
fig, ax = plt.subplots(1, 1, figsize=(9, 4))
ax.imshow(flc, vmin=0, vmax=200, interpolation='nearest', cmap='Greys_r', origin='lower')
ax.set_xlim(2000, 2800)
ax.set_ylim(1200, 1700)
(1200.0, 1700.0)
Top of Page
4A. Add artificial stars#
Add the image of artificial stars generated above to both CCDs of the flc
image, and save it as a new file.
hdu = fits.open('jd0q14ctq_flc.fits')
wfc1 = hdu[4].data
wfc2 = hdu[1].data
wfc1 += synth_stars_image
wfc2 += synth_stars_image
hdu.writeto('jd0q14ctq_stars_flc.fits', overwrite=True)
Below we plot a section of the flc
image with a few artificial stars circled in red.
flc_stars = fits.getdata('jd0q14ctq_stars_flc.fits', ext=1)
fig, ax = plt.subplots(1, 1, figsize=(9, 4))
ax.imshow(flc_stars, vmin=0, vmax=200, interpolation='nearest', cmap='Greys_r',
origin='lower')
ax.plot(sources['x_mean'], sources['y_mean'], marker='o', markersize=20,
markerfacecolor='none', markeredgecolor='red', linestyle='none')
ax.set_xlim(2000, 2800)
ax.set_ylim(1200, 1700)
(1200.0, 1700.0)
Top of Page
5A. Reverse the flat and dark correction#
First, calculate the total exposure time of the 47 Tuc image by combining the exposure time, flash time (if any), and 3 seconds of extra dark time to approximate instrument commanding overheads.
hdu = fits.open('jd0q14ctq_stars_flc.fits')
hdr = hdu[0].header
exptime = hdr['EXPTIME']
flashtime = hdr['FLASHDUR']
darktime = exptime + flashtime + 3
Next, we open the 47 Tuc image and obtain the SCI
extensions of both CCDs. We multiply by the flat and scale the CTE-corrected dark by the total exposure time. We also run the scaled dark image through a Poisson sampler to include Poisson noise in the dark scene. We then add the dark current to the image. We save the result, which is now effectively a blc_tmp
file. If the data are post-flashed, we also need to reverse the flash correction. We do this by multiplying the flash file by the flash duration, running it through a Poisson sampler, and adding it to the 47 Tuc image. The lines for this are commented out below. Note: It is not recommended to use a simulated exposure time that scales pixels in the dark or flash image to or above the full well depth of ~80,000 electrons.
wfc1 = hdu[4].data
wfc2 = hdu[1].data
wfc1 *= flat_wfc1
wfc2 *= flat_wfc2
wfc1 += np.random.poisson(dkc_wfc1*darktime)
wfc2 += np.random.poisson(dkc_wfc2*darktime)
# wfc1 += np.random.poisson(flash_wfc1*flashtime)
# wfc2 += np.random.poisson(flash_wfc2*flashtime)
hdu.writeto('jd0q14ctq_stars_pfl_dkc.fits', overwrite=True)
Finally, we update the header keyword PCTECORR
to PERFORM
, which is necessary for running the forward model.
fits.setval('jd0q14ctq_stars_pfl_dkc.fits', 'PCTECORR', value='PERFORM')
Top of Page
6A. Run CTE forward model#
We are now ready to run the CTE forward model, which simulates the effects of CTE losses while reading out the detector. In this example, we will use the acstools
module acscteforwardmodel
. Note that this step may take a few minutes. The resulting filename will be *_ctefmod.fits
. We rename the file to have the suffix *_blv_tmp.fits
so that it can be processed by CALACS
in a later step.
acscteforwardmodel.acscteforwardmodel('jd0q14ctq_stars_pfl_dkc.fits')
git tag: e0988181-dirty
git branch: HEAD
HEAD @: e098818105734475101120a544dfe468207bc690
Setting max threads to 4 out of 4 available
Trying to open jd0q14ctq_stars_pfl_dkc.fits...
Read in Primary header from jd0q14ctq_stars_pfl_dkc.fits...
CALBEG*** ACSCTE -- Version 10.3.5 (08-Feb-2022) ***
Begin 18-Sep-2024 12:45:16 UTC
Input jd0q14ctq_stars_pfl_dkc.fits
Output jd0q14ctq_stars_pfl_dkc_ctefmod.fits
Trying to open jd0q14ctq_stars_pfl_dkc.fits...
Read in Primary header from jd0q14ctq_stars_pfl_dkc.fits...
APERTURE WFCENTER
FILTER1 F775W
FILTER2 CLEAR2L
DETECTOR WFC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
PCTECORR PERFORM
PCTEFILE jref$19i16323j_cte.fits
PCTEFILE PEDIGREE=INFLIGHT 01/03/2002 22/07/2010
PCTEFILE DESCRIP =Parameters needed for gen2 pixel-based CTE correction -------------
Trying to open jref$19i16323j_cte.fits...
Read in Primary header from jref$19i16323j_cte.fits...
(pctecorr) Generation 2 PCTETAB file auto-detected.
(pctecorr) Reading CTE parameters from PCTETAB file: 'jref$19i16323j_cte.fits'...
Trying to open jref$19i16323j_cte.fits...
Read in Primary header from jref$19i16323j_cte.fits...
CTE_NAME: PixelCTE 2017
CTE_VER: 2.0
CTEDATE0: 52334.9
CTEDATE1: 57710.4
PCTETLEN: 60
PCTERNOI: 4.300000
PCTERNFOR: 5
PCTERNPAR: 7
PCTENSMD: 0
PCTETRSH: -10
FIXROCR: 1
Reading in image from extension 3
Reading in image from extension 4
ERROR: Keyword = `PCTENSMD'.
ERROR: Keyword = `PCTETLEN'.
ERROR: Keyword = `PCTERNOI'.
ERROR: Keyword = `PCTENFOR'.
ERROR: Keyword = `PCTENPAR'.
ERROR: Keyword = `FIXROCR'.
Warning (pctecorr) IGNORING read noise level PCTERNOI from PCTETAB: 4.300000. Using amp dependent values from CCDTAB instead
(pctecorr) Readout simulation forward modeling iterations PCTENFOR: 5
(pctecorr) Number of iterations used in the parallel transfer PCTENPAR: 7
(pctecorr) CTE_FRAC: 0.951805
(pctecorr) PCTETAB read
(pctecorr) Using parallel processing provided by OpenMP inside CTE routine
(pctecorr) Performing CTE correction for amp C
(pctecorr) Read noise level from CCDTAB: 4.050000.
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running forward model simulation...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: -361084.062500 (-0.051082%)
(pctecorr) Performing CTE correction for amp D
(pctecorr) Read noise level from CCDTAB: 5.050000.
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running forward model simulation...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: -415242.812500 (-0.049261%)
(pctecorr) CTE run time for current chip: 119.26(s) with 4 procs/threads
(pctecorr) Using parallel processing provided by OpenMP inside CTE routine
(pctecorr) Performing CTE correction for amp A
(pctecorr) Read noise level from CCDTAB: 4.350000.
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running forward model simulation...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: -282239.406250 (-0.048701%)
(pctecorr) Performing CTE correction for amp B
(pctecorr) Read noise level from CCDTAB: 3.750000.
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running forward model simulation...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: -455608.531250 (-0.040255%)
(pctecorr) CTE run time for current chip: 133.42(s) with 4 procs/threads
PCTECORR COMPLETE
End 18-Sep-2024 12:49:31 UTC
*** ACSCTE complete ***
os.rename('jd0q14ctq_stars_pfl_dkc_ctefmod.fits', 'jd0q14ctq_stars_ctefmod_blv_tmp.fits')
After the forward model is run, the SCI
extensions of the image are equivalent to a blv_tmp
file, in principle. However, the ERR
extensions are the original flc
ERR
extensions plus 10% of the forward model correction. To ensure the ERR
extensions are accurate for a blv_tmp
file, we will set every pixel to zero and calculate new values for each pixel according to
\(\mathrm{ERR} = \sqrt{\mathrm{SCI} + \mathrm{RN}^2 + (\mathrm{ERR}_{\mathrm{superbias}}g)^2}\),
where \(\mathrm{SCI}\) is the pixel value in the SCI
extension (all negative pixels are set to zero), \(\mathrm{RN}\) is the readnoise, \(\mathrm{ERR}_{\mathrm{superbias}}\) is the pixel value in the ERR
extension of the superbias, and \(g\) is the gain.
First, we access the header and SCI
and ERR
extensions of the forward-modeled data.
hdu = fits.open('jd0q14ctq_stars_ctefmod_blv_tmp.fits')
sci_wfc1 = hdu[4].data
sci_wfc2 = hdu[1].data
err_wfc1 = hdu[5].data
err_wfc2 = hdu[2].data
hdr = hdu[0].header
Next, we take the readnoise and gain values for each quadrant from the header.
rn_A = hdr['READNSEA']
rn_B = hdr['READNSEB']
rn_C = hdr['READNSEC']
rn_D = hdr['READNSED']
gain_A = hdr['ATODGNA']
gain_B = hdr['ATODGNB']
gain_C = hdr['ATODGNC']
gain_D = hdr['ATODGND']
Finally, we make copies of the SCI
extensions in which to set all negative values to zero. We calculate the appropriate error for each quadrant and save them to the ERR
extensions of the forward-modeled image.
sci_wfc1_pos = np.copy(sci_wfc1)
sci_wfc2_pos = np.copy(sci_wfc2)
sci_wfc1_pos[sci_wfc1_pos < 0] = 0
sci_wfc2_pos[sci_wfc2_pos < 0] = 0
err_A = np.sqrt(sci_wfc1_pos[:, :2048] + rn_A**2 + (err_bias_wfc1[20:, 24:2072]*gain_A)**2)
err_B = np.sqrt(sci_wfc1_pos[:, 2048:] + rn_B**2 + (err_bias_wfc1[20:, 2072:-24]*gain_B)**2)
err_C = np.sqrt(sci_wfc2_pos[:, :2048] + rn_C**2 + (err_bias_wfc2[:-20, 24:2072]*gain_C)**2)
err_D = np.sqrt(sci_wfc2_pos[:, 2048:] + rn_D**2 + (err_bias_wfc2[:-20, 2072:-24]*gain_D)**2)
err_wfc1[:] = np.hstack((err_A, err_B))
err_wfc2[:] = np.hstack((err_C, err_D))
hdu.writeto('jd0q14ctq_stars_ctefmod_blv_tmp.fits', overwrite=True)
Top of Page
(Optional) 7A. Run CTE correction#
If desired, we now CTE correct the forward-modeled image. To do this, we need to update the PCTECORR
keyword to PERFORM
again and update the NEXTEND
keyword to 6, the number of extensions left after running the forward model. (This is because the forward model strips the distortion-related extensions from the input file, but does not update NEXTEND
.) Finally, run acscte
on the image. The resulting filename will be *_blc_tmp.fits
.
fits.setval('jd0q14ctq_stars_ctefmod_blv_tmp.fits', 'PCTECORR', value='PERFORM')
fits.setval('jd0q14ctq_stars_ctefmod_blv_tmp.fits', 'NEXTEND', value=6)
acscte.acscte('jd0q14ctq_stars_ctefmod_blv_tmp.fits')
git tag: e0988181-dirty
git branch: HEAD
HEAD @: e098818105734475101120a544dfe468207bc690
Setting max threads to 4 out of 4 available
Trying to open jd0q14ctq_stars_ctefmod_blv_tmp.fits...
Read in Primary header from jd0q14ctq_stars_ctefmod_blv_tmp.fits...
CALBEG*** ACSCTE -- Version 10.3.5 (08-Feb-2022) ***
Begin 18-Sep-2024 12:49:31 UTC
Input jd0q14ctq_stars_ctefmod_blv_tmp.fits
Output jd0q14ctq_stars_ctefmod_blc_tmp.fits
Trying to open jd0q14ctq_stars_ctefmod_blv_tmp.fits...
Read in Primary header from jd0q14ctq_stars_ctefmod_blv_tmp.fits...
APERTURE WFCENTER
FILTER1 F775W
FILTER2 CLEAR2L
DETECTOR WFC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
PCTECORR PERFORM
PCTEFILE jref$19i16323j_cte.fits
PCTEFILE PEDIGREE=INFLIGHT 01/03/2002 22/07/2010
PCTEFILE DESCRIP =Parameters needed for gen2 pixel-based CTE correction -------------
Trying to open jref$19i16323j_cte.fits...
Read in Primary header from jref$19i16323j_cte.fits...
(pctecorr) Generation 2 PCTETAB file auto-detected.
(pctecorr) Reading CTE parameters from PCTETAB file: 'jref$19i16323j_cte.fits'...
Trying to open jref$19i16323j_cte.fits...
Read in Primary header from jref$19i16323j_cte.fits...
CTE_NAME: PixelCTE 2017
CTE_VER: 2.0
CTEDATE0: 52334.9
CTEDATE1: 57710.4
PCTETLEN: 60
PCTERNOI: 4.300000
PCTERNFOR: 5
PCTERNPAR: 7
PCTENSMD: 0
PCTETRSH: -10
FIXROCR: 1
Reading in image from extension 3
Reading in image from extension 4
ERROR: Keyword = `PCTENSMD'.
ERROR: Keyword = `PCTETLEN'.
ERROR: Keyword = `PCTERNOI'.
ERROR: Keyword = `PCTENFOR'.
ERROR: Keyword = `PCTENPAR'.
ERROR: Keyword = `FIXROCR'.
Warning (pctecorr) IGNORING read noise level PCTERNOI from PCTETAB: 4.300000. Using amp dependent values from CCDTAB instead
(pctecorr) Readout simulation forward modeling iterations PCTENFOR: 5
(pctecorr) Number of iterations used in the parallel transfer PCTENPAR: 7
(pctecorr) CTE_FRAC: 0.951805
(pctecorr) PCTETAB read
(pctecorr) Using parallel processing provided by OpenMP inside CTE routine
(pctecorr) Performing CTE correction for amp C
(pctecorr) Read noise level from CCDTAB: 4.050000.
(pctecorr) Calculating smooth readnoise image...
(pctecorr) Time taken to smooth image: 2.34(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running correction algorithm...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: 354790.875000 (0.050222%)
(pctecorr) Performing CTE correction for amp D
(pctecorr) Read noise level from CCDTAB: 5.050000.
(pctecorr) Calculating smooth readnoise image...
(pctecorr) Time taken to smooth image: 2.11(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running correction algorithm...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: 408042.625000 (0.048432%)
(pctecorr) CTE run time for current chip: 607.54(s) with 4 procs/threads
(pctecorr) Using parallel processing provided by OpenMP inside CTE routine
(pctecorr) Performing CTE correction for amp A
(pctecorr) Read noise level from CCDTAB: 4.350000.
(pctecorr) Calculating smooth readnoise image...
(pctecorr) Time taken to smooth image: 2.12(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running correction algorithm...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: 275780.281250 (0.047613%)
(pctecorr) Performing CTE correction for amp B
(pctecorr) Read noise level from CCDTAB: 3.750000.
(pctecorr) Calculating smooth readnoise image...
(pctecorr) Time taken to smooth image: 2.34(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running correction algorithm...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: 460929.281250 (0.040738%)
(pctecorr) CTE run time for current chip: 676.65(s) with 4 procs/threads
PCTECORR COMPLETE
End 18-Sep-2024 13:11:00 UTC
*** ACSCTE complete ***
8A. Apply flat and dark correction#
Finally, we flat-field and dark-correct the forward-modeled image using acs2d
to produce an flt
-like image. First, we update the keywords DARKCORR
and FLATCORR
to PERFORM
. All other relevant CALACS
header keyword switches are set to COMPLETE
because the original data was an flc
image. The resulting filename will be *_flt.fits
. Note: If the data were post-flashed, and the flash background was added back in during an earlier step, we must also set FLSHCORR
equal to PERFORM
. This option is shown below in a commented out line.
fits.setval('jd0q14ctq_stars_ctefmod_blv_tmp.fits', 'DARKCORR', value='PERFORM')
fits.setval('jd0q14ctq_stars_ctefmod_blv_tmp.fits', 'FLATCORR', value='PERFORM')
# fits.setval('jd0q14ctq_stars_ctefmod_blv_tmp.fits', 'FLSHCORR', value='PERFORM')
acs2d.acs2d('jd0q14ctq_stars_ctefmod_blv_tmp.fits')
git tag: e0988181-dirty
git branch: HEAD
HEAD @: e098818105734475101120a544dfe468207bc690
Trying to open jd0q14ctq_stars_ctefmod_blv_tmp.fits...
Read in Primary header from jd0q14ctq_stars_ctefmod_blv_tmp.fits...
CALBEG*** ACS2D -- Version 10.3.5 (08-Feb-2022) ***
Begin 18-Sep-2024 13:11:00 UTC
Input jd0q14ctq_stars_ctefmod_blv_tmp.fits
Output jd0q14ctq_stars_ctefmod_flt.fits
Trying to open jd0q14ctq_stars_ctefmod_blv_tmp.fits...
Read in Primary header from jd0q14ctq_stars_ctefmod_blv_tmp.fits...
APERTURE WFCENTER
FILTER1 F775W
FILTER2 CLEAR2L
DETECTOR WFC
Imset 1 Begin 13:11:00 UTC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
DQICORR OMIT
DARKCORR PERFORM
DARKFILE jref$78f18443j_drk.fits
DARKFILE PEDIGREE=INFLIGHT 12/02/2016 09/03/2016
DARKFILE DESCRIP =Standard full-frame dark for data taken after Feb 11 2016 08:10:42-
Darktime from header 342.239197
Mean of dark image (MEANDARK) = 4.06977
DARKCORR COMPLETE
FLSHCORR OMIT
FLATCORR PERFORM
PFLTFILE jref$qb12257oj_pfl.fits
PFLTFILE PEDIGREE=INFLIGHT 18/04/2002 - 04/07/2006
PFLTFILE DESCRIP =Flats: P(Lab)*L(Flight)*delta(-81K,ISR06-06). UNCONFIRMED FWOFFSET
FLATCORR COMPLETE
SHADCORR OMIT
PHOTCORR OMIT
Imset 1 End 13:11:00 UTC
Imset 2 Begin 13:11:00 UTC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
DQICORR OMIT
DARKCORR PERFORM
Darktime from header 342.239197
Mean of dark image (MEANDARK) = 4.16998
DARKCORR COMPLETE
FLSHCORR OMIT
FLATCORR PERFORM
FLATCORR COMPLETE
SHADCORR OMIT
PHOTCORR OMIT
Imset 2 End 13:11:01 UTC
End 18-Sep-2024 13:11:01 UTC
*** ACS2D complete ***
If the forward-modeled image was CTE-corrected in Step 7A, we run acs2d
on the CTE-corrected image. The resulting filename will be *_flc.fits
.
fits.setval('jd0q14ctq_stars_ctefmod_blc_tmp.fits', 'DARKCORR', value='PERFORM')
fits.setval('jd0q14ctq_stars_ctefmod_blc_tmp.fits', 'FLATCORR', value='PERFORM')
# fits.setval('jd0q14ctq_stars_ctefmod_blv_tmp.fits', 'FLSHCORR', value='PERFORM')
acs2d.acs2d('jd0q14ctq_stars_ctefmod_blc_tmp.fits')
git tag: e0988181-dirty
git branch: HEAD
HEAD @: e098818105734475101120a544dfe468207bc690
Trying to open jd0q14ctq_stars_ctefmod_blc_tmp.fits...
Read in Primary header from jd0q14ctq_stars_ctefmod_blc_tmp.fits...
CALBEG*** ACS2D -- Version 10.3.5 (08-Feb-2022) ***
Begin 18-Sep-2024 13:11:01 UTC
Input jd0q14ctq_stars_ctefmod_blc_tmp.fits
Output jd0q14ctq_stars_ctefmod_flc.fits
Trying to open jd0q14ctq_stars_ctefmod_blc_tmp.fits...
Read in Primary header from jd0q14ctq_stars_ctefmod_blc_tmp.fits...
APERTURE WFCENTER
FILTER1 F775W
FILTER2 CLEAR2L
DETECTOR WFC
Imset 1 Begin 13:11:01 UTC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
DQICORR OMIT
DARKCORR PERFORM
DARKFILE jref$78g0300bj_dkc.fits
DARKFILE PEDIGREE=INFLIGHT 12/02/2016 09/03/2016
DARKFILE DESCRIP =CTE corrected dark for WFC data taken after Feb 11 2016 08:10:42---
Darktime from header 342.239197
Mean of dark image (MEANDARK) = 3.36636
DARKCORR COMPLETE
FLSHCORR OMIT
FLATCORR PERFORM
PFLTFILE jref$qb12257oj_pfl.fits
PFLTFILE PEDIGREE=INFLIGHT 18/04/2002 - 04/07/2006
PFLTFILE DESCRIP =Flats: P(Lab)*L(Flight)*delta(-81K,ISR06-06). UNCONFIRMED FWOFFSET
FLATCORR COMPLETE
SHADCORR OMIT
PHOTCORR OMIT
Imset 1 End 13:11:01 UTC
Imset 2 Begin 13:11:01 UTC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
DQICORR OMIT
DARKCORR PERFORM
Darktime from header 342.239197
Mean of dark image (MEANDARK) = 3.4793
DARKCORR COMPLETE
FLSHCORR OMIT
FLATCORR PERFORM
FLATCORR COMPLETE
SHADCORR OMIT
PHOTCORR OMIT
Imset 2 End 13:11:01 UTC
End 18-Sep-2024 13:11:01 UTC
*** ACS2D complete ***
The 47 Tuc image(s) are now prepared for further analysis appropriate for the user’s science. The cells below plot a portion of the final images, the flt
and, if produced, the flc
.
flt_stars = fits.getdata('jd0q14ctq_stars_ctefmod_flt.fits', ext=1)
fig, ax = plt.subplots(1, 1, figsize=(9, 4))
ax.imshow(flt_stars, vmin=0, vmax=200, interpolation='nearest', cmap='Greys_r',
origin='lower')
ax.plot(sources['x_mean'], sources['y_mean'], marker='o', markersize=20,
markerfacecolor='none', markeredgecolor='red', linestyle='none')
ax.set_xlim(2000, 2800)
ax.set_ylim(1200, 1700)
(1200.0, 1700.0)
flc_stars = fits.getdata('jd0q14ctq_stars_ctefmod_flc.fits', ext=1)
fig, ax = plt.subplots(1, 1, figsize=(9, 4))
ax.imshow(flc_stars, vmin=0, vmax=200, interpolation='nearest', cmap='Greys_r',
origin='lower')
ax.plot(sources['x_mean'], sources['y_mean'], marker='o', markersize=20,
markerfacecolor='none', markeredgecolor='red', linestyle='none')
ax.set_xlim(2000, 2800)
ax.set_ylim(1200, 1700)
(1200.0, 1700.0)
Top of Page
Option B: Start with a synthetic image#
In this Option, we start with the raw
file from the jd0q14ctq
dataset and process the SCI
extensions to make a completely synthetic dataset. We then process it appropriately for use in the forward model.
4B. Create a synthetic image#
We will create an image that is equivalent to a blc_tmp
file. This means that the image is not flat-fielded and includes sky background, Poisson noise from the sky, artificial stars or other sources, Poisson noise from the sources, dark current, and dark noise.
We first process the data with acsccd
within acstools
to create a blv_tmp
. This ensures that the error (ERR
) and data quality (DQ
) extensions are created and the header keywords for every extension are initially populated, which is necessary for the CTE forward model to run.
acsccd.acsccd('jd0q14ctq_raw.fits')
git tag: e0988181-dirty
git branch: HEAD
HEAD @: e098818105734475101120a544dfe468207bc690
Trying to open jd0q14ctq_raw.fits...
Read in Primary header from jd0q14ctq_raw.fits...
CALBEG*** ACSCCD -- Version 10.3.5 (08-Feb-2022) ***
Begin 18-Sep-2024 13:11:02 UTC
Input jd0q14ctq_raw.fits
Output jd0q14ctq_blv_tmp.fits
Trying to open jd0q14ctq_raw.fits...
Read in Primary header from jd0q14ctq_raw.fits...
APERTURE WFCENTER
FILTER1 F775W
FILTER2 CLEAR2L
DETECTOR WFC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
DQICORR PERFORM
DQITAB jref$25g1256nj_bpx.fits
DQITAB PEDIGREE=INFLIGHT 30/03/2002 30/05/2002
DQITAB DESCRIP =FITS reference table for bad pixel locations on ACS WFC
DQICORR COMPLETE
BIASCORR PERFORM
BIASFILE jref$66418280j_bia.fits
BIASFILE PEDIGREE=INFLIGHT 12/02/2016 09/03/2016
BIASFILE DESCRIP =Standard full-frame bias for data taken after Feb 11 2016 08:10:42-
BIASCORR COMPLETE
BLEVCORR PERFORM
OSCNTAB jref$17717071j_osc.fits
OSCNTAB PEDIGREE=GROUND
OSCNTAB DESCRIP =New OSCNTAB which includes entries for all subarrays.--------------
BLEVCORR PERFORM
Performing bias-shift and cross talk corrections for full frame data.
BLEVCORR PERFORM
Bias shift correcting for bias level in Amp A of 4217.9877 electrons.
Bias shift correcting for bias level in Amp A of 4217.9877 electrons.
Bias shift correcting for bias level in Amp B of 4025.7480 electrons.
Bias shift correcting for bias level in Amp B of 4025.7480 electrons.
Bias shift correcting for bias level in Amp C of 4437.9683 electrons.
Bias shift correcting for bias level in Amp C of 4437.9683 electrons.
Bias shift correcting for bias level in Amp D of 4624.3633 electrons.
Performing stripe removal and bias level subtraction for full frame data.
Bias shift correcting for bias level in Amp D of 4624.3633 electrons.
Bias shift correcting for bias level in Amp D of 4624.3633 electrons.
Bias shift correcting for bias level in Amp D of 4624.3633 electrons.
Bias shift correcting for bias level in Amp D of 4624.3633 electrons.
bias level of 0.561443 electrons was subtracted for AMP A.
bias level of -0.0598474 electrons was subtracted for AMP B.
bias level of -0.32127 electrons was subtracted for AMP C.
bias level of 0.5666 electrons was subtracted for AMP D.
BLEVCORR COMPLETE
Full Frame adjusted Darktime: 342.239197
DARKTIME from SCI header: 342.239197 Offset from CCDTAB: 0.000000 Final DARKTIME: 342.239197
Full-well saturation flagging being performed for imset 1.
Full-frame full-well saturation image flagging step being performed.
Full-frame full-well saturation image flagging step done.
Full-well saturation flagging being performed for imset 2.
Full-frame full-well saturation image flagging step being performed.
Full-frame full-well saturation image flagging step done.
Uncertainty array initialized,
readnoise =4.35,3.75,4.05,5.05
gain =2.02,1.886,2.017,2.011
default bias levels =4242,4060.6,4481.8,4645.4
SINKCORR PERFORM
SNKCFILE jref$25e1534hj_snk.fits
SNKCFILE PEDIGREE=INFLIGHT 12/02/2016 09/03/2016
SNKCFILE DESCRIP =Sink pixel reference file ----------------------------
SINKCORR COMPLETE
End 18-Sep-2024 13:11:03 UTC
*** ACSCCD complete ***
Next, we obtain the SCI
extensions from the blv_tmp
file, and set the pixels to zero.
hdu = fits.open('jd0q14ctq_blv_tmp.fits')
wfc1 = hdu[4].data
wfc2 = hdu[1].data
wfc1[:] = np.zeros(shape)
wfc2[:] = np.zeros(shape)
We then generate an image containing a user-selected sky background level (here we choose 40 electrons arbitrarily) and Poisson noise. Finally, we sum the noise image and the artificial star image, and save the result as a new file.
noise_image = datasets.make_noise_image(shape, distribution='poisson', mean=40, seed=12345)
wfc1 += noise_image + synth_stars_image
wfc2 += noise_image + synth_stars_image
hdu.writeto('synth.fits', overwrite=True)
Below we plot a portion of the synthetic image, with sources circled in red.
synth = fits.getdata('synth.fits', ext=1)
fig, ax = plt.subplots(1, 1, figsize=(9, 4))
ax.imshow(synth, vmin=0, vmax=200, interpolation='nearest', cmap='Greys_r',
origin='lower')
ax.plot(sources['x_mean'], sources['y_mean'], marker='o', markersize=20,
markerfacecolor='none', markeredgecolor='red', linestyle='none')
ax.set_xlim(2000, 2800)
ax.set_ylim(1200, 1700)
(1200.0, 1700.0)
In order to properly remove the dark current after the forward model is run, we update the exposure time and flash duration header keywords, EXPTIME
and FLASHDUR
, with the desired simulated exposure time. The total exposure time used for the dark correction is the combination of exposure time, flash duration, and overhead (which depends on whether the data are post-flashed or not). Here we set EXPTIME
to 300 seconds and FLASHDUR
to 0 seconds. In principle one should retrieve the overheads from CCDTAB, but we provide a simpler approach here. Please note that the overhead times may change.
exptime = 300.
flashdur = 0.
hdu = fits.open('synth.fits')
hdr = hdu[0].header
hdr['EXPTIME'] = exptime
hdr['FLASHDUR'] = flashdur
if flashdur > 0:
overhead = 2.43
else:
overhead = 0.21
darktime = exptime + flashdur + overhead
We need to update the FITS header with the correct dark time for use in a later step. However, we leave off the overhead, because ACSCCD (run in a later step) will automatically append the overhead to the dark time in the header. We still use the darktime variable with overhead to manually add the dark current to our model below.
hdr['DARKTIME'] = darktime - overhead
Next, obtain the SCI
extensions of both CCDs. We then multiply by the flat and scale the CTE-corrected dark by a chosen exposure time. We also run the scaled dark image through a Poisson sampler to include Poisson noise in the dark scene. We then add the dark current to the image. If post-flash is desired, multiply the flash reference file by the flash duration, run it through a Poisson sampler, and add to the synthetic data. This is shown in the commented out lines below. We save the result, which is now effectively a blc_tmp
file. Note: It is not recommended to use a simulated exposure time that scales pixels in the dark or flash image to or above the full well depth of ~80,000 electrons.
Note that these reference files are specific to the anneal cycle in which these data were taken. If an observation date other than that listed in the DATE-OBS
header keyword is desired for the synthetic data, different reference files will be needed. These can be found by updating the DATE-OBS
header keyword in the synthetic image to the desired observation date, and rerunning the cell in Step 2 which uses CRDS bestrefs
to download the correct reference files.
wfc1 = hdu[4].data
wfc2 = hdu[1].data
wfc1 *= flat_wfc1
wfc2 *= flat_wfc2
wfc1 += np.random.poisson(dkc_wfc1*darktime)
wfc2 += np.random.poisson(dkc_wfc2*darktime)
# wfc1 += np.random.poisson(flash_wfc1*flashdur)
# wfc2 += np.random.poisson(flash_wfc2*flashdur)
hdu.writeto('synth_blc_tmp.fits', overwrite=True)
Top of Page
5B. Run CTE forward model#
We are now ready to run the CTE forward model, which simulates the effects of CTE losses while reading out the detector. In this example, we will use the acstools
module acscteforwardmodel
. Note that this step may take a few minutes. The resulting filename will be *_ctefmod.fits
. We rename this to *_blv_tmp.fits
in order to ensure the correct behavior from acs2d
in a later step.
acscteforwardmodel.acscteforwardmodel('synth_blc_tmp.fits')
os.rename('synth_blc_tmp_ctefmod.fits', 'synth_ctefmod_blv_tmp.fits')
git tag: e0988181-dirty
git branch: HEAD
HEAD @: e098818105734475101120a544dfe468207bc690
Setting max threads to 4 out of 4 available
Trying to open synth_blc_tmp.fits...
Read in Primary header from synth_blc_tmp.fits...
CALBEG*** ACSCTE -- Version 10.3.5 (08-Feb-2022) ***
Begin 18-Sep-2024 13:11:05 UTC
Input synth_blc_tmp.fits
Output synth_blc_tmp_ctefmod.fits
Trying to open synth_blc_tmp.fits...
Read in Primary header from synth_blc_tmp.fits...
APERTURE WFCENTER
FILTER1 F775W
FILTER2 CLEAR2L
DETECTOR WFC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
PCTECORR PERFORM
PCTEFILE jref$19i16323j_cte.fits
PCTEFILE PEDIGREE=INFLIGHT 01/03/2002 22/07/2010
PCTEFILE DESCRIP =Parameters needed for gen2 pixel-based CTE correction -------------
Trying to open jref$19i16323j_cte.fits...
Read in Primary header from jref$19i16323j_cte.fits...
(pctecorr) Generation 2 PCTETAB file auto-detected.
(pctecorr) Reading CTE parameters from PCTETAB file: 'jref$19i16323j_cte.fits'...
Trying to open jref$19i16323j_cte.fits...
Read in Primary header from jref$19i16323j_cte.fits...
CTE_NAME: PixelCTE 2017
CTE_VER: 2.0
CTEDATE0: 52334.9
CTEDATE1: 57710.4
PCTETLEN: 60
PCTERNOI: 4.300000
PCTERNFOR: 5
PCTERNPAR: 7
PCTENSMD: 0
PCTETRSH: -10
FIXROCR: 1
Reading in image from extension 3
Reading in image from extension 4
ERROR: Keyword = `PCTENSMD'.
ERROR: Keyword = `PCTETLEN'.
ERROR: Keyword = `PCTERNOI'.
ERROR: Keyword = `PCTENFOR'.
ERROR: Keyword = `PCTENPAR'.
ERROR: Keyword = `FIXROCR'.
Warning (pctecorr) IGNORING read noise level PCTERNOI from PCTETAB: 4.300000. Using amp dependent values from CCDTAB instead
(pctecorr) Readout simulation forward modeling iterations PCTENFOR: 5
(pctecorr) Number of iterations used in the parallel transfer PCTENPAR: 7
(pctecorr) CTE_FRAC: 0.951805
(pctecorr) PCTETAB read
(pctecorr) Using parallel processing provided by OpenMP inside CTE routine
(pctecorr) Performing CTE correction for amp C
(pctecorr) Read noise level from CCDTAB: 4.050000.
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running forward model simulation...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: -300674.750000 (-0.135812%)
(pctecorr) Performing CTE correction for amp D
(pctecorr) Read noise level from CCDTAB: 5.050000.
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running forward model simulation...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: -313220.500000 (-0.135211%)
(pctecorr) CTE run time for current chip: 51.72(s) with 4 procs/threads
(pctecorr) Using parallel processing provided by OpenMP inside CTE routine
(pctecorr) Performing CTE correction for amp A
(pctecorr) Read noise level from CCDTAB: 4.350000.
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running forward model simulation...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: -301690.843750 (-0.142740%)
(pctecorr) Performing CTE correction for amp B
(pctecorr) Read noise level from CCDTAB: 3.750000.
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running forward model simulation...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: -312444.875000 (-0.138763%)
(pctecorr) CTE run time for current chip: 51.54(s) with 4 procs/threads
PCTECORR COMPLETE
End 18-Sep-2024 13:12:49 UTC
*** ACSCTE complete ***
At this point, we also add readnoise to the forward-modeled SCI
extensions to complete the readout simulation. We find the readnoise values for each quadrant of the image from the header keywords READNSEA
, READNSEB
, etc. We make a noise image for each quadrant, concatenate quadrants A and B and quadrants C and D, and add them to the synthetic image.
rn_A = hdr['READNSEA']
rn_B = hdr['READNSEB']
rn_C = hdr['READNSEC']
rn_D = hdr['READNSED']
img_rn_A = datasets.make_noise_image((shape[0], int(shape[1]/2)), distribution='gaussian',
mean=0., stddev=rn_A)
img_rn_B = datasets.make_noise_image((shape[0], int(shape[1]/2)), distribution='gaussian',
mean=0., stddev=rn_B)
img_rn_C = datasets.make_noise_image((shape[0], int(shape[1]/2)), distribution='gaussian',
mean=0., stddev=rn_C)
img_rn_D = datasets.make_noise_image((shape[0], int(shape[1]/2)), distribution='gaussian',
mean=0., stddev=rn_D)
wfc1_rn = np.hstack((img_rn_A, img_rn_B))
wfc2_rn = np.hstack((img_rn_C, img_rn_D))
hdu = fits.open('synth_ctefmod_blv_tmp.fits')
wfc1 = hdu[4].data
wfc2 = hdu[1].data
wfc1 += wfc1_rn
wfc2 += wfc2_rn
hdu.writeto('synth_ctefmod_rn_blv_tmp.fits', overwrite=True)
The SCI
extensions of this image are now equivalent to a blv_tmp
file, in principle. However, the ERR
extensions are the original blv_tmp
ERR
extensions plus 10% of the forward model correction. To ensure the ERR
extensions are accurate, we will calculate new values for each pixel according to
\(\mathrm{ERR} = \sqrt{\mathrm{SCI} + \mathrm{RN}^2 + (\mathrm{ERR}_{\mathrm{superbias}}g)^2}\),
where \(\mathrm{SCI}\) is the pixel value in the SCI
extension (all negative pixels are set to zero), \(\mathrm{RN}\) is the readnoise, \(\mathrm{ERR}_{\mathrm{superbias}}\) is the pixel value in the ERR
extension of the superbias, and \(g\) is the gain.
First, we access the header and SCI
and ERR
extensions of the forward-modeled data.
hdu = fits.open('synth_ctefmod_rn_blv_tmp.fits')
sci_wfc1 = hdu[4].data
sci_wfc2 = hdu[1].data
err_wfc1 = hdu[5].data
err_wfc2 = hdu[2].data
hdr = hdu[0].header
Next, we take the readnoise and gain values for each quadrant from the header.
rn_A = hdr['READNSEA']
rn_B = hdr['READNSEB']
rn_C = hdr['READNSEC']
rn_D = hdr['READNSED']
gain_A = hdr['ATODGNA']
gain_B = hdr['ATODGNB']
gain_C = hdr['ATODGNC']
gain_D = hdr['ATODGND']
Finally, we make copies of the SCI
extensions in which to set all negative values to zero. We calculate the appropriate error for each quadrant and save them to the ERR
extensions of the forward-modeled image.
sci_wfc1_pos = np.copy(sci_wfc1)
sci_wfc2_pos = np.copy(sci_wfc2)
sci_wfc1_pos[sci_wfc1_pos < 0] = 0
sci_wfc2_pos[sci_wfc2_pos < 0] = 0
# The superbias ERR arrays contain 20 rows of virtual overscan at the edge of
# each CCD furthest from the amplifier and 24 columns of physical prescan on the
# left and right edges.
err_A = np.sqrt(sci_wfc1_pos[:, :2048] + rn_A**2 + (err_bias_wfc1[20:, 24:2072]*gain_A)**2)
err_B = np.sqrt(sci_wfc1_pos[:, 2048:] + rn_B**2 + (err_bias_wfc1[20:, 2072:-24]*gain_B)**2)
err_C = np.sqrt(sci_wfc2_pos[:, :2048] + rn_C**2 + (err_bias_wfc2[:-20, 24:2072]*gain_C)**2)
err_D = np.sqrt(sci_wfc2_pos[:, 2048:] + rn_D**2 + (err_bias_wfc2[:-20, 2072:-24]*gain_D)**2)
err_wfc1[:] = np.hstack((err_A, err_B))
err_wfc2[:] = np.hstack((err_C, err_D))
hdu.writeto('synth_ctefmod_rn_blv_tmp.fits', overwrite=True)
We also repopulate the DQ extensions because they reflect the processing of the original blv_tmp
SCI
extensions. To do this, we reprocess the data with DQICORR
and SINKCORR
, both within acsccd
, and add in the DQ extensions of the appropriate superbias file. First, we rename the synthetic image to have a filename *_raw.fits
, or acsccd
will fail. Then, we update the DQICORR
and SINKCORR
header keywords to PERFORM
and run acsccd
. The output will be *_blv_tmp.fits
again.
This step will also add the proper overhead to DARKTIME
header keyword, but only if using CALACS v10.3.3 or later. We first check the version.
os.system('calacs.e --version')
10.3.5 (08-Feb-2022)
0
If your version of CALCACS is prior to v10.3.3, please update. Now let’s run ACSCCD.
os.rename('synth_ctefmod_rn_blv_tmp.fits', 'synth_ctefmod_rn_raw.fits')
fits.setval('synth_ctefmod_rn_raw.fits', 'DQICORR', value='PERFORM')
fits.setval('synth_ctefmod_rn_raw.fits', 'SINKCORR', value='PERFORM')
acsccd.acsccd('synth_ctefmod_rn_raw.fits')
git tag: e0988181-dirty
git branch: HEAD
HEAD @: e098818105734475101120a544dfe468207bc690
Trying to open synth_ctefmod_rn_raw.fits...
Read in Primary header from synth_ctefmod_rn_raw.fits...
CALBEG*** ACSCCD -- Version 10.3.5 (08-Feb-2022) ***
Begin 18-Sep-2024 13:12:50 UTC
Input synth_ctefmod_rn_raw.fits
Output synth_ctefmod_rn_blv_tmp.fits
Trying to open synth_ctefmod_rn_raw.fits...
Read in Primary header from synth_ctefmod_rn_raw.fits...
APERTURE WFCENTER
FILTER1 F775W
FILTER2 CLEAR2L
DETECTOR WFC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
Warning Could not find appropriate row from OSCNTAB.
Warning Could not find appropriate row from OSCNTAB.
DQICORR PERFORM
DQITAB jref$25g1256nj_bpx.fits
DQITAB PEDIGREE=INFLIGHT 30/03/2002 30/05/2002
DQITAB DESCRIP =FITS reference table for bad pixel locations on ACS WFC
DQICORR COMPLETE
BIASCORR OMIT
BIASCORR COMPLETE
BLEVCORR OMIT
Full Frame adjusted Darktime: 300.000000
DARKTIME from SCI header: 300.000000 Offset from CCDTAB: 0.000000 Final DARKTIME: 300.000000
Warning
No Full-well saturation flagging being performed for imset 1.
Warning
No Full-well saturation flagging being performed for imset 2.
Uncertainty array initialized,
readnoise =4.35,3.75,4.05,5.05
gain =2.02,1.886,2.017,2.011
default bias levels =4242,4060.6,4481.8,4645.4
SINKCORR PERFORM
SNKCFILE jref$25e1534hj_snk.fits
SNKCFILE PEDIGREE=INFLIGHT 12/02/2016 09/03/2016
SNKCFILE DESCRIP =Sink pixel reference file ----------------------------
SINKCORR COMPLETE
End 18-Sep-2024 13:12:50 UTC
*** ACSCCD complete ***
Next, obtain the DQ extensions of the superbias file, and add them to the new DQ extensions of the synthetic data with a bitwise_or
operator.
hdu = fits.open('synth_ctefmod_rn_blv_tmp.fits')
dq_wfc1 = hdu[6].data
dq_wfc2 = hdu[3].data
dq_wfc1[:] = np.bitwise_or(dq_wfc1, dq_bias_wfc1[20:, 24:-24])
dq_wfc2[:] = np.bitwise_or(dq_wfc2, dq_bias_wfc2[:-20, 24:-24])
Also, acsccd assumes the input image is in DN and converts it to counts by multiplying by the gain. We defined our model in electrons though, so the acsccd conversion to electrons was unnecessary. We divide by the gains to fix this and replace the image.
sci_wfc1 = hdu[4].data
sci_wfc2 = hdu[1].data
sci_wfc1[:, :2048] /= gain_A
sci_wfc1[:, 2048:] /= gain_B
sci_wfc2[:, :2048] /= gain_C
sci_wfc2[:, 2048:] /= gain_D
err_wfc1 = hdu[5].data
err_wfc2 = hdu[2].data
err_wfc1[:, :2048] /= gain_A
err_wfc1[:, 2048:] /= gain_B
err_wfc2[:, :2048] /= gain_C
err_wfc2[:, 2048:] /= gain_D
hdu.writeto('synth_ctefmod_rn_blv_tmp.fits', overwrite=True)
Top of Page
6B. (Optional) Run CTE correction#
If desired, we now CTE correct the forward-modeled image. To do this, we need to update the PCTECORR
keyword to PERFORM
again, and run acscte
on the image. The resulting filename will be *_blc_tmp.fits
.
fits.setval('synth_ctefmod_rn_blv_tmp.fits', 'PCTECORR', value='PERFORM')
acscte.acscte('synth_ctefmod_rn_blv_tmp.fits')
git tag: e0988181-dirty
git branch: HEAD
HEAD @: e098818105734475101120a544dfe468207bc690
Setting max threads to 4 out of 4 available
Trying to open synth_ctefmod_rn_blv_tmp.fits...
Read in Primary header from synth_ctefmod_rn_blv_tmp.fits...
CALBEG*** ACSCTE -- Version 10.3.5 (08-Feb-2022) ***
Begin 18-Sep-2024 13:12:51 UTC
Input synth_ctefmod_rn_blv_tmp.fits
Output synth_ctefmod_rn_blc_tmp.fits
Trying to open synth_ctefmod_rn_blv_tmp.fits...
Read in Primary header from synth_ctefmod_rn_blv_tmp.fits...
APERTURE WFCENTER
FILTER1 F775W
FILTER2 CLEAR2L
DETECTOR WFC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
PCTECORR PERFORM
PCTEFILE jref$19i16323j_cte.fits
PCTEFILE PEDIGREE=INFLIGHT 01/03/2002 22/07/2010
PCTEFILE DESCRIP =Parameters needed for gen2 pixel-based CTE correction -------------
Trying to open jref$19i16323j_cte.fits...
Read in Primary header from jref$19i16323j_cte.fits...
(pctecorr) Generation 2 PCTETAB file auto-detected.
(pctecorr) Reading CTE parameters from PCTETAB file: 'jref$19i16323j_cte.fits'...
Trying to open jref$19i16323j_cte.fits...
Read in Primary header from jref$19i16323j_cte.fits...
CTE_NAME: PixelCTE 2017
CTE_VER: 2.0
CTEDATE0: 52334.9
CTEDATE1: 57710.4
PCTETLEN: 60
PCTERNOI: 4.300000
PCTERNFOR: 5
PCTERNPAR: 7
PCTENSMD: 0
PCTETRSH: -10
FIXROCR: 1
Reading in image from extension 3
Reading in image from extension 4
ERROR: Keyword = `PCTENSMD'.
ERROR: Keyword = `PCTETLEN'.
ERROR: Keyword = `PCTERNOI'.
ERROR: Keyword = `PCTENFOR'.
ERROR: Keyword = `PCTENPAR'.
ERROR: Keyword = `FIXROCR'.
Warning (pctecorr) IGNORING read noise level PCTERNOI from PCTETAB: 4.300000. Using amp dependent values from CCDTAB instead
(pctecorr) Readout simulation forward modeling iterations PCTENFOR: 5
(pctecorr) Number of iterations used in the parallel transfer PCTENPAR: 7
(pctecorr) CTE_FRAC: 0.951805
(pctecorr) PCTETAB read
(pctecorr) Using parallel processing provided by OpenMP inside CTE routine
(pctecorr) Performing CTE correction for amp C
(pctecorr) Read noise level from CCDTAB: 4.050000.
(pctecorr) Calculating smooth readnoise image...
(pctecorr) Time taken to smooth image: 1.96(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running correction algorithm...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: 294427.093750 (0.133176%)
(pctecorr) Performing CTE correction for amp D
(pctecorr) Read noise level from CCDTAB: 5.050000.
(pctecorr) Calculating smooth readnoise image...
(pctecorr) Time taken to smooth image: 1.66(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running correction algorithm...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: 306225.500000 (0.132374%)
(pctecorr) CTE run time for current chip: 257.90(s) with 4 procs/threads
(pctecorr) Using parallel processing provided by OpenMP inside CTE routine
(pctecorr) Performing CTE correction for amp A
(pctecorr) Read noise level from CCDTAB: 4.350000.
(pctecorr) Calculating smooth readnoise image...
(pctecorr) Time taken to smooth image: 1.72(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running correction algorithm...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: 294814.937500 (0.139701%)
(pctecorr) Performing CTE correction for amp B
(pctecorr) Read noise level from CCDTAB: 3.750000.
(pctecorr) Calculating smooth readnoise image...
(pctecorr) Time taken to smooth image: 1.77(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Creating charge trap image...
(pctecorr) Time taken to populate pixel trap map image: 0.01(s) with 4 threads
(pctecorr) ...complete.
(pctecorr) Running correction algorithm...
(pctecorr) ...complete.
(pctecorr) Total count difference (corrected-raw) incurred from correction: 306765.843750 (0.136422%)
(pctecorr) CTE run time for current chip: 259.85(s) with 4 procs/threads
PCTECORR COMPLETE
End 18-Sep-2024 13:21:31 UTC
*** ACSCTE complete ***
7B. Apply flat and dark correction#
Finally, we flat-field and dark-correct the forward-modeled image using acs2d
to produce an flt
-like image. We first ensure that the DARKCORR
, FLATCORR
, and if necessary, FLSHCORR
header keywords are set to PERFORM
. The resulting filename will be *_flt.fits
.
fits.setval('synth_ctefmod_rn_blv_tmp.fits', 'DARKCORR', value='PERFORM')
fits.setval('synth_ctefmod_rn_blv_tmp.fits', 'FLATCORR', value='PERFORM')
# fits.setval('synth_ctefmod_rn_blv_tmp.fits', 'FLSHCORR', value='PERFORM')
acs2d.acs2d('synth_ctefmod_rn_blv_tmp.fits')
git tag: e0988181-dirty
git branch: HEAD
HEAD @: e098818105734475101120a544dfe468207bc690
Trying to open synth_ctefmod_rn_blv_tmp.fits...
Read in Primary header from synth_ctefmod_rn_blv_tmp.fits...
CALBEG*** ACS2D -- Version 10.3.5 (08-Feb-2022) ***
Begin 18-Sep-2024 13:21:31 UTC
Input synth_ctefmod_rn_blv_tmp.fits
Output synth_ctefmod_rn_flt.fits
Trying to open synth_ctefmod_rn_blv_tmp.fits...
Read in Primary header from synth_ctefmod_rn_blv_tmp.fits...
APERTURE WFCENTER
FILTER1 F775W
FILTER2 CLEAR2L
DETECTOR WFC
Imset 1 Begin 13:21:31 UTC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
DQICORR OMIT
DARKCORR PERFORM
DARKFILE jref$78f18443j_drk.fits
DARKFILE PEDIGREE=INFLIGHT 12/02/2016 09/03/2016
DARKFILE DESCRIP =Standard full-frame dark for data taken after Feb 11 2016 08:10:42-
Darktime from header 300.000000
Mean of dark image (MEANDARK) = 3.56748
DARKCORR COMPLETE
FLSHCORR OMIT
FLATCORR PERFORM
PFLTFILE jref$qb12257oj_pfl.fits
PFLTFILE PEDIGREE=INFLIGHT 18/04/2002 - 04/07/2006
PFLTFILE DESCRIP =Flats: P(Lab)*L(Flight)*delta(-81K,ISR06-06). UNCONFIRMED FWOFFSET
FLATCORR COMPLETE
SHADCORR OMIT
PHOTCORR PERFORM
Found parameterized variable 1.
NUMPAR=1, N=1
Allocated 1 parnames
Adding parameter mjd#57451.3694 as parnames[0]
==> Value of PHOTFLAM = 1.0033185e-19
==> Value of PHOTPLAM = 7693.4699
==> Value of PHOTBW = 434.53752
IMPHTTAB jref$4af1559ij_imp.fits
IMPHTTAB PEDIGREE=INFLIGHT 18/04/2000 29/09/2020
IMPHTTAB DESCRIP =photometry keywords reference file---------------------------------
PHOTCORR COMPLETE
Imset 1 End 13:21:31 UTC
Imset 2 Begin 13:21:31 UTC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
DQICORR OMIT
DARKCORR PERFORM
Darktime from header 300.000000
Mean of dark image (MEANDARK) = 3.65532
DARKCORR COMPLETE
FLSHCORR OMIT
FLATCORR PERFORM
FLATCORR COMPLETE
SHADCORR OMIT
PHOTCORR PERFORM
Found parameterized variable 1.
NUMPAR=1, N=1
Allocated 1 parnames
Adding parameter mjd#57451.3694 as parnames[0]
==> Value of PHOTFLAM = 1.0033185e-19
==> Value of PHOTPLAM = 7693.4699
==> Value of PHOTBW = 434.53752
IMPHTTAB jref$4af1559ij_imp.fits
IMPHTTAB PEDIGREE=INFLIGHT 18/04/2000 29/09/2020
IMPHTTAB DESCRIP =photometry keywords reference file---------------------------------
PHOTCORR COMPLETE
Imset 2 End 13:21:31 UTC
End 18-Sep-2024 13:21:31 UTC
*** ACS2D complete ***
If the forward-modeled image was CTE-corrected in Step 6, we run acs2d
on the CTE-corrected image. The resulting filename will be *_flc.fits
.
fits.setval('synth_ctefmod_rn_blc_tmp.fits', 'DARKCORR', value='PERFORM')
fits.setval('synth_ctefmod_rn_blc_tmp.fits', 'FLATCORR', value='PERFORM')
# fits.setval('synth_ctefmod_rn_blc_tmp.fits', 'FLSHCORR', value='PERFORM')
acs2d.acs2d('synth_ctefmod_rn_blc_tmp.fits')
git tag: e0988181-dirty
git branch: HEAD
HEAD @: e098818105734475101120a544dfe468207bc690
Trying to open synth_ctefmod_rn_blc_tmp.fits...
Read in Primary header from synth_ctefmod_rn_blc_tmp.fits...
CALBEG*** ACS2D -- Version 10.3.5 (08-Feb-2022) ***
Begin 18-Sep-2024 13:21:31 UTC
Input synth_ctefmod_rn_blc_tmp.fits
Output synth_ctefmod_rn_flc.fits
Trying to open synth_ctefmod_rn_blc_tmp.fits...
Read in Primary header from synth_ctefmod_rn_blc_tmp.fits...
APERTURE WFCENTER
FILTER1 F775W
FILTER2 CLEAR2L
DETECTOR WFC
Imset 1 Begin 13:21:31 UTC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
DQICORR OMIT
DARKCORR PERFORM
DARKFILE jref$78g0300bj_dkc.fits
DARKFILE PEDIGREE=INFLIGHT 12/02/2016 09/03/2016
DARKFILE DESCRIP =CTE corrected dark for WFC data taken after Feb 11 2016 08:10:42---
Darktime from header 300.000000
Mean of dark image (MEANDARK) = 2.95088
DARKCORR COMPLETE
FLSHCORR OMIT
FLATCORR PERFORM
PFLTFILE jref$qb12257oj_pfl.fits
PFLTFILE PEDIGREE=INFLIGHT 18/04/2002 - 04/07/2006
PFLTFILE DESCRIP =Flats: P(Lab)*L(Flight)*delta(-81K,ISR06-06). UNCONFIRMED FWOFFSET
FLATCORR COMPLETE
SHADCORR OMIT
PHOTCORR PERFORM
Found parameterized variable 1.
NUMPAR=1, N=1
Allocated 1 parnames
Adding parameter mjd#57451.3694 as parnames[0]
==> Value of PHOTFLAM = 1.0033185e-19
==> Value of PHOTPLAM = 7693.4699
==> Value of PHOTBW = 434.53752
IMPHTTAB jref$4af1559ij_imp.fits
IMPHTTAB PEDIGREE=INFLIGHT 18/04/2000 29/09/2020
IMPHTTAB DESCRIP =photometry keywords reference file---------------------------------
PHOTCORR COMPLETE
Imset 1 End 13:21:32 UTC
Imset 2 Begin 13:21:32 UTC
CCDTAB jref$72m1821dj_ccd.fits
CCDTAB PEDIGREE=inflight
CCDTAB DESCRIP =CCD table with updated readnoise values for CCDGAIN=2.-------------
CCDTAB DESCRIP =July 2009
DQICORR OMIT
DARKCORR PERFORM
Darktime from header 300.000000
Mean of dark image (MEANDARK) = 3.04988
DARKCORR COMPLETE
FLSHCORR OMIT
FLATCORR PERFORM
FLATCORR COMPLETE
SHADCORR OMIT
PHOTCORR PERFORM
Found parameterized variable 1.
NUMPAR=1, N=1
Allocated 1 parnames
Adding parameter mjd#57451.3694 as parnames[0]
==> Value of PHOTFLAM = 1.0033185e-19
==> Value of PHOTPLAM = 7693.4699
==> Value of PHOTBW = 434.53752
IMPHTTAB jref$4af1559ij_imp.fits
IMPHTTAB PEDIGREE=INFLIGHT 18/04/2000 29/09/2020
IMPHTTAB DESCRIP =photometry keywords reference file---------------------------------
PHOTCORR COMPLETE
Imset 2 End 13:21:32 UTC
End 18-Sep-2024 13:21:32 UTC
*** ACS2D complete ***
The image(s) are now prepared for further analysis appropriate for the user’s science. The cells below plot a portion of the final images, the flt
and, if produced, the flc
.
synth_ctefmod = fits.getdata('synth_ctefmod_rn_flt.fits', ext=1)
fig, ax = plt.subplots(1, 1, figsize=(9, 4))
ax.imshow(synth_ctefmod, vmin=0, vmax=200, interpolation='nearest', cmap='Greys_r',
origin='lower')
ax.plot(sources['x_mean'], sources['y_mean'], marker='o', markersize=20,
markerfacecolor='none', markeredgecolor='red', linestyle='none')
ax.set_xlim(2000, 2800)
ax.set_ylim(1200, 1700)
(1200.0, 1700.0)
synth_ctefmod_flc = fits.getdata('synth_ctefmod_rn_flc.fits', ext=1)
fig, ax = plt.subplots(1, 1, figsize=(9, 4))
ax.imshow(synth_ctefmod_flc, vmin=0, vmax=200, interpolation='nearest', cmap='Greys_r',
origin='lower')
ax.plot(sources['x_mean'], sources['y_mean'], marker='o', markersize=20,
markerfacecolor='none', markeredgecolor='red', linestyle='none')
ax.set_xlim(2000, 2800)
ax.set_ylim(1200, 1700)
(1200.0, 1700.0)
For more help:#
More details may be found on the ACS website and in the ACS Instrument and Data Handbooks.
Please visit the HST Help Desk. Through the help desk portal, you can explore the HST Knowledge Base and request additional help from experts.
About this Notebook#
Author: Jenna Ryon, ACS Instrument Team
Updated On: 04/21/2022