Sky Matching for HST Mosaics #


This notebook assumes you have created and activated a virtual environment using the requirements file in this notebook's repository. Please make sure you have read the contents of the README file before continuing the notebook. Note that the GIF file "sky_matching_comparison.gif" is one of the downloads needed for this notebook:

Learning Goals:#

In this tutorial we explore different options for handling the background sky with AstroDrizzle.
By the end of this notebook you will:
    • Download data with astroquery
    • Align data with TweakReg
    • Compare background sky options using the AstroDrizzle parameter skymethod

Table of Contents#

Introduction

1. Download the Observations with astroquery
    1.1 Check image header data
    1.2 Inspect the alignment
2. Align the visit-level drizzled data with TweakReg
    2.1 Create a catalog of Gaia DR3 sources
    2.2 Create a catalog of Gaia DR3 sources with Proper Motion Data
    2.3 Run Tweakreg
    2.4 Inspect the shift file and fit quality
    2.5 Overplot matched sources and inspect fit residuals
    2.6 Rerun TweakReg and update the header WCS
    2.7 Run TweakBack to propogate the WCS to the FLT files
3. Compare skymethod options in AstroDrizzle
    3.1 skymethod = 'localmin'
    3.2 skymethod = 'match'
    3.3 skymethod = 'globalmin+match'
    3.4 skymethod = 'globalmin'
4. Compare the MDRIZSKY values for each method
5. Display the ‘sky matched’ science mosaic and weight image
6. Conclusion

Additional Resources
About this notebook
Citations

Introduction #

When creating an image mosaic, AstroDrizzle has the ability to compute the sky and then either subtract or equalize the background in input images. Users may select the algorithm used for the sky subtraction via the skymethod parameter.

There are four methods available in sky matching: localmin, match, globalmin, and globalmin+match.

By applying drizzlepac.sky.sky(), or using the skymethod parameter in the call to drizzlepac.astrodrizzle.AstroDrizzle(), AstroDrizzle will update the keyword MDRIZSKY in the headers of the input files but it will not change the science data.

For images of sparse fields with few astronomical sources, the default skymethod = 'localmin' may be used, although this method can slightly oversubtract the background. For images with complicated backgrounds, such as nebulae and large host galaxies, skymethod = 'match' is recommended.

For more information on the specifics of this function, please refer to the documentation here

Below, each of the four methods is demonstrated using a single example dataset, and differences between the methods is highlighted.

# All imports needed through out this notebook are included at the beginning. 
%matplotlib inline
%config InlineBackend.figure_format = 'retina'

from collections import defaultdict
from IPython.display import clear_output 
import glob
import os
import shutil 
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import pandas

from astropy.coordinates import SkyCoord
from astropy.io import ascii, fits
from astropy.table import Table
from astropy.units import Quantity
import astropy.units as u
from astroquery.gaia import Gaia
from astroquery.mast import Observations
from drizzlepac import astrodrizzle, tweakback, tweakreg 
from drizzlepac.haputils.astrometric_utils import create_astrometric_catalog


Gaia.MAIN_GAIA_TABLE = 'gaiadr3.gaia_source'   # Change if different data release is desired
Gaia.ROW_LIMIT = 100000

The following task in the stsci.skypac package can be run with TEAL:
                                    skymatch                                    
The following tasks in the drizzlepac package can be run with TEAL:
    astrodrizzle       config_testbed      imagefindpars           mapreg       
       photeq            pixreplace           pixtopix            pixtosky      
  refimagefindpars       resetbits          runastrodriz          skytopix      
     tweakback            tweakreg           updatenpol

1. Download the Observations with astroquery #

MAST queries may be done using query_criteria, where we specify:

    –> obs_id, proposal_id, and filters

MAST data products may be downloaded by using download_products, where we specify:

    –> products = calibrated (FLT, FLC) or drizzled (DRZ, DRC) files

    –> type = standard products (CALxxx) or advanced products (HAP-SVM)


WFC3/IR observations of the Horsehead Nebula in the F160W filter obtained in HST proposal program 12812 will be used for this demonstration.

Nine visits were acquired in a 3x3 mosaic pattern on the sky, with two dither positions per visit in two IR filters. High level science products for these datasets were delivered to MAST in 2013, and this notebook is based on that user tutorial but has been updated to align these data to Gaia.

The 18 FLT images ibxl5*_flt.fits have been processed by the HST WFC3 pipeline (calwf3), which includes bias subtraction, dark current correction, cosmic-ray rejection, and flatfielding. The 9 DRZ files ibxl5*_drz.fits have been processed with AstroDrizzle to remove distortion and to combine the 2 dithered FLT frames by filter for each vist.

THIS IS A LARGE DOWNLOAD (~400 MB). Depending on your connection speed, the next cell may take a few minutes to execute.
obs_ids = ['ibxl5*']
props = ['12812']
filts = ['F160W']

obsTable = Observations.query_criteria(obs_id=obs_ids, proposal_id=props, filters=filts)
products = Observations.get_product_list(obsTable)

data_prod = ['FLT', 'DRZ']     # ['FLC','FLT','DRC','DRZ']                  
data_type = ['CALWF3']         # ['CALACS','CALWF3','CALWP2','HAP-SVM']    

Observations.download_products(products, download_dir='./science',
                               productSubGroupDescription=data_prod, 
                               project=data_type)
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl50030_drz.fits to ./science/mastDownload/HST/ibxl50030/ibxl50030_drz.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl50clq_flt.fits to ./science/mastDownload/HST/ibxl50clq/ibxl50clq_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl50cqq_flt.fits to ./science/mastDownload/HST/ibxl50cqq/ibxl50cqq_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl51030_drz.fits to ./science/mastDownload/HST/ibxl51030/ibxl51030_drz.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl51eoq_flt.fits to ./science/mastDownload/HST/ibxl51eoq/ibxl51eoq_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl51etq_flt.fits to ./science/mastDownload/HST/ibxl51etq/ibxl51etq_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl52030_drz.fits to ./science/mastDownload/HST/ibxl52030/ibxl52030_drz.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl52k0q_flt.fits to ./science/mastDownload/HST/ibxl52k0q/ibxl52k0q_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl52k5q_flt.fits to ./science/mastDownload/HST/ibxl52k5q/ibxl52k5q_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl53030_drz.fits to ./science/mastDownload/HST/ibxl53030/ibxl53030_drz.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl53kxq_flt.fits to ./science/mastDownload/HST/ibxl53kxq/ibxl53kxq_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl53l9q_flt.fits to ./science/mastDownload/HST/ibxl53l9q/ibxl53l9q_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl54030_drz.fits to ./science/mastDownload/HST/ibxl54030/ibxl54030_drz.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl54bgq_flt.fits to ./science/mastDownload/HST/ibxl54bgq/ibxl54bgq_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl54blq_flt.fits to ./science/mastDownload/HST/ibxl54blq/ibxl54blq_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl55030_drz.fits to ./science/mastDownload/HST/ibxl55030/ibxl55030_drz.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl55f0q_flt.fits to ./science/mastDownload/HST/ibxl55f0q/ibxl55f0q_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl55f5q_flt.fits to ./science/mastDownload/HST/ibxl55f5q/ibxl55f5q_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl56030_drz.fits to ./science/mastDownload/HST/ibxl56030/ibxl56030_drz.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl56huq_flt.fits to ./science/mastDownload/HST/ibxl56huq/ibxl56huq_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl56i2q_flt.fits to ./science/mastDownload/HST/ibxl56i2q/ibxl56i2q_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl57030_drz.fits to ./science/mastDownload/HST/ibxl57030/ibxl57030_drz.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl57adq_flt.fits to ./science/mastDownload/HST/ibxl57adq/ibxl57adq_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl57aiq_flt.fits to ./science/mastDownload/HST/ibxl57aiq/ibxl57aiq_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl58030_drz.fits to ./science/mastDownload/HST/ibxl58030/ibxl58030_drz.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl58sqq_flt.fits to ./science/mastDownload/HST/ibxl58sqq/ibxl58sqq_flt.fits ...
 [Done]
Downloading URL https://mast.stsci.edu/api/v0.1/Download/file?uri=mast:HST/product/ibxl58svq_flt.fits to ./science/mastDownload/HST/ibxl58svq/ibxl58svq_flt.fits ...
 [Done]
Table length=27
Local PathStatusMessageURL
str55str8objectobject
./science/mastDownload/HST/ibxl50030/ibxl50030_drz.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl50clq/ibxl50clq_flt.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl50cqq/ibxl50cqq_flt.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl51030/ibxl51030_drz.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl51eoq/ibxl51eoq_flt.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl51etq/ibxl51etq_flt.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl52030/ibxl52030_drz.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl52k0q/ibxl52k0q_flt.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl52k5q/ibxl52k5q_flt.fitsCOMPLETENoneNone
............
./science/mastDownload/HST/ibxl55f5q/ibxl55f5q_flt.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl56030/ibxl56030_drz.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl56huq/ibxl56huq_flt.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl56i2q/ibxl56i2q_flt.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl57030/ibxl57030_drz.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl57adq/ibxl57adq_flt.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl57aiq/ibxl57aiq_flt.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl58030/ibxl58030_drz.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl58sqq/ibxl58sqq_flt.fitsCOMPLETENoneNone
./science/mastDownload/HST/ibxl58svq/ibxl58svq_flt.fitsCOMPLETENoneNone

Move the files to the local working directory

files = glob.glob(os.path.join(os.curdir, 'science', 'mastDownload', 'HST', '*', '*fits'))
for im in files:
    root = os.path.basename(im)
    os.rename(im, './' + root)
    
if os.path.exists('./science'):
    shutil.rmtree('science/')

1.1 Check image header data #

Here we will look at important keywords in the image headers.

files = sorted(glob.glob('*fl?.fits'))
keywords_ext0 = ["ROOTNAME", "ASN_ID", "TARGNAME", "DETECTOR", "FILTER", "EXPTIME", 
                 "RA_TARG", "DEC_TARG", "POSTARG1", "POSTARG2", "DATE-OBS"]
keywords_ext1 = ["ORIENTAT"]
data = []

for file in files:
    path_data = []
    for keyword in keywords_ext0:
        path_data.append(fits.getval(file, keyword, ext=0))
    for keyword in keywords_ext1:
        path_data.append(fits.getval(file, keyword, ext=1))
    data.append(path_data)
    
keywords = keywords_ext0 + keywords_ext1
table = Table(np.array(data), names=keywords, dtype=['str', 'str', 'str', 'str', 'str', 'f8', 'f8', 'f8', 'f8', 'f8', 'str', 'f8'])
table['EXPTIME'].format = '7.1f' 
table['RA_TARG'].format = table['DEC_TARG'].format = '7.4f'
table['POSTARG1'].format = table['POSTARG2'].format = '7.3f' 
table['ORIENTAT'].format = '7.2f'
table.show_in_notebook()
Table length=18
idxROOTNAMEASN_IDTARGNAMEDETECTORFILTEREXPTIMERA_TARGDEC_TARGPOSTARG1POSTARG2DATE-OBSORIENTAT
0ibxl50clqIBXL50030HORSEHEAD-COPYIRF160W702.985.2545-2.4530-123.742-113.1122012-11-03170.64
1ibxl50cqqIBXL50030HORSEHEAD-COPYIRF160W702.985.2545-2.4530-123.742-105.9122012-11-03170.64
2ibxl51eoqIBXL51030HORSEHEAD-COPYIRF160W702.985.2545-2.45300.000-113.1122012-10-22166.65
3ibxl51etqIBXL51030HORSEHEAD-COPYIRF160W702.985.2545-2.45300.000-105.9122012-10-22166.65
4ibxl52k0qIBXL52030HORSEHEAD-COPYIRF160W702.985.2545-2.4530123.742-113.1122012-10-23166.65
5ibxl52k5qIBXL52030HORSEHEAD-COPYIRF160W702.985.2545-2.4530123.742-105.9122012-10-23166.66
6ibxl53kxqIBXL53030HORSEHEAD-COPYIRF160W702.985.2545-2.4530-123.742-3.6002012-10-23165.65
7ibxl53l9qIBXL53030HORSEHEAD-COPYIRF160W702.985.2545-2.4530-123.7423.6002012-10-24165.65
8ibxl54bgqIBXL54030HORSEHEAD-COPYIRF160W702.985.2545-2.45300.000-3.6002012-10-26166.63
9ibxl54blqIBXL54030HORSEHEAD-COPYIRF160W702.985.2545-2.45300.0003.6002012-10-26166.62
10ibxl55f0qIBXL55030HORSEHEAD-COPYIRF160W702.985.2545-2.4530123.742-3.6002012-10-27166.64
11ibxl55f5qIBXL55030HORSEHEAD-COPYIRF160W702.985.2545-2.4530123.7423.6002012-10-27166.64
12ibxl56huqIBXL56030HORSEHEAD-COPYIRF160W702.985.2545-2.4530-123.742105.9122012-10-27162.65
13ibxl56i2qIBXL56030HORSEHEAD-COPYIRF160W702.985.2545-2.4530-123.742113.1122012-10-28162.64
14ibxl57adqIBXL57030HORSEHEAD-COPYIRF160W702.985.2545-2.45300.000105.9122012-11-05166.64
15ibxl57aiqIBXL57030HORSEHEAD-COPYIRF160W702.985.2545-2.45300.000113.1122012-11-05166.64
16ibxl58sqqIBXL58030HORSEHEAD-COPYIRF160W702.985.2545-2.4530123.742105.9122012-11-07166.65
17ibxl58svqIBXL58030HORSEHEAD-COPYIRF160W702.985.2545-2.4530123.742113.1122012-11-07166.65

1.2 Inspect the Alignment #

Check the active WCS solution in the image header. If the image is aligned to a catalog, list the number of matches and the fit RMS in mas.
Convert the fit RMS values to pixels for comparison with the alignment results performed later in this notebook.

ext_0_kws = ['DETECTOR']
ext_1_kws = ['WCSNAME', 'NMATCHES', 'RMS_RA', 'RMS_DEC']

det_scale = {'IR': 0.1283, 'UVIS': 0.0396, 'WFC': 0.05}                  # plate scale (arcsec/pixel)

format_dict = {}
col_dict = defaultdict(list)

for f in sorted(glob.glob('*dr?.fits')):
    col_dict['FILENAME'].append(f)
    hdr0 = fits.getheader(f, 0)
    hdr1 = fits.getheader(f, 1)
    
    for kw in ext_0_kws:                                                # extension 0 keywords
        col_dict[kw].append(hdr0[kw])
    for kw in ext_1_kws:                                                # extension 1 keywords
        if 'RMS' in kw:
            val = np.around(hdr1[kw], 1)
        else: 
            val = hdr1[kw]
        col_dict[kw].append(val)
        
    for kw in ['RMS_RA', 'RMS_DEC']:
        val = np.round(hdr1[kw]/1000./det_scale[hdr0['DETECTOR']], 2)  # convert RMS from mas to pixels
        col_dict[f'{kw}_pix'].append(val)

wcstable = Table(col_dict)
wcstable.show_in_notebook()
Table length=9
idxFILENAMEDETECTORWCSNAMENMATCHESRMS_RARMS_DECRMS_RA_pixRMS_DEC_pix
0ibxl50030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR385.410.40.040.08
1ibxl51030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR31113.58.20.110.06
2ibxl52030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR3823.519.30.180.15
3ibxl53030_drz.fitsIRIDC_w3m18525i-FIT_REL_GSC2421464.787.60.50.68
4ibxl54030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR3726.023.90.20.19
5ibxl55030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR3109.87.90.080.06
6ibxl56030_drz.fitsIRIDC_w3m18525i-FIT_REL_GSC2421865.493.30.510.73
7ibxl57030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR3128.48.20.070.06
8ibxl58030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR31535.536.70.280.29
Note that there are different WCS solutions for each visit, with Gaia eDR3 as the reference catalog for all but two which were fit to GSC v2.4.2 and which have a much larger fit rms values (>0.5 pixels). Since the WCS solutions are inconsistent for this target, we wish to realign the data to use a common reference catalog.

2. Align the visit-level drizzled data with TweakReg #

Here we will use TweakReg to align the DRZ files to Gaia DR3 and then use TweakBack to propagate those solutions back to the FLT image headers prior to combining with AstroDrizzle.

2.1 Create a catalog of Gaia DR3 sources #

This method uses the RA/Dec of the first image and a radius of 5’.

RA = table['RA_TARG'][0]
Dec = table['DEC_TARG'][0]

coord = SkyCoord(ra=RA, dec=Dec, unit=(u.deg, u.deg))
radius = Quantity(5., u.arcmin)

gaia_query = Gaia.query_object_async(coordinate=coord, radius=radius)
gaia_query
INFO: Query finished. [astroquery.utils.tap.core]
Table length=183
solution_idDESIGNATIONSOURCE_IDrandom_indexref_epochrara_errordecdec_errorparallaxparallax_errorparallax_over_errorpmpmrapmra_errorpmdecpmdec_errorra_dec_corrra_parallax_corrra_pmra_corrra_pmdec_corrdec_parallax_corrdec_pmra_corrdec_pmdec_corrparallax_pmra_corrparallax_pmdec_corrpmra_pmdec_corrastrometric_n_obs_alastrometric_n_obs_acastrometric_n_good_obs_alastrometric_n_bad_obs_alastrometric_gof_alastrometric_chi2_alastrometric_excess_noiseastrometric_excess_noise_sigastrometric_params_solvedastrometric_primary_flagnu_eff_used_in_astrometrypseudocolourpseudocolour_errorra_pseudocolour_corrdec_pseudocolour_corrparallax_pseudocolour_corrpmra_pseudocolour_corrpmdec_pseudocolour_corrastrometric_matched_transitsvisibility_periods_usedastrometric_sigma5d_maxmatched_transitsnew_matched_transitsmatched_transits_removedipd_gof_harmonic_amplitudeipd_gof_harmonic_phaseipd_frac_multi_peakipd_frac_odd_winruwescan_direction_strength_k1scan_direction_strength_k2scan_direction_strength_k3scan_direction_strength_k4scan_direction_mean_k1scan_direction_mean_k2scan_direction_mean_k3scan_direction_mean_k4duplicated_sourcephot_g_n_obsphot_g_mean_fluxphot_g_mean_flux_errorphot_g_mean_flux_over_errorphot_g_mean_magphot_bp_n_obsphot_bp_mean_fluxphot_bp_mean_flux_errorphot_bp_mean_flux_over_errorphot_bp_mean_magphot_rp_n_obsphot_rp_mean_fluxphot_rp_mean_flux_errorphot_rp_mean_flux_over_errorphot_rp_mean_magphot_bp_rp_excess_factorphot_bp_n_contaminated_transitsphot_bp_n_blended_transitsphot_rp_n_contaminated_transitsphot_rp_n_blended_transitsphot_proc_modebp_rpbp_gg_rpradial_velocityradial_velocity_errorrv_method_usedrv_nb_transitsrv_nb_deblended_transitsrv_visibility_periods_usedrv_expected_sig_to_noiserv_renormalised_gofrv_chisq_pvaluerv_time_durationrv_amplitude_robustrv_template_teffrv_template_loggrv_template_fe_hrv_atm_param_originvbroadvbroad_errorvbroad_nb_transitsgrvs_maggrvs_mag_errorgrvs_mag_nb_transitsrvs_spec_sig_to_noisephot_variable_flaglbecl_lonecl_latin_qso_candidatesin_galaxy_candidatesnon_single_starhas_xp_continuoushas_xp_sampledhas_rvshas_epoch_photometryhas_epoch_rvhas_mcmc_gspphothas_mcmc_mscin_andromeda_surveyclassprob_dsc_combmod_quasarclassprob_dsc_combmod_galaxyclassprob_dsc_combmod_starteff_gspphotteff_gspphot_lowerteff_gspphot_upperlogg_gspphotlogg_gspphot_lowerlogg_gspphot_uppermh_gspphotmh_gspphot_lowermh_gspphot_upperdistance_gspphotdistance_gspphot_lowerdistance_gspphot_upperazero_gspphotazero_gspphot_lowerazero_gspphot_upperag_gspphotag_gspphot_lowerag_gspphot_upperebpminrp_gspphotebpminrp_gspphot_lowerebpminrp_gspphot_upperlibname_gspphotdist
yrdegmasdegmasmasmasmas / yrmas / yrmas / yrmas / yrmas / yrmas1 / um1 / um1 / ummasdegdegdegdegdegelectron / selectron / smagelectron / selectron / smagelectron / selectron / smagmagmagmagkm / skm / sdkm / sKlog(cm.s**-2)dexkm / skm / smagmagdegdegdegdegKKKlog(cm.s**-2)log(cm.s**-2)log(cm.s**-2)dexdexdexpcpcpcmagmagmagmagmagmagmagmagmag
int64objectint64int64float64float64float32float64float32float64float32float32float32float64float32float64float32float32float32float32float32float32float32float32float32float32float32int16int16int16int16float32float32float32float32int16boolfloat32float32float32float32float32float32float32float32int16int16float32int16int16int16float32float32int16int16float32float32float32float32float32float32float32float32float32boolint16float64float32float32float32int16float64float32float32float32int16float64float32float32float32float32int16int16int16int16int16float32float32float32float32float32int16int16int16int16float32float32float32float32float32float32float32float32int16float32float32int16float32float32int16float32objectfloat64float64float64float64boolboolint16boolboolboolboolboolboolboolboolfloat32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32float32objectfloat64
1636148068921376768Gaia DR3 321646905341885849632164690534188584963680248052016.085.250782068747380.34748474-2.4442576210375410.318497450.94953368149541540.416418672.28023827.7956214-0.83023805996094970.431424267.7512850213897710.36127582-0.0723629150.0020754219-0.351860280.1278402-0.269704580.15042841-0.61647550.100072740.19517034-0.149899357035701.8443948436.1331.38491332.20871795False--1.2338760.08958775-0.17215662-0.06320628-0.05079003-0.12549370.0890731841210.63760585422600.0154789575.244358001.06944240.201291560.246633250.26718260.5048746-80.303276-2.1296542-22.792238-43.76734False354218.899266513017040.7818137279.9890419.8367562844.184869469083395.249698.41666221.22535936308.895272785115611.35645227.1999818.5233671.61298020302.7019921.38860321.3133888--------------------------------------------NOT_AVAILABLE206.94547931488657-16.7643418791580584.72852258013162-25.79667536635267FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse1.7621454e-135.111382e-130.99999774------------------------------------------0.009486679186673242
1636148068921376768Gaia DR3 321646905771452608032164690577145260801605629942016.085.248658589215030.0807162-2.4413545846161360.074135330.247024292334559720.095515642.58621841.387560.73127387423655840.099508561.17922060682770420.08531875-0.09268238-0.016587587-0.353307720.15432145-0.250574350.17109188-0.6492080.116244580.24781711-0.127371238903872-1.0886481412.404570.00.095False--1.26429880.020441843-0.14009616-0.078366740.0031425122-0.107817010.0972707345210.1476955462900.0217760782.3582678000.95995960.192185760.26565980.223006260.48614076-98.501114-2.7790413-25.351597-43.091904False3851533.79647103622191.6690606918.9579517.72294845414.87985435657187.522979755.14834218.793736441747.716707973625711.556245151.2356916.6417181.4099631010102.15201761.07078741.0812302--------------------------------------------NOT_AVAILABLE206.94176557869633-16.76487499185271484.72628577778967-25.793696653062412FalseFalse0FalseFalseFalseFalseFalseTrueTrueFalse1.2362927e-136.260371e-130.99999276097.9175930.60456142.0944.52264.50094.5768-3.9361-4.0965-3.6061919.4193833.37948.08483.62233.53153.65152.74072.66192.76441.54551.50141.5587MARCS0.013011650487557274
1636148068921376768Gaia DR3 321646785512368601632164678551236860166687102222016.085.254744170639190.07255654-2.4700840906080950.067638071.7059943087771960.0927493918.3935913.672125-3.1816816541393630.08841129-13.2967625165468950.07709159-0.128096130.08502215-0.30733430.19231312-0.377120170.17119895-0.663743850.030204790.40648898-0.117953785376037604.4143248528.089840.393147084.882766231False1.3003229--------------43210.13255168452600.02708889714.045337021.16541050.223880980.30778120.253453880.42603984-72.65342-1.7500962-25.84865-41.594986False3682476.0276502430424.3828444564.936217.20297840585.778038160845111.73194549.93017218.41921362981.2363041460724.774414120.3352916.0619051.4406197040302.35730551.21623231.1410732--------------------------------------------NOT_AVAILABLE206.9712942044114-16.77281162967581884.73186766212942-25.822629314586116FalseFalse0TrueFalseFalseFalseFalseFalseTrueFalse1.1540595e-131.3798553e-090.99998775968.22955923.57285995.964.62754.5894.6636-4.0538-4.1164-3.7235542.7187531.214555.8374.05024.02314.0693.00962.98753.02381.70221.68971.7104MARCS0.017083879996516314
1636148068921376768Gaia DR3 321646901906067532832164690190606753287556267352016.085.268335248573980.45910412-2.44160298533366670.40957135-1.09056640995987570.530555-2.05551981.12191710.86430624892700980.58287710.7153130935736430.47160438-0.054446124-0.015339496-0.334684430.13777287-0.26095370.1763433-0.56110490.0310971420.2177652-0.11443702330032911.0299137382.768160.689336840.2994290695False--1.25023650.123004876-0.19324453-0.125749360.032932058-0.143619220.06455237439190.84676933412500.0605501912.78158001.03974820.209127380.26045140.244918330.5289087-85.225365-3.2899575-29.32366-42.54999False328147.745868388353640.72871625202.7481420.2635782936.027169684549873.89423739.25140621.44696637190.876379509008367.546255625.29418419.0460151.5357692000002.40095141.18338781.2175636--------------------------------------------NOT_AVAILABLE206.9515174309682-16.7475736700905584.74809544110592-25.794662806626693FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse7.747473e-135.229698e-130.99999446------------------------------------------0.017945489552972947
1636148068921376768Gaia DR3 321646861103793062432164686110379306249354734092016.085.23860857472170.46767473-2.4622923009866810.40314810.77700769724615020.598390761.29849545.4132920.55314650580423390.6129275-5.3849566732572420.494308680.0149385660.06448122-0.212450890.0711942-0.26143860.1208418-0.5615382-0.0267677680.38506997-0.09344254342034200.9642493406.291961.47108111.278055595False--1.16231330.12403801-0.19795567-0.0794256850.06298836-0.1067884040.101240339170.8698572402400.03629359690.33434001.03642230.16089920.309920130.184753030.44911218-82.79225-4.6845818-28.746756-41.727596False341137.964866753973040.78542095175.6572320.3379462159.027077206460066.85343938.61276720.91091333211.439490675618979.65003521.9107518.934931.9604018010101.97598270.57296751.4030151--------------------------------------------NOT_AVAILABLE206.95627609646655-16.7834811187594484.71428834509156-25.814252456150466FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse1.2971835e-138.269208e-130.9999991------------------------------------------0.01836293659726027
1636148068921376768Gaia DR3 32164686754654882563216468675465488256166472192016.085.234673098710810.51438564-2.44980855730576330.435045870.337316437470670250.631778660.53391562.33316352.33307169289167860.657961250.020696178275889480.5042113-0.011451531-0.19442908-0.416421030.03437781-0.383347450.10441229-0.69430090.19266070.4085249-0.12117048334033310.65179557368.289641.34232991.264421895False--1.33475160.11629938-0.2020829-0.07508502-0.014079772-0.134418030.0930247438170.95642906392500.004085686564.82368001.02456740.200015070.367116060.260030.40765452-98.687514.1797576-20.715187-39.459377False327151.86253145623440.66563815228.1457820.233742136.177458443578095.46200376.623477521.44244829204.661804300239238.29044324.68647218.9703031.5859032000002.4721451.20870781.2634373--------------------------------------------NOT_AVAILABLE206.94281943924076-16.78117497149264384.71043259626695-25.801632853854667FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse4.767196e-135.8040146e-110.99999815------------------------------------------0.020028009828231417
1636148068921376768Gaia DR3 321646902335478540832164690233547854081766919112016.085.270755823294690.1961405-2.4413072346084350.178603570.66366819284537160.23415622.83429676.5850256.5754048658043110.24365711-0.355809916386045640.20158039-0.042318420.014788889-0.31547280.11617606-0.26037260.12642686-0.57009410.130724640.23919845-0.061890464368036620.43652844405.41870.0725201140.01589975595False--1.25868210.05131671-0.1420974-0.08405918-0.029754888-0.1145383340.1351950543200.3494921452800.0187986986.73902001.01538170.217225640.247628630.267649350.5151869-74.446075-3.9929616-22.67545-43.95803False363409.713378509141141.0203439401.544419.1561663765.821937935860495.464419412.0455520.79261640530.04665635533757.32902972.3215417.937111.4543548010102.8555051.63644981.2190552--------------------------------------------NOT_AVAILABLE206.95241508079897-16.74529394628304584.75079163706141-25.7944553638111FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse3.5761834e-135.110677e-130.999994------------------------------------------0.020043830041751424
1636148068921376768Gaia DR3 321646785512241446432164678551224144649239361722016.085.255780051666720.50923383-2.47650544746949340.455202460.77691685715218510.59604721.30344840.92492580.80186976455429150.67977680.46096924209070580.5313265-0.112634420.11976503-0.228063850.19673494-0.187768360.22860377-0.618966160.193633960.23427469-0.1325835128502823-0.40685338300.893920.02.4194166e-1595False--1.09798240.14102378-0.12671481-0.15378633-0.059823737-0.180964540.2456726733180.9812631341900.076289624.733895000.981532750.213446210.294727530.192385990.43329495-87.93401-1.0898006-29.688093-42.996693False280136.190562989170840.83884525162.3548120.3522345.2404983015652758.2042315.514288421.19972431151.98580011416098.5243817.82954419.2933881.4481642000201.90633580.84772491.0586109--------------------------------------------NOT_AVAILABLE206.97773758997462-16.77487209035170384.73275587575476-25.829084209901822FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse1.0344582e-091.8264745e-100.99999684------------------------------------------0.023539736369753695
1636148068921376768Gaia DR3 32164681643600529923216468164360052992235467102016.085.274516826975762.2556965-2.4723057142289851.5849423----------------0.536678------------------8008001.430115793.141760.00.03False----------------1074.167668310600.09136518171.8855900--0.36974720.500568570.411107420.52664024-76.56397-22.63934-33.053043-39.32441False7978.444165857171411.315044959.65132520.950966466.5763751095258825.0766052.654919920.7802415135.56417909373225.5035255.315507419.4175342.5768716000001.3627071-0.170724871.533432--------------------------------------------NOT_AVAILABLE206.98291592741373-16.7563392493909184.75370889485112-25.82557011527804FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse2.4502437e-051.4911667e-050.99836755------------------------------------------0.02782140743048771
...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................
1636148068921376768Gaia DR3 3216456065439222912321645606543922291214216956772016.085.311169825758140.40173137-2.51066819484564530.40131231.7361331188268820.454184353.82252969.741213-5.1529179074586170.517365-8.2667198790980390.443483-0.16442835-0.076135896-0.430101930.242566990.00729042150.35669935-0.72363280.12072589-0.0053872755-0.32701382290028913.1741064417.325621.61368453.021048395False--1.14197360.1037138-0.102503575-0.23006625-0.033000063-0.163985490.2234993134200.8391437372500.02747992177.14145101.13511290.18848940.273698840.219297860.48222566-80.36146-4.405813-22.027073-42.93724False287234.38669612839120.9647052242.9619919.7625352475.94563059259429.6330697.88384620.63728529334.766020308070511.11256530.12518.4360431.7522823020102.20124240.874750141.3264923--------------------------------------------NOT_AVAILABLE207.0361400496104-16.7416752140798784.79282428995414-25.865235525984968FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse6.410813e-122.0735247e-090.9999794------------------------------------------0.080839193349907
1636148068921376768Gaia DR3 321647255811288780832164725581128878087967069402016.085.188526213173570.2259397-2.4056562675433470.21768318-0.113887777311962440.28216147-0.403626261.21987831.1842942345551460.26978385-0.292489952065707050.2340413-0.269530480.1911443-0.235108780.32237884-0.363430050.30793124-0.652729450.0373012540.33524925-0.2686844232503250-0.717088325.744050.00.095False--1.28399410.056570467-0.199616770.015470109-0.18636444-0.097889270.01929561638200.43101293382300.0308802878.535898000.970710160.220029060.285578430.207942560.4101255-65.664780.8588567-24.406776-43.698612False320364.005079220680950.90043736404.2536319.28459734137.1550711881877511.7971511.6261219.99551231342.40814354401257.83838643.68350218.4115351.3174629010101.58397670.71091460.87306213--------------------------------------------NOT_AVAILABLE206.87962201372886-16.80153522261224884.66107447497244-25.75581047640869FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse2.1622872e-101.3842859e-100.99999607------------------------------------------0.08112646296289025
1636148068921376768Gaia DR3 3216444937178204160321644493717820416013862390992016.085.190305865777390.07698814-2.50288193236420130.069521550.490476387215092850.096912785.06100859.4425577.0140162129957590.09374031-6.3218252187870110.079626285-0.0549270440.02979098-0.28497930.09145997-0.349647250.09440442-0.627611760.0666177940.35496876-0.08418727381038102.634945476.30320.306532532.205727695False--1.41011750.020281127-0.15829301-0.032261044-0.025952134-0.0492492240.0622064643210.13505712432500.0238799239.0169325101.09682450.209047420.293577520.245373060.4592325-93.2105560.81500864-25.391544-42.085728False3731818.65556469129661.50911205.12617.5379938663.871498798340711.66446156.91403218.283333381679.688056955974212.2571137.0379616.6848241.288622020001.59850880.745342250.8531666--------------------------------------------NOT_AVAILABLE206.97046839266432-16.84505810561864884.65904656064926-25.85303525756708FalseFalse0TrueFalseFalseFalseFalseTrueTrueFalse2.1057866e-115.2152347e-130.99999294720.87164589.97564839.49074.65674.57764.7072-2.2392-2.4267-1.7745862.0521812.244948.85391.04760.90541.20780.79580.6850.92280.43620.37460.5038PHOENIX0.08121814053391099
1636148068921376768Gaia DR3 321646878283537203232164687828353720326575116492016.085.172926183584790.19054802-2.46239574930347430.172725472.16240202938218350.239383439.03321552.4493213-2.0370351960317850.22680171.36002287929031240.19178832-0.145307470.112551525-0.209203230.17061059-0.30533540.17149667-0.57081010.0433841050.30095217-0.2015912835203511-0.48073354416.802340.595159351.196572795False--1.09010860.05042796-0.17146336-0.0065654744-0.110863455-0.0304774380.007562004540200.33940324402300.030575372178.93437000.98079460.167473550.288670030.173143630.43588594-74.8669365.0166435-23.469093-43.28577False347435.67159216979491.0631166409.8060619.0894682644.399558766169716.04460957.345314521.22009538673.55768085941518.57523878.5468217.6769581.6479322000003.54313662.13062671.4125099--------------------------------------------NOT_AVAILABLE206.92457804544165-16.84166631780135584.64143853749016-25.811932421839387FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse2.7495896e-135.0978774e-130.99999624------------------------------------------0.08200148643415694
1636148068921376768Gaia DR3 3216455691775435392321645569177543539210796843572016.085.304957089105141.4646537-2.51789043925866231.1984521.06214293006590841.4969340.7095455514.069712.3629598712775921.4997277-13.8698645982717481.29725440.419499130.5497209-0.122153305-0.0074391460.365121540.13959806-0.497818140.08308936-0.122015750.138876511301121-1.8722427109.503010.00.095False--1.11609790.380087020.28031650.1086029260.32898340.099974590.1775860513112.138008414800.13895129172.40553000.871205150.366616930.37740080.221789550.376025-25.664597-18.63486-15.04699342.01079False11183.734665705052620.994157484.2267720.880104848.31637298104771411.5515364.182679721.12830711143.1242636882916513.86908710.3196619.3586122.286277000011.76969530.248203281.521492--------------------------------------------NOT_AVAILABLE207.03981962770035-16.75052221144076784.7856405966112-25.872228605607752FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse1.2387219e-104.4580528e-080.99999696------------------------------------------0.08219069174617054
1636148068921376768Gaia DR3 3216469847988496640321646984798849664017503210722016.085.332058749151190.4250795-2.4252498607593210.373271730.224212721884867630.481204240.465940861.13753930.61466113154650140.53041315-0.95717666589952180.43026003-0.08336612-0.04359924-0.35039510.17059404-0.222150580.20433807-0.632150350.1050495060.21047379-0.11205828395039323.2212033549.235351.79646422.88557695False--1.04707590.107746-0.16536176-0.12141910.04378124-0.122201280.1245975446210.7767407503100.016963525142.54533001.11709630.210570510.309179070.263337370.43816993-90.41127-5.9151006-22.575792-42.194275False384176.8022117019990.77002114229.6069520.0686472148.0944092642239558.2007515.864634521.13330741300.87476522625638.94530433.6349418.5519311.9737829010202.58137511.06465911.516716--------------------------------------------NOT_AVAILABLE206.96721911695258-16.68358428483469484.81941412521121-25.78062488637266FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse5.8075224e-136.0352385e-130.99999946------------------------------------------0.08234330900782977
1636148068921376768Gaia DR3 321647084013309350432164708401330935044004650012016.085.307472388214750.29184374-2.389493592313770.260748830.120192603675435940.339850.353663685.18945741.78764598245265520.36385092-4.8718362058100020.2897296-0.09265526-0.0014098006-0.312704240.17439121-0.194702310.19349204-0.570278170.146708350.18696235-0.098352544363036030.86954176431.95990.85806581.129153495False--1.16370460.07667623-0.1388337-0.07941982-0.006895077-0.1168730850.133164243200.52750075452800.01510797356.0423245001.0319050.205954340.253176750.26039470.5014082-76.88399-3.9765499-21.605133-43.848877False357265.889092422599960.897993296.092619.6256163451.0913124823540346.84660347.46228621.06767541406.28934672317818.79159746.2133718.2258071.7201934000202.84186741.44205861.3998089--------------------------------------------NOT_AVAILABLE206.92225446615564-16.688761054788984.7935869203766-25.744006573347082FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse8.483602e-135.134769e-130.9999985------------------------------------------0.08269446496314736
1636148068921376768Gaia DR3 321644387202505881632164438720250588169257328672016.085.245590423093760.71123976-2.5353892265506730.737375740.89802383494170920.96701690.92865371.5929452-1.47910264142623430.8477286-0.59137957050516710.7786666-0.28390630.3210551-0.237746880.2605932-0.519155740.22001855-0.61014396-0.199064280.4816959-0.21136881217021522.8487191283.36871.58346341.160853795False--1.68256510.205878-0.35830180.26714784-0.16991253-0.030751199-0.1008917225161.3951224261300.00461144765.27896001.14085580.350995150.187642960.3546440.6033324-63.2702378.353648-27.99232-44.789764False213116.434175525845570.8913834130.6218720.5221651650.0242539938938159.8389175.084325321.09059122124.749887200002018.93935513.95513319.5077951.5010554000001.58279610.568426131.01437--------------------------------------------NOT_AVAILABLE207.02730810483163-16.81118743428815484.71905604380503-25.88755596761321FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse1.085153e-075.787982e-090.9999933------------------------------------------0.08286217986852269
1636148068921376768Gaia DR3 3216455653128695936321645565312869593614674229212016.085.293280388614920.2429748-2.5262445326560980.233233577.1877708445657620.299343424.0117936.290695-33.92371725325130.279955512.8916997351076020.25018305-0.07392460.051945604-0.343405280.11745921-0.234827920.14009184-0.67943627-0.0047987670.24896738-0.115868084302030020.91878456374.84650.90506872.16200295False--1.153160.06230389-0.1844487-0.073425606-0.014452084-0.0120718950.04843985735200.4237814382600.01891589511.662993001.03698050.225643290.29009150.272267670.43290338-72.828270.47325253-21.18871-44.038074False291415.483035543012361.1920303348.5507219.1409842654.114110245989628.1897546.60753821.00526635627.909876293218513.44624846.69777717.7531531.6415206010203.25211331.86428261.3878307--------------------------------------------NOT_AVAILABLE207.04190534382894-16.7647307870152184.77234739467015-25.880154554757564FalseFalse0FalseFalseFalseFalseFalseFalseFalseFalse8.234745e-131.9977706e-090.9999949------------------------------------------0.08287548585527736
reduced_query = gaia_query['ra', 'dec', 'phot_g_mean_mag']
reduced_query.write('gaia_no_pm.cat', format='ascii.commented_header', overwrite=True)
reduced_query
Table length=183
radecphot_g_mean_mag
degdegmag
float64float64float32
85.25078206874738-2.44425762103754119.836756
85.24865858921503-2.44135458461613617.722948
85.25474417063919-2.47008409060809517.202978
85.26833524857398-2.441602985333666720.263578
85.2386085747217-2.46229230098668120.337946
85.23467309871081-2.449808557305763320.23374
85.27075582329469-2.44130723460843519.156166
85.25578005166672-2.476505447469493420.352
85.27451682697576-2.47230571422898520.950966
.........
85.31116982575814-2.510668194845645319.762535
85.18852621317357-2.40565626754334719.284597
85.19030586577739-2.502881932364201317.53799
85.17292618358479-2.462395749303474319.089468
85.30495708910514-2.517890439258662320.880104
85.33205874915119-2.42524986075932120.068647
85.30747238821475-2.3894935923137719.625616
85.24559042309376-2.53538922655067320.522165
85.29328038861492-2.52624453265609819.140984

2.2 Create a catalog of Gaia DR3 sources with Proper Motion Data #

This method uses the image FLT footprints and gives 161 sources, compared to 183 with the prior method.

pm_cat = create_astrometric_catalog(sorted(glob.glob('*flt.fits')))
pm_cat.write('gaia_pm.cat', overwrite=True, format='ascii.no_header')
len(pm_cat)
2024218174307 INFO src=drizzlepac.haputils.astrometric_utils- Getting catalog using: 
    http://gsss.stsci.edu/webservices/vo/CatalogSearch.aspx?RA=85.25357496441966&DEC=-2.4518021150880305&SR=0.07776401075620538&FORMAT=CSV&CAT=GAIAedr3&MINDET=5&EPOCH=2012.839
2024218174308 INFO src=drizzlepac.haputils.astrometric_utils- Created catalog 'ref_cat.ecsv' with 161  sources
161

2.3 Run TweakReg #

Next we run TweakReg on the visit-level drizzled (DRZ) images and align to the Gaia catalog with proper motion data.

Because the fit RMS values for the MAST products were large for some visits, we allow for a larger than usual search radius of 1”. We also set the conv_width value slightly higher than the recommended value of 2.5 for WFC3/IR data in order to use barely resolved sources for alignment.

refcat = 'gaia_pm.cat'                    # Use the catalog with proper motion data

drz_files = sorted(glob.glob('*drz.fits'))

tweakreg.TweakReg(drz_files, 
                  imagefindcfg={'threshold': 4, 'conv_width': 4.5}, 
                  minobj=3,
                  shiftfile=True, 
                  outshifts='shift_drz.txt',
                  refcat=refcat,
                  searchrad=1,
                  ylimit=0.4, 
                  nclip=1,
                  updatehdr=False,       # change later when you verify the alignment works
                  interactive=False)
# clear_output()
Setting up logfile :  tweakreg.log
TweakReg Version 3.7.0.1 started at: 17:43:08.371 (05/08/2024) 

Version Information
--------------------
Python Version 3.11.9 (main, Jul 15 2024, 21:50:21) [GCC 11.4.0]
numpy Version -> 1.26.4 
astropy Version -> 6.1.2 
stwcs Version -> 1.7.3 
photutils Version -> 1.12.0 

Finding shifts for: 
    ibxl50030_drz.fits
    ibxl51030_drz.fits
    ibxl52030_drz.fits
    ibxl53030_drz.fits
    ibxl54030_drz.fits
    ibxl55030_drz.fits
    ibxl56030_drz.fits
    ibxl57030_drz.fits
    ibxl58030_drz.fits

===  Source finding for image 'ibxl50030_drz.fits':
  #  Source finding for 'ibxl50030_drz.fits', EXT=('SCI', 1) started at: 17:43:08.419 (05/08/2024)
     Found 59 objects.
===  FINAL number of objects in image 'ibxl50030_drz.fits': 59

===  Source finding for image 'ibxl51030_drz.fits':
  #  Source finding for 'ibxl51030_drz.fits', EXT=('SCI', 1) started at: 17:43:08.515 (05/08/2024)
     Found 66 objects.
===  FINAL number of objects in image 'ibxl51030_drz.fits': 66

===  Source finding for image 'ibxl52030_drz.fits':
  #  Source finding for 'ibxl52030_drz.fits', EXT=('SCI', 1) started at: 17:43:08.608 (05/08/2024)
     Found 76 objects.
===  FINAL number of objects in image 'ibxl52030_drz.fits': 76

===  Source finding for image 'ibxl53030_drz.fits':
  #  Source finding for 'ibxl53030_drz.fits', EXT=('SCI', 1) started at: 17:43:08.700 (05/08/2024)
     Found 32 objects.
===  FINAL number of objects in image 'ibxl53030_drz.fits': 32

===  Source finding for image 'ibxl54030_drz.fits':
  #  Source finding for 'ibxl54030_drz.fits', EXT=('SCI', 1) started at: 17:43:08.791 (05/08/2024)
     Found 41 objects.
===  FINAL number of objects in image 'ibxl54030_drz.fits': 41

===  Source finding for image 'ibxl55030_drz.fits':
  #  Source finding for 'ibxl55030_drz.fits', EXT=('SCI', 1) started at: 17:43:08.884 (05/08/2024)
     Found 83 objects.
===  FINAL number of objects in image 'ibxl55030_drz.fits': 83

===  Source finding for image 'ibxl56030_drz.fits':
  #  Source finding for 'ibxl56030_drz.fits', EXT=('SCI', 1) started at: 17:43:08.977 (05/08/2024)
     Found 57 objects.
===  FINAL number of objects in image 'ibxl56030_drz.fits': 57

===  Source finding for image 'ibxl57030_drz.fits':
  #  Source finding for 'ibxl57030_drz.fits', EXT=('SCI', 1) started at: 17:43:09.06 (05/08/2024)
     Found 80 objects.
===  FINAL number of objects in image 'ibxl57030_drz.fits': 80

===  Source finding for image 'ibxl58030_drz.fits':
  #  Source finding for 'ibxl58030_drz.fits', EXT=('SCI', 1) started at: 17:43:09.159 (05/08/2024)
     Found 88 objects.
===  FINAL number of objects in image 'ibxl58030_drz.fits': 88


===============================================================
Performing alignment in the projection plane defined by the WCS
derived from 'ibxl50030_drz.fits'
===============================================================


====================
Performing fit for: ibxl50030_drz.fits

Matching sources from 'ibxl50030_drz.fits' with sources from reference catalog 'gaia_pm.cat'
Computing initial guess for X and Y shifts...
Found initial X and Y shifts of 0.2027, 0.2027 with significance of 9 and 9 matches
Found 9 matches for ibxl50030_drz.fits...
Computed  rscale  fit for  ibxl50030_drz.fits : 
XSH: -0.0132  YSH: -0.0611    ROT: 359.9979222    SCALE: 1.000034
FIT XRMS: 0.036      FIT YRMS: 0.033  
FIT RMSE: 0.049      FIT MAE: 0.044  

RMS_RA: 1.5e-06 (deg)   RMS_DEC: 9.6e-07 (deg)

Final solution based on  9  objects.
wrote XY data to:  ibxl50030_drz_catalog_fit.match
Total # points: 9
# of points after clipping: 9
Total # points: 9
# of points after clipping: 9

====================
Performing fit for: ibxl51030_drz.fits

Matching sources from 'ibxl51030_drz.fits' with sources from reference catalog 'gaia_pm.cat'
Computing initial guess for X and Y shifts...
Found initial X and Y shifts of 0.2027, 0.2027 with significance of 8.485 and 12 matches
Found 12 matches for ibxl51030_drz.fits...
Computed  rscale  fit for  ibxl51030_drz.fits : 
XSH: 0.1506  YSH: -0.0723    ROT: 359.9953417    SCALE: 1.000079
FIT XRMS: 0.026      FIT YRMS: 0.039  
FIT RMSE: 0.047      FIT MAE: 0.04   

RMS_RA: 1.1e-06 (deg)   RMS_DEC: 1.2e-06 (deg)

Final solution based on  12  objects.
wrote XY data to:  ibxl51030_drz_catalog_fit.match
Total # points: 12
# of points after clipping: 12
Total # points: 12
# of points after clipping: 12

====================
Performing fit for: ibxl52030_drz.fits

Matching sources from 'ibxl52030_drz.fits' with sources from reference catalog 'gaia_pm.cat'
Computing initial guess for X and Y shifts...
Found initial X and Y shifts of 0.07773, 0.4527 with significance of 6.139 and 8 matches
Found 7 matches for ibxl52030_drz.fits...
Computed  rscale  fit for  ibxl52030_drz.fits : 
XSH: 0.2701  YSH: 0.2527    ROT: 359.9900691    SCALE: 0.999944
FIT XRMS: 0.046      FIT YRMS: 0.034  
FIT RMSE: 0.058      FIT MAE: 0.053  

RMS_RA: 1.8e-06 (deg)   RMS_DEC: 9.4e-07 (deg)

Final solution based on  7  objects.
wrote XY data to:  ibxl52030_drz_catalog_fit.match
Total # points: 7
# of points after clipping: 7
Total # points: 7
# of points after clipping: 7

====================
Performing fit for: ibxl53030_drz.fits

Matching sources from 'ibxl53030_drz.fits' with sources from reference catalog 'gaia_pm.cat'
Computing initial guess for X and Y shifts...
Found initial X and Y shifts of 0.2027, 0.2027 with significance of 5 and 5 matches
Found 5 matches for ibxl53030_drz.fits...
Computed  rscale  fit for  ibxl53030_drz.fits : 
XSH: -0.1291  YSH: -0.3033    ROT: 359.9975685    SCALE: 1.000116
FIT XRMS: 0.023      FIT YRMS: 0.048  
FIT RMSE: 0.054      FIT MAE: 0.046  

RMS_RA: 1.1e-06 (deg)   RMS_DEC: 1.6e-06 (deg)

Final solution based on  5  objects.
wrote XY data to:  ibxl53030_drz_catalog_fit.match
Total # points: 5
# of points after clipping: 5
Total # points: 5
# of points after clipping: 5

====================
Performing fit for: ibxl54030_drz.fits

Matching sources from 'ibxl54030_drz.fits' with sources from reference catalog 'gaia_pm.cat'
Computing initial guess for X and Y shifts...
Found initial X and Y shifts of 0.2027, 0.2027 with significance of 6.261 and 7 matches
Found 7 matches for ibxl54030_drz.fits...
Computed  rscale  fit for  ibxl54030_drz.fits : 
XSH: 0.0227  YSH: 0.2099    ROT: 0.01677810197    SCALE: 1.000314
FIT XRMS: 0.021      FIT YRMS: 0.034  
FIT RMSE: 0.04       FIT MAE: 0.036  

RMS_RA: 9.3e-07 (deg)   RMS_DEC: 1.1e-06 (deg)

Final solution based on  7  objects.
wrote XY data to:  ibxl54030_drz_catalog_fit.match
Total # points: 7
# of points after clipping: 7
Total # points: 7
# of points after clipping: 7

====================
Performing fit for: ibxl55030_drz.fits

Matching sources from 'ibxl55030_drz.fits' with sources from reference catalog 'gaia_pm.cat'
Computing initial guess for X and Y shifts...
Found initial X and Y shifts of 0.2027, 0.2027 with significance of 8.165 and 10 matches
Found 10 matches for ibxl55030_drz.fits...
Computed  rscale  fit for  ibxl55030_drz.fits : 
XSH: -0.1110  YSH: -0.0133    ROT: 0.001558507484    SCALE: 0.999874
FIT XRMS: 0.042      FIT YRMS: 0.045  
FIT RMSE: 0.062      FIT MAE: 0.057  

RMS_RA: 1.7e-06 (deg)   RMS_DEC: 1.4e-06 (deg)

Final solution based on  10  objects.
wrote XY data to:  ibxl55030_drz_catalog_fit.match
Total # points: 10
# of points after clipping: 10
Total # points: 10
# of points after clipping: 10

====================
Performing fit for: ibxl56030_drz.fits

Matching sources from 'ibxl56030_drz.fits' with sources from reference catalog 'gaia_pm.cat'
Computing initial guess for X and Y shifts...
Found initial X and Y shifts of 0.2027, -0.7973 with significance of 5 and 5 matches
Found 5 matches for ibxl56030_drz.fits...
Computed  rscale  fit for  ibxl56030_drz.fits : 
XSH: -0.2514  YSH: -0.3965    ROT: 0.001077725127    SCALE: 1.000291
FIT XRMS: 0.18       FIT YRMS: 0.053  
FIT RMSE: 0.18       FIT MAE: 0.15   

RMS_RA: 6.5e-06 (deg)   RMS_DEC: 8.9e-07 (deg)

Final solution based on  5  objects.
wrote XY data to:  ibxl56030_drz_catalog_fit.match
Total # points: 5
# of points after clipping: 5
Total # points: 5
# of points after clipping: 5

====================
Performing fit for: ibxl57030_drz.fits

Matching sources from 'ibxl57030_drz.fits' with sources from reference catalog 'gaia_pm.cat'
Computing initial guess for X and Y shifts...
Found initial X and Y shifts of 0.2027, 0.2027 with significance of 12 and 12 matches
Found 12 matches for ibxl57030_drz.fits...
Computed  rscale  fit for  ibxl57030_drz.fits : 
XSH: 0.0136  YSH: 0.0748    ROT: 0.0002822969294    SCALE: 1.000050
FIT XRMS: 0.037      FIT YRMS: 0.052  
FIT RMSE: 0.064      FIT MAE: 0.055  

RMS_RA: 1.6e-06 (deg)   RMS_DEC: 1.6e-06 (deg)

Final solution based on  12  objects.
wrote XY data to:  ibxl57030_drz_catalog_fit.match
Total # points: 12
# of points after clipping: 12
Total # points: 12
# of points after clipping: 12

====================
Performing fit for: ibxl58030_drz.fits

Matching sources from 'ibxl58030_drz.fits' with sources from reference catalog 'gaia_pm.cat'
Computing initial guess for X and Y shifts...
Found initial X and Y shifts of 0.2027, 0.2027 with significance of 13.57 and 15 matches
Found 15 matches for ibxl58030_drz.fits...
Computed  rscale  fit for  ibxl58030_drz.fits : 
XSH: 0.1882  YSH: 0.3442    ROT: 359.9942141    SCALE: 1.000085
FIT XRMS: 0.081      FIT YRMS: 0.05   
FIT RMSE: 0.095      FIT MAE: 0.078  

RMS_RA: 3.1e-06 (deg)   RMS_DEC: 1.3e-06 (deg)

Final solution based on  15  objects.
wrote XY data to:  ibxl58030_drz_catalog_fit.match
Total # points: 15
# of points after clipping: 15
Total # points: 15
# of points after clipping: 15
Writing out shiftfile : shift_drz.txt
Trailer file written to:  tweakreg.log
../../../_images/4377a2c5ebf78b6bc2c76f277e648a4c8fe4bf0675254d885c55bd36e9b49bab.png ../../../_images/c51efba192df3bc8eef2a3a909c6e414fb48ab929cf599ef47389c808005dcb9.png ../../../_images/f355ea23dc916ad39779a727bea4d0a5b96fcc8efacbdb6a7480bb85af40048b.png
# If the alignment is unsuccessful, stop the notebook
with open('shift_drz.txt', 'r') as shift:
    for line_number, line in enumerate(shift, start=1):
        if "nan" in line:
            raise ValueError(f'nan found in line {line_number} in shift file')

2.4 Inspect the shift file and fit quality #

# Read the shift file just created by tweakreg
# There are 7 columns including: filename, x-shift, y-shift, rotation, scale, x-RMS, and y-RMS
shift_table = Table.read('shift_drz.txt',
                         format='ascii.no_header', 
                         names=['file', 'dx', 'dy', 'rot', 'scale', 'xrms', 'yrms'])

# Define the format for each column (excluding 'file').
formats = ['.2f', '.2f', '.3f', '.5f', '.2f', '.2f']

# Iterate over the columns 'dx', 'dy', 'rot', 'scale', 'xrms', 'yrms'
for i, col in enumerate(shift_table.colnames[1:]):
    # Apply the format to the current column 
    shift_table[col].format = formats[i]
    
# Display the table in the notebook
shift_table
Table length=9
filedxdyrotscalexrmsyrms
str18float64float64float64float64float64float64
ibxl50030_drz.fits-0.01-0.06359.9981.000030.040.03
ibxl51030_drz.fits0.15-0.07359.9951.000080.030.04
ibxl52030_drz.fits0.270.25359.9900.999940.050.03
ibxl53030_drz.fits-0.13-0.30359.9981.000120.020.05
ibxl54030_drz.fits0.020.210.0171.000310.020.03
ibxl55030_drz.fits-0.11-0.010.0020.999870.040.05
ibxl56030_drz.fits-0.25-0.400.0011.000290.180.05
ibxl57030_drz.fits0.010.070.0001.000050.040.05
ibxl58030_drz.fits0.190.34359.9941.000080.080.05

Note that there are large residual rotation and scale terms in the shift file for several visits in the MAST data products. These will be corrected when we run TweakReg an additional time and update the WCS in Section 2.6 below.

match_files = sorted(glob.glob('*_drz_catalog_fit.match'))
for f in match_files:
    input = ascii.read(f)
    print(f'Number of matches for {f} {len(input)}')
Number of matches for ibxl50030_drz_catalog_fit.match 9
Number of matches for ibxl51030_drz_catalog_fit.match 12
Number of matches for ibxl52030_drz_catalog_fit.match 7
Number of matches for ibxl53030_drz_catalog_fit.match 5
Number of matches for ibxl54030_drz_catalog_fit.match 7
Number of matches for ibxl55030_drz_catalog_fit.match 10
Number of matches for ibxl56030_drz_catalog_fit.match 5
Number of matches for ibxl57030_drz_catalog_fit.match 12
Number of matches for ibxl58030_drz_catalog_fit.match 15

Next we compare with the MAST WCS solutions, number of matches and fit RMS values. Since there are only 5 Gaia sources in Visits 53 and 56, these did not have a successful Gaia fit during MAST processing and instead were aligned to the next catalog in the priority list, GSC v2.4.2. (Currently the minimum number of matches for a successful fit is 6, but this will updated to 10 in summer 2024.

wcstable
Table length=9
FILENAMEDETECTORWCSNAMENMATCHESRMS_RARMS_DECRMS_RA_pixRMS_DEC_pix
str18str2str30int64float64float64float64float64
ibxl50030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR385.410.40.040.08
ibxl51030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR31113.58.20.110.06
ibxl52030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR3823.519.30.180.15
ibxl53030_drz.fitsIRIDC_w3m18525i-FIT_REL_GSC2421464.787.60.50.68
ibxl54030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR3726.023.90.20.19
ibxl55030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR3109.87.90.080.06
ibxl56030_drz.fitsIRIDC_w3m18525i-FIT_REL_GSC2421865.493.30.510.73
ibxl57030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR3128.48.20.070.06
ibxl58030_drz.fitsIRIDC_w3m18525i-FIT_REL_GAIAeDR31535.536.70.280.29

2.5 Overplot matched sources and inspect fit residuals #

Here we overplot the HST sources which were successfully matched with Gaia eDR3 and we look at the astrometric fit residual PNG plots.

While we inspect only two visits (52 and 53) at a time, and additional visits may be uncommented in the cell below.

# Define the rootnames for the two FITS files to be compared
# Uncomment the pairs you want to use

# rootname_A = 'ibxl50030'
# rootname_B = 'ibxl51030'
rootname_A = 'ibxl52030'
rootname_B = 'ibxl53030'
# rootname_A = 'ibxl54030'
# rootname_B = 'ibxl55030'
# rootname_A = 'ibxl56030'
# rootname_B = 'ibxl57030'
# rootname_A = 'ibxl57030'
# rootname_B = 'ibxl58030'

# Create subplots with 1 row and 2 columns
fig, [ax1, ax2] = plt.subplots(1, 2, figsize=(13, 10))

# Open the FITS files and extract the data from the 'SCI' extension
data_a = fits.open(rootname_A+'_drz.fits')['SCI', 1].data
data_b = fits.open(rootname_B+'_drz.fits')['SCI', 1].data

# Display the images in grayscale with a stretch from 0 to 2 
ax1.imshow(data_a, cmap='Greys', origin='lower', vmin=0, vmax=2)
ax2.imshow(data_b, cmap='Greys', origin='lower', vmin=0, vmax=2)

# Read the matching catalog files for both rootnames
match_tab_a = ascii.read(rootname_A+'_drz_catalog_fit.match')
match_tab_b = ascii.read(rootname_B+'_drz_catalog_fit.match')

# Extract x and y coordinates from the matching catalogs
x_coord_a, y_coord_a = match_tab_a['col11'], match_tab_a['col12']
x_coord_b, y_coord_b = match_tab_b['col11'], match_tab_b['col12']

# Plot the coordinates on the images with red circles
ax1.scatter(x_coord_a, y_coord_a, s=30, edgecolor='r', facecolor='None')
ax2.scatter(x_coord_b, y_coord_b, s=30, edgecolor='r', facecolor='None')

# Set the titles for the subplots, including the number of matches
ax1.set_title(rootname_A+f'  N = {len(match_tab_a)}  Gaia Matches', fontsize=20)
ax2.set_title(rootname_B+f'  N = {len(match_tab_b)}  Gaia Matches', fontsize=20)
fig.tight_layout()

# Load, display, and inspect fit residual PNG files
img_A = mpimg.imread(f'residuals_{rootname_A}_drz.png')
img_B = mpimg.imread(f'residuals_{rootname_B}_drz.png')

# Create subplots for the residual images
fig, axs = plt.subplots(1, 2, figsize=(20, 10), dpi=200)
axs[0].imshow(img_A)
axs[1].imshow(img_B)

# Remove unnecessary axis from the residual images
axs[0].axis('off') 
axs[1].axis('off')

# Adjust layout to minimize margins and display plots
fig.tight_layout()
plt.show()
../../../_images/65a49f9deeff0e0aececd7a5803efe1ae7fc7e4afbbad498c5f8153dacfc83a9.png ../../../_images/3fa3ac2302aec400e6a7370fe281ab5eda1b4776ea3971937bfacc8944e602b3.png

2.6 Rerun TweakReg and update the header WCS #

Once we are happy with the alignment, we run TweakReg again with the same parameters but with the updatehdr=True.

refcat = 'gaia_pm.cat'    # Use the catalog with proper motion data

tweakreg.TweakReg(drz_files, 
                  imagefindcfg={'threshold': 4, 'conv_width': 4.5}, 
                  minobj=4,
                  shiftfile=False, 
                  refcat=refcat,
                  searchrad=1,
                  ylimit=0.4, 
                  nclip=1,
                  updatehdr=True,       # update header
                  interactive=False)
clear_output()

2.7 Run TweakBack to propogate the WCS to the FLT files #

Finally, we run Tweakback on the aligned DRZ files to propogate the updated WCS information back to the FLT files.

for f in drz_files:
    tb_input = f+'[sci,1]'
    with fits.open(f) as hdu:
        tweakback.apply_tweak(tb_input, orig_wcs_name=hdu[1].header['WCSNAME'])
    
clear_output()

3. Compare skymethod options in AstroDrizzle #

Now that the FLT files contain the updated WCS solutions, we explore different algorithms for estimating the sky.

3.1 skymethod = 'localmin' #

When using AstroDrizzle to compute the sky in each frame, ‘localmin’ will compute a common sky value for all chips of a given exposure, using the minimum sky value from all chips. This process is repeated for each input image. This algorithm is recommended when images are dominated by blank sky instead of extended, diffuse sources.

See readthedocs for more details on sky subtraction options.

In the command below, the aligned FLT frames are sky subtracted and drizzled together.

Because the WFC3/IR data products are already cleaned of cosmic rays during calwf3 processing, cosmic-ray rejection is turned off in AstroDrizzle by setting the parameters driz_separate, median, blot, and driz_cr to ‘False’. Note that final_bits=16 means only the stable hot pixels are treated as good.

sky = 'localmin'
astrodrizzle.AstroDrizzle('*flt.fits', 
                          output='f160w_localmin',
                          preserve=False, 
                          context=False,
                          skymethod=sky, 
                          driz_separate=False, median=False, blot=False, driz_cr=False, # CR-rej turned off
                          final_bits='16',
                          final_wcs=True, 
                          final_rot=257.)
clear_output()

3.2 skymethod = 'match' #

When skymethod is set to ‘match’, differences in sky values between images in common sky regions will be computed. Thus, sky values will be relative (delta) to the sky computed in one of the input images whose sky value will be set to and reported as 0. This setting “equalizes” sky values between the images in large mosaics.

This is the recommended setting for images containing diffuse sources (e.g., galaxies, nebulae) covering significant parts of the image.

sky = 'match'
astrodrizzle.AstroDrizzle('*flt.fits', 
                          output='f160w_match',
                          preserve=False, 
                          context=False,
                          skymethod=sky, 
                          driz_separate=False, median=False, blot=False, driz_cr=False, # CRREJ=None
                          final_bits='16',
                          final_wcs=True, 
                          final_rot=257.)
clear_output()

3.3 skymethod = 'globalmin+match' #

When skymethod is set to ‘globalmin+match’, AstroDrizzle will first find a minimum “global” sky value in all input images and then use the ‘match’ method to equalize sky values between images.

sky = 'globalmin+match'
astrodrizzle.AstroDrizzle('*flt.fits', 
                          output='f160w_globalmin_match',
                          preserve=False, 
                          context=False,
                          skymethod=sky, 
                          driz_separate=False, median=False, blot=False, driz_cr=False, # CRREJ=None
                          final_bits='16',
                          final_wcs=True, 
                          final_rot=257.)
clear_output()

3.4 skymethod = 'globalmin' #

When skymethod is set to ‘globalmin’, a common sky value will be computed for all exposures. AstroDrizzle will compute sky values for each chip/image extension, find the minimum sky value from all the exposures, and then subtract that minimum sky value from all chips in all images.

This method may be useful when input images already have matched background values.

sky = 'globalmin'
astrodrizzle.AstroDrizzle('*flt.fits', 
                          output='f160w_globalmin',
                          preserve=False, 
                          context=False,
                          skymethod=sky, 
                          driz_separate=False, median=False, blot=False, driz_cr=False, # CRREJ=None
                          final_bits='16',
                          final_wcs=True, 
                          final_rot=257.)
clear_output()

4. Compare the MDRIZSKY values for each method #

Below we provide a gif comparing the upper portion of the final drizzled image. We cycle through three drizzled images produced using different skymethod algorithms:

The top of the horsehead nebula is shown in grayscale with a stretch of about -0.4 to 2 and the animated gif transitions between displaying the "localmin", "match", and "globalmin+match" sky methods from astrodrizzle. Localmin looks the worst with unmatched backgrounds in the top left and right corners where the outline of separate pointings (dithers) are apparent.

Next we print the sky values computed for each image using the four different methods.

mdrizsky_val = pandas.DataFrame({'rootname': fits.getdata('f160w_globalmin_drz_sci.fits', 1)['rootname'],
                                 'local': fits.getdata('f160w_localmin_drz_sci.fits', 1)['mdrizsky'],
                                 'globalmin': fits.getdata('f160w_globalmin_drz_sci.fits', 1)['mdrizsky'],
                                 'globalmin_match': fits.getdata('f160w_globalmin_match_drz_sci.fits', 1)['mdrizsky'],
                                 'match': fits.getdata('f160w_match_drz_sci.fits', 1)['mdrizsky']})
mdrizsky_val
rootname local globalmin globalmin_match match
0 ibxl50clq 1.149898 0.795737 0.797206 0.029825
1 ibxl50cqq 1.162179 0.795737 0.793516 0.026135
2 ibxl51eoq 1.172860 0.795737 0.809310 0.041929
3 ibxl51etq 1.169722 0.795737 0.798349 0.030968
4 ibxl52k0q 0.800908 0.795737 0.800908 0.033527
5 ibxl52k5q 0.795737 0.795737 0.789151 0.021769
6 ibxl53kxq 1.201764 0.795737 0.811705 0.044323
7 ibxl53l9q 1.182859 0.795737 0.791296 0.023914
8 ibxl54bgq 1.169069 0.795737 0.791586 0.024204
9 ibxl54blq 1.162565 0.795737 0.786370 0.018989
10 ibxl55f0q 1.005999 0.795737 0.784566 0.017185
11 ibxl55f5q 1.009036 0.795737 0.784839 0.017458
12 ibxl56huq 1.362230 0.795737 0.794645 0.027263
13 ibxl56i2q 1.361166 0.795737 0.789920 0.022538
14 ibxl57adq 1.132304 0.795737 0.774515 0.007133
15 ibxl57aiq 1.119097 0.795737 0.773648 0.006266
16 ibxl58sqq 0.804495 0.795737 0.768938 0.001557
17 ibxl58svq 0.799019 0.795737 0.767381 0.000000

These computed sky values can be visualized in the plot below. To reiterate, the MDRIZSKY keyword reports the value subtracted from each FLC image prior to drizzling, and not the sky level itself. Thus the values for skymethod='match' are close to zero.

We also note that varying background levels across the individual tiles result in inaccurate sky background determination when skymethod='localmin' and thus a mismatched sky in the final mosaic.

index = mdrizsky_val.index.tolist()
globalmin = list(mdrizsky_val['globalmin'])
globalmin_match = list(mdrizsky_val['globalmin_match'])
match = list(mdrizsky_val['match'])
local = list(mdrizsky_val['local'])

# Plotting code: 
fig = plt.figure(figsize=[7, 7])
plt.scatter(index, globalmin_match, color='magenta', label='Globalmin + Match')
plt.scatter(index, match, color='navy', label='Match')
plt.scatter(index, local, color='olive', label='Local')
plt.scatter(index, globalmin, color='orange', label='Globalmin')
plt.xlabel('Individual Images')
plt.ylabel('MDRIZSKY Value')
plt.legend(loc='best')
plt.xticks(index)
plt.tight_layout()
plt.show()
../../../_images/4377a2c5ebf78b6bc2c76f277e648a4c8fe4bf0675254d885c55bd36e9b49bab.png ../../../_images/c51efba192df3bc8eef2a3a909c6e414fb48ab929cf599ef47389c808005dcb9.png ../../../_images/f355ea23dc916ad39779a727bea4d0a5b96fcc8efacbdb6a7480bb85af40048b.png ../../../_images/983899b427dccde0bf6712f0475b6ebbf6bd0ee7c66cca08e0186cf5396eb7b8.png

5. Display the ‘sky matched’ science mosaic and weight image #

Finally, we display the science and weight images for the combined mosaic.

sci = fits.getdata('f160w_match_drz_sci.fits')
fig = plt.figure(figsize=(10, 10), dpi=130)
plt.imshow(sci, vmin=0.5, vmax=3, cmap='Greys_r', origin='lower')
plt.colorbar(shrink=0.85, pad=0.01)
plt.show()
../../../_images/f0e21ad43b9bd8df3210974cd0119cfa5f161c74c0c7f6de9d3e5f9fb7c693e0.png
sci = fits.getdata('f160w_match_drz_wht.fits')
fig = plt.figure(figsize=(10, 10), dpi=130)
plt.imshow(sci, vmin=0, vmax=4000, cmap='Greys_r', origin='lower')
plt.colorbar(shrink=0.85, pad=0.01)
plt.show()
../../../_images/9f0d608c6af547146968c3649d031b4ace18ead2c01fa04c13f79e173e8cf93f.png

6. Conclusion #

Thank you for going through this notebook. You should now have all the necessary tools for assessing the
appropriate skymethod parameter to use when combining images. After completing this notebook you
should be more familiar with:
    • How to effectively use astroquery to download FLT and DRZ files.
    • Checking the WCS of images and aligning them to a reference catalog with TweakReg.
    • Combining data with AstroDrizzle taking into account the skymethod

Congratulations, you have completed the notebook!

Additional Resources #

About this Notebook #

Created: 14 Dec 2018; C. Martlin & J. Mack
Updated: 16 Nov 2023; K. Huynh & J. Mack
Updated: 23 Jul 2024; J. Mack & B. Kuhn

Source: https://github.com/spacetelescope/hst_notebooks

Citations #

If you use Python packages for published research, please cite the authors. Follow these links for more
information about citing packages such as astropy, astroquery, matplotlib, pandas, etc.:

Top of Page Space Telescope Logo