EGS master catalogue

Preparation of CANDELS-EGS data

CANDELS-EGS catalogue: the catalogue comes from dmu0_CANDELS-EGS.

In the catalogue, we keep:

  • The identifier (it's unique in the catalogue);
  • The position;
  • The stellarity;
  • The magnitude for each band in 2 arcsec aperture (aperture 10).
  • The kron magnitude to be used as total magnitude (no “auto” magnitude is provided).

We don't know when the maps have been observed. We will use the year of the reference paper.

In [1]:
from herschelhelp_internal import git_version
print("This notebook was run with herschelhelp_internal version: \n{}".format(git_version()))
This notebook was run with herschelhelp_internal version: 
44f1ae0 (Thu Nov 30 18:27:54 2017 +0000)
In [2]:
%matplotlib inline
#%config InlineBackend.figure_format = 'svg'

import matplotlib.pyplot as plt
plt.rc('figure', figsize=(10, 6))

from collections import OrderedDict
import os

from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.table import Column, Table
import numpy as np

from herschelhelp_internal.flagging import  gaia_flag_column
from herschelhelp_internal.masterlist import nb_astcor_diag_plot, remove_duplicates
from herschelhelp_internal.utils import astrometric_correction, flux_to_mag
In [3]:
OUT_DIR =  os.environ.get('TMP_DIR', "./data_tmp")
try:
    os.makedirs(OUT_DIR)
except FileExistsError:
    pass

RA_COL = "candels-egs_ra"
DEC_COL = "candels-egs_dec"

I - Column selection

In [4]:
imported_columns = OrderedDict({
        'ID': "candels-egs_id",
        'RA': "candels-egs_ra",
        'DEC': "candels-egs_dec",
        'CLASS_STAR':  "candels-egs_stellarity",
    #HST data
        'FLUX_APER_10_F606W': "f_ap_acs_f606w", 
        'FLUXERR_APER_10_F606W': "ferr_ap_acs_f606w", 
        'FLUX_AUTO_F606W': "f_acs_f606w", 
        'FLUXERR_AUTO_F606W': "ferr_acs_f606w",
        'FLUX_APER_10_F814W': "f_ap_acs_f814w", 
        'FLUXERR_APER_10_F814W': "ferr_ap_acs_f814w", 
        'FLUX_AUTO_F814W': "f_acs_f814w", 
        'FLUXERR_AUTO_F814W': "ferr_acs_f814w",
        'FLUX_APER_10_F125W': "f_ap_wfc3_f125w", 
        'FLUXERR_APER_10_F125W': "ferr_ap_wfc3_f125w", 
        'FLUX_AUTO_F125W': "f_wfc3_f125w", 
        'FLUXERR_AUTO_F125W': "ferr_wfc3_f125w",
        'FLUX_APER_10_F140W': "f_ap_wfc3_f140w", 
        'FLUXERR_APER_10_F140W': "ferr_ap_wfc3_f140w", 
        'FLUX_AUTO_F140W': "f_wfc3_f140w", 
        'FLUXERR_AUTO_F140W': "ferr_wfc3_f140w",
        'FLUX_APER_10_F160W': "f_ap_wfc3_f160w", 
        'FLUXERR_APER_10_F160W': "ferr_ap_wfc3_f160w", 
        'FLUX_AUTO_F160W': "f_wfc3_f160w", 
        'FLUXERR_AUTO_F160W': "ferr_wfc3_f160w",
    #CFHT Megacam
        'CFHT_u_FLUX': "f_candels-megacam_u", # 9 CFHT_u_FLUX Flux density (in μJy) in the u*-band (CFHT/MegaCam) (3)
        'CFHT_u_FLUXERR': "ferr_candels-megacam_u",# 10 CFHT_u_FLUXERR Flux uncertainty (in μJy) in the u*-band (CFHT/MegaCam) (3)
        'CFHT_g_FLUX': "f_candels-megacam_g",# 11 CFHT_g_FLUX Flux density (in μJy) in the g'-band (CFHT/MegaCam) (3)
        'CFHT_g_FLUXERR': "ferr_candels-megacam_g",# 12 CFHT_g_FLUXERR Flux uncertainty (in μJy) in the g'-band (CFHT/MegaCam) (3)
        'CFHT_r_FLUX': "f_candels-megacam_r",# 13 CFHT_r_FLUX Flux density (in μJy) in the r'-band (CFHT/MegaCam) (3)
        'CFHT_r_FLUXERR': "ferr_candels-megacam_r",# 14 CFHT_r_FLUXERR Flux uncertainty (in μJy) in the r'-band (CFHT/MegaCam) (3)
        'CFHT_i_FLUX': "f_candels-megacam_i",# 15 CFHT_i_FLUX Flux density (in μJy) in the i'-band (CFHT/MegaCam) (3)
        'CFHT_i_FLUXERR': "ferr_candels-megacam_i",# 16 CFHT_i_FLUXERR Flux uncertainty (in μJy) in the i'-band (CFHT/MegaCam) (3)
        'CFHT_z_FLUX': "f_candels-megacam_z",# 17 CFHT_z_FLUX Flux density (in μJy) in the z'-band (CFHT/MegaCam) (3)
        'CFHT_z_FLUXERR': "ferr_candels-megacam_z",# 18 CFHT_z_FLUXERR 
    #CFHT WIRCAM
        'WIRCAM_J_FLUX': "f_candels-wircam_j",# 29 WIRCAM_J_FLUX Flux density (in μJy) in the J-band (CFHT/WIRCam) (3)
        'WIRCAM_J_FLUXERR': "ferr_candels-wircam_j",# 30 WIRCAM_J_FLUXERR Flux uncertainty (in μJy) in the J-band (CFHT/WIRCam) (3)
        'WIRCAM_H_FLUX': "f_candels-wircam_h",# 31 WIRCAM_H_FLUX Flux density (in μJy) in the H-band (CFHT/WIRCam) (3)
        'WIRCAM_H_FLUXERR': "ferr_candels-wircam_h",# 32 WIRCAM_H_FLUXERR Flux uncertainty (in μJy) in the H-band (CFHT/WIRCam) (3)
        'WIRCAM_K_FLUX': "f_candels-wircam_k",# 33 WIRCAM_K_FLUX Flux density (in μJy) in the Ks-band (CFHT/WIRCam) (3)
        'WIRCAM_K_FLUXERR': "ferr_candels-wircam_k",# 34 WIRCAM_K_FLUXERR 
    #Mayall/Newfirm
        'NEWFIRM_J1_FLUX': "f_candels-newfirm_j1",# 35 NEWFIRM_J1_FLUX Flux density (in μJy) in the J1-band (Mayall/NEWFIRM) (3)
        'NEWFIRM_J1_FLUXERR': "ferr_candels-newfirm_j1",# 36 NEWFIRM_J1_FLUXERR Flux uncertainty (in μJy) in the J1-band (Mayall/NEWFIRM) (3)
        'NEWFIRM_J2_FLUX': "f_candels-newfirm_j2",# 37 NEWFIRM_J2_FLUX Flux density (in μJy) in the J2-band (Mayall/NEWFIRM) (3)
        'NEWFIRM_J2_FLUXERR': "ferr_candels-newfirm_j2",# 38 NEWFIRM_J2_FLUXERR Flux uncertainty (in μJy) in the J2-band (Mayall/NEWFIRM) (3)
        'NEWFIRM_J3_FLUX': "f_candels-newfirm_j3",# 39 NEWFIRM_J3_FLUX Flux density (in μJy) in the J3-band (Mayall/NEWFIRM) (3)
        'NEWFIRM_J3_FLUXERR': "ferr_candels-newfirm_j3",# 40 NEWFIRM_J3_FLUXERR Flux uncertainty (in μJy) in the J3-band (Mayall/NEWFIRM) (3)
        'NEWFIRM_H1_FLUX': "f_candels-newfirm_h1",# 41 NEWFIRM_H1_FLUX Flux density (in μJy) in the H1-band (Mayall/NEWFIRM) (3)
        'NEWFIRM_H1_FLUXERR': "ferr_candels-newfirm_h1",# 42 NEWFIRM_H1_FLUXERR Flux uncertainty (in μJy) in the H1-band (Mayall/NEWFIRM) (3)
        'NEWFIRM_H2_FLUX': "f_candels-newfirm_h2",# 43 NEWFIRM_H2_FLUX Flux density (in μJy) in the H2-band (Mayall/NEWFIRM) (3)
        'NEWFIRM_H2_FLUXERR': "ferr_candels-newfirm_h2",# 44 NEWFIRM_H2_FLUXERR Flux uncertainty (in μJy) in the H2-band (Mayall/NEWFIRM) (3)
        'NEWFIRM_K_FLUX': "f_candels-newfirm_k",# 45 NEWFIRM_K_FLUX Flux density (in μJy) in the K-band (Mayall/NEWFIRM) (3)
        'NEWFIRM_K_FLUXERR': "ferr_candels-newfirm_k",# 46 NEWFIRM_K_FLUXERR 
    #Spitzer/IRAC
        'IRAC_CH1_FLUX': "f_candels-irac_i1",# 47 IRAC_CH1_FLUX Flux density (in μJy) in the 3.6μm-band (Spitzer/IRAC) (3)
        'IRAC_CH1_FLUXERR': "ferr_candels-irac_i1",# 48 IRAC_CH1_FLUXERR Flux uncertainty (in μJy) in the 3.6μm-band (Spitzer/IRAC) (3)
        'IRAC_CH2_FLUX': "f_candels-irac_i2",# 49 IRAC_CH2_FLUX Flux density (in μJy) in the 4.5μm-band (Spitzer/IRAC) (3)
        'IRAC_CH2_FLUXERR': "ferr_candels-irac_i2",# 50 IRAC_CH2_FLUXERR Flux uncertainty (in μJy) in the 4.5μm-band (Spitzer/IRAC) (3)
        'IRAC_CH3_FLUX': "f_candels-irac_i3",# 51 IRAC_CH3_FLUX Flux density (in μJy) in the 5.8μm-band (Spitzer/IRAC) (3)
        'IRAC_CH3_FLUXERR': "ferr_candels-irac_i3",# 52 IRAC_CH3_FLUXERR Flux uncertainty (in μJy) in the 5.8μm-band (Spitzer/IRAC) (3)
        'IRAC_CH4_FLUX': "f_candels-irac_i4",# 53 IRAC_CH4_FLUX Flux density (in μJy) in the 8.0μm-band (Spitzer/IRAC) (3)
        'IRAC_CH4_FLUXERR': "ferr_candels-irac_i4"# 54 IRAC_CH4_FLUXERR
    
    
    })


catalogue = Table.read("../../dmu0/dmu0_CANDELS-EGS/data/hlsp_candels_hst_wfc3_egs-tot-multiband_f160w_v1_cat.fits")[list(imported_columns)]
for column in imported_columns:
    catalogue[column].name = imported_columns[column]

epoch = 2011

# Clean table metadata
catalogue.meta = None
In [5]:
# Adding flux and band-flag columns
for col in catalogue.colnames:
    if col.startswith('f_'):
        
        errcol = "ferr{}".format(col[1:])
        
        # Some object have a magnitude to 0, we suppose this means missing value
        #catalogue[col][catalogue[col] <= 0] = np.nan
        #catalogue[errcol][catalogue[errcol] <= 0] = np.nan  
        

        mag, error = flux_to_mag(np.array(catalogue[col])*1.e-6, np.array(catalogue[errcol])*1.e-6)
        
        # Fluxes are added in µJy
        catalogue.add_column(Column(mag, name="m{}".format(col[1:])))
        catalogue.add_column(Column(error, name="m{}".format(errcol[1:])))
        
        # Add nan col for aperture fluxes
        if ('wfc' not in col) & ('acs' not in col):
            catalogue.add_column(Column(np.full(len(catalogue), np.nan), name="m_ap{}".format(col[1:])))
            catalogue.add_column(Column(np.full(len(catalogue), np.nan), name="merr_ap{}".format(col[1:])))
            catalogue.add_column(Column(np.full(len(catalogue), np.nan), name="f_ap{}".format(col[1:])))
            catalogue.add_column(Column(np.full(len(catalogue), np.nan), name="ferr_ap{}".format(col[1:])))
        
        # Band-flag column
        if "ap" not in col:
            catalogue.add_column(Column(np.zeros(len(catalogue), dtype=bool), name="flag{}".format(col[1:])))
        
# TODO: Set to True the flag columns for fluxes that should not be used for SED fitting.
/opt/herschelhelp_internal/herschelhelp_internal/utils.py:76: RuntimeWarning: invalid value encountered in log10
  magnitudes = 2.5 * (23 - np.log10(fluxes)) - 48.6
/opt/herschelhelp_internal/herschelhelp_internal/utils.py:76: RuntimeWarning: divide by zero encountered in log10
  magnitudes = 2.5 * (23 - np.log10(fluxes)) - 48.6
/opt/herschelhelp_internal/herschelhelp_internal/utils.py:80: RuntimeWarning: divide by zero encountered in true_divide
  errors = 2.5 / np.log(10) * errors_on_fluxes / fluxes
In [6]:
catalogue[:10].show_in_notebook()
Out[6]:
<Table length=10>
idxcandels-egs_idcandels-egs_racandels-egs_deccandels-egs_stellarityf_ap_acs_f606wferr_ap_acs_f606wf_acs_f606wferr_acs_f606wf_ap_acs_f814wferr_ap_acs_f814wf_acs_f814wferr_acs_f814wf_ap_wfc3_f125wferr_ap_wfc3_f125wf_wfc3_f125wferr_wfc3_f125wf_ap_wfc3_f140wferr_ap_wfc3_f140wf_wfc3_f140wferr_wfc3_f140wf_ap_wfc3_f160wferr_ap_wfc3_f160wf_wfc3_f160wferr_wfc3_f160wf_candels-megacam_uferr_candels-megacam_uf_candels-megacam_gferr_candels-megacam_gf_candels-megacam_rferr_candels-megacam_rf_candels-megacam_iferr_candels-megacam_if_candels-megacam_zferr_candels-megacam_zf_candels-wircam_jferr_candels-wircam_jf_candels-wircam_hferr_candels-wircam_hf_candels-wircam_kferr_candels-wircam_kf_candels-newfirm_j1ferr_candels-newfirm_j1f_candels-newfirm_j2ferr_candels-newfirm_j2f_candels-newfirm_j3ferr_candels-newfirm_j3f_candels-newfirm_h1ferr_candels-newfirm_h1f_candels-newfirm_h2ferr_candels-newfirm_h2f_candels-newfirm_kferr_candels-newfirm_kf_candels-irac_i1ferr_candels-irac_i1f_candels-irac_i2ferr_candels-irac_i2f_candels-irac_i3ferr_candels-irac_i3f_candels-irac_i4ferr_candels-irac_i4m_ap_acs_f606wmerr_ap_acs_f606wm_acs_f606wmerr_acs_f606wflag_acs_f606wm_ap_acs_f814wmerr_ap_acs_f814wm_acs_f814wmerr_acs_f814wflag_acs_f814wm_ap_wfc3_f125wmerr_ap_wfc3_f125wm_wfc3_f125wmerr_wfc3_f125wflag_wfc3_f125wm_ap_wfc3_f140wmerr_ap_wfc3_f140wm_wfc3_f140wmerr_wfc3_f140wflag_wfc3_f140wm_ap_wfc3_f160wmerr_ap_wfc3_f160wm_wfc3_f160wmerr_wfc3_f160wflag_wfc3_f160wm_candels-megacam_umerr_candels-megacam_um_ap_candels-megacam_umerr_ap_candels-megacam_uf_ap_candels-megacam_uferr_ap_candels-megacam_uflag_candels-megacam_um_candels-megacam_gmerr_candels-megacam_gm_ap_candels-megacam_gmerr_ap_candels-megacam_gf_ap_candels-megacam_gferr_ap_candels-megacam_gflag_candels-megacam_gm_candels-megacam_rmerr_candels-megacam_rm_ap_candels-megacam_rmerr_ap_candels-megacam_rf_ap_candels-megacam_rferr_ap_candels-megacam_rflag_candels-megacam_rm_candels-megacam_imerr_candels-megacam_im_ap_candels-megacam_imerr_ap_candels-megacam_if_ap_candels-megacam_iferr_ap_candels-megacam_iflag_candels-megacam_im_candels-megacam_zmerr_candels-megacam_zm_ap_candels-megacam_zmerr_ap_candels-megacam_zf_ap_candels-megacam_zferr_ap_candels-megacam_zflag_candels-megacam_zm_candels-wircam_jmerr_candels-wircam_jm_ap_candels-wircam_jmerr_ap_candels-wircam_jf_ap_candels-wircam_jferr_ap_candels-wircam_jflag_candels-wircam_jm_candels-wircam_hmerr_candels-wircam_hm_ap_candels-wircam_hmerr_ap_candels-wircam_hf_ap_candels-wircam_hferr_ap_candels-wircam_hflag_candels-wircam_hm_candels-wircam_kmerr_candels-wircam_km_ap_candels-wircam_kmerr_ap_candels-wircam_kf_ap_candels-wircam_kferr_ap_candels-wircam_kflag_candels-wircam_km_candels-newfirm_j1merr_candels-newfirm_j1m_ap_candels-newfirm_j1merr_ap_candels-newfirm_j1f_ap_candels-newfirm_j1ferr_ap_candels-newfirm_j1flag_candels-newfirm_j1m_candels-newfirm_j2merr_candels-newfirm_j2m_ap_candels-newfirm_j2merr_ap_candels-newfirm_j2f_ap_candels-newfirm_j2ferr_ap_candels-newfirm_j2flag_candels-newfirm_j2m_candels-newfirm_j3merr_candels-newfirm_j3m_ap_candels-newfirm_j3merr_ap_candels-newfirm_j3f_ap_candels-newfirm_j3ferr_ap_candels-newfirm_j3flag_candels-newfirm_j3m_candels-newfirm_h1merr_candels-newfirm_h1m_ap_candels-newfirm_h1merr_ap_candels-newfirm_h1f_ap_candels-newfirm_h1ferr_ap_candels-newfirm_h1flag_candels-newfirm_h1m_candels-newfirm_h2merr_candels-newfirm_h2m_ap_candels-newfirm_h2merr_ap_candels-newfirm_h2f_ap_candels-newfirm_h2ferr_ap_candels-newfirm_h2flag_candels-newfirm_h2m_candels-newfirm_kmerr_candels-newfirm_km_ap_candels-newfirm_kmerr_ap_candels-newfirm_kf_ap_candels-newfirm_kferr_ap_candels-newfirm_kflag_candels-newfirm_km_candels-irac_i1merr_candels-irac_i1m_ap_candels-irac_i1merr_ap_candels-irac_i1f_ap_candels-irac_i1ferr_ap_candels-irac_i1flag_candels-irac_i1m_candels-irac_i2merr_candels-irac_i2m_ap_candels-irac_i2merr_ap_candels-irac_i2f_ap_candels-irac_i2ferr_ap_candels-irac_i2flag_candels-irac_i2m_candels-irac_i3merr_candels-irac_i3m_ap_candels-irac_i3merr_ap_candels-irac_i3f_ap_candels-irac_i3ferr_ap_candels-irac_i3flag_candels-irac_i3m_candels-irac_i4merr_candels-irac_i4m_ap_candels-irac_i4merr_ap_candels-irac_i4f_ap_candels-irac_i4ferr_ap_candels-irac_i4flag_candels-irac_i4
degdeguJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJy
01215.301153.0512060.350.06254830.03329170.05270330.02805270.45760.04052380.2914540.03263611.925320.07865671.007080.05989160.1105060.00.0787410.03.343660.05931621.72360.04816910.0121159060.008110431950.01152336320.006562994330.0332292430.00725465780.06609068810.01191694010.1262555870.02771626970.5635392070.1356712880.562492490.09093283860.9666783810.125305772-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.04.983355050.4411808555.728363990.4843716322.794061421.813017732.85265351.9586925526.90946122370.57788947114427.09540547680.57791128888False24.74878496050.096149818213225.23857494980.121577317011False23.18874269440.044356484603523.89234007190.0645693276412False26.29153535250.026.65949768510.0False22.58944472550.01926085363623.30890878650.0303428497451False28.69161026190.726795800854nannannannanFalse28.74605187390.618368130209nannannannanFalse27.59619888080.237039544554nannannannanFalse26.84964931620.195771199975nannannannanFalse26.14687348650.238346343233nannannannanFalse24.52268965870.26138949606nannannannanFalse24.52470817890.175520699075nannannannanFalse23.93679498490.140738653103nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalse22.15619542370.0961211919106nannannannanFalse22.0049234850.0918062850647nannannannanFalse22.78441012830.704515289191nannannannanFalse22.76187744270.745489564549nannannannanFalse
12215.26714353.0275530.020.1059450.03594980.08627250.02597640.1367040.03579970.1463960.02824730.5092010.8286410.09701650.1665230.1105310.00.05481490.00.2426430.07730370.2311630.05371030.004993046170.008994889450.01636936330.006525234320.1071649570.01148161010.1449537280.01616458590.1496167480.02842608650.2233603890.1138612030.3204081950.09588703510.3988384010.113377944-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.01.404192450.2065963751.018542890.2264472540.4492254560.7957133051.954811450.82668733626.33729883670.36841756962426.5603190420.326912028158False26.06054694410.28432986898325.98617697350.20949422318False24.63277688031.7668573597626.4328859931.86360103719False26.2912897520.027.05275343460.0False25.43758058280.34590499561825.49020419490.252268820176False29.65408604521.95593567557nannannannanFalse28.36492053130.432801387318nannannannanFalse26.32486801490.116325337344nannannannanFalse25.99692652690.121076404096nannannannanFalse25.96254947280.206281928228nannannannanFalse25.52748460670.553469802627nannannannanFalse25.13574096150.324923104963nannannannanFalse24.89800758390.308642644021nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalse23.5314334160.159742465578nannannannanFalse23.88005169620.241385988307nannannannanFalse24.76883910451.92316515529nannannannanFalse23.17223781460.459156493436nannannannanFalse
23215.30322753.0529180.060.04462730.03217120.06621260.02053560.1813470.03213140.1259270.02171730.3185040.06688720.2511020.0399850.1105410.00.04025670.00.3128360.05253410.2351370.03219810.02523971720.009590700270.04356243830.00782577880.04280542210.009085658940.07253241540.01277089860.1003862990.0257727150.4315633770.14932628-0.003384611340.09385088830.4142518040.125510916-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.00.1222638040.214329943-0.0361751840.239601865-0.5841945410.8903930780.6080485580.90301674627.27599846910.78269213218226.84764839540.33673718305False25.75372406130.1923727676226.14970285710.187245458715False25.14221277280.22800923905225.40037457040.172890547058False26.29119152730.027.3879045720.0False25.16170818940.18232612088925.47169756760.148673509037False27.89478878870.412562883713nannannannanFalse27.30221954920.195047194445nannannannanFalse27.32125304010.230452787785nannannannanFalse26.74866964970.191167313274nannannannanFalse26.39581389210.278746901212nannannannanFalse24.8123885430.375678190408nannannannanFalsenan-30.106058581nannannannanFalse24.85683897910.328958725774nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalse26.18175524031.90330883929nannannannanFalsenan-7.19123970615nannannannanFalsenan-1.654811768nannannannanFalse24.44015434281.61243368105nannannannanFalse
34215.30381453.0534030.050.1052140.03286140.08209440.0188210.1419750.03133570.1333490.0205820.1612690.07140860.1563350.03740260.1105110.00.03000260.00.3718050.05383760.2098810.0293591-0.003030247290.008624550890.02622474730.007730289830.05934833360.01096821760.08589585870.01340991540.09873791780.02662848870.3267097470.1326152530.3255043330.0963880792-0.09627661850.111007407-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.00.02651504240.214698195-0.07235036790.239132062-0.7171491380.878306329-0.6688534620.8978419326.34481617050.33910707433526.61421616730.248916382966False26.01947030660.23963587949626.0875255920.1675799786False25.88112276760.48075515040825.91485945510.259758575956False26.2914862280.027.70710277010.0False24.97421193540.15721529161125.59506718810.151877672629Falsenan-3.09017260141nannannannanFalse27.85322171990.320043333333nannannannanFalse26.9664786770.200655860538nannannannanFalse26.56506943580.169503290064nannannannanFalse26.41379008870.292810653736nannannannanFalse25.11459477170.44071284315nannannannanFalse25.11860806470.321507324741nannannannanFalsenan-1.25185909782nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalse27.84126918528.79144750708nannannannanFalsenan-3.58856969174nannannannanFalsenan-1.32972199189nannannannanFalsenan-1.45744852189nannannannanFalse
45215.27872153.0358690.350.1487350.03706850.07922170.02532730.1882160.0371110.1655950.028350.015010.06136220.1035140.04144980.1105260.00.05190330.00.1576390.04753570.1906890.03234110.01752286030.008647424170.04658215490.007804720660.09803100680.01051800050.1328145860.01412118510.123231150.02737679330.3416685760.1122618470.01900639570.08771124480.2484232780.127936274-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.00.4809534250.2021772120.2574545440.228326485-0.2638947960.7997422220.6869655250.82280623925.96896705550.27059274888926.6528896060.347111543665False25.71335865130.2140772107325.85238195130.185878929949False28.45904826944.4385850861826.36250227260.434758086249False26.29133886770.027.11201257230.0False25.9058408220.32740140770125.69918589690.184142258713False28.29098750350.535804163163nannannannanFalse27.2294510620.181912318285nannannannanFalse26.42159134260.116491448138nannannannanFalse26.09188556790.115438238968nannannannanFalse26.17319874660.241205049665nannannannanFalse25.06598740590.356739718729nannannannanFalse28.20275058325.01048570949nannannannanFalse25.41201927980.559146653655nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalse24.69474244550.456408266238nannannannanFalse25.37324859650.962897478592nannannannanFalsenan-3.29036077278nannannannanFalse24.30766264311.30042992068nannannannanFalse
56215.26612953.0270760.010.03669460.03521890.08002320.02351360.208030.03217130.1901830.02383410.2161030.1658770.3128620.0991070.1105310.00.04240880.00.2262810.06569060.2954990.03956140.04375268890.01001005530.0501254350.008187404830.07989018410.01072894870.1324104820.01603823710.1542833750.02906038240.4206786450.112553030.19568260.0962657183-0.03901125860.115770258-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.00.5498188730.2172760520.4284645320.2363132090.7393082980.8662195210.8861984010.89137327727.48849460521.0420725344326.64196021470.319027067453False25.60468507730.16790628834425.70207076550.136066553151False25.56334801020.83339270827625.16161795690.343934571936False26.2912897520.027.33136004040.0False25.51337977660.31519510136625.22360996120.145358340607False27.29748812870.248402549057nannannannanFalse27.14985461360.177342338215nannannannanFalse26.64376644510.145810254086nannannannanFalse26.09519408380.131509941033nannannannanFalse25.92920217340.204506216537nannannannanFalse24.8401238340.290489905011nannannannanFalse25.67111947470.534126057377nannannannanFalsenan-3.22204320126nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalse24.54945089180.429058527577nannannannanFalse24.82021280710.598821576844nannannannanFalse24.22793604811.27211597349nannannannanFalse24.03117259481.09207626385nannannannanFalse
67215.30103353.051390.370.08598740.03342490.07638130.03378650.3829790.03888350.2349510.03476761.513390.07468860.7405940.06959360.1104750.00.1158330.02.711450.05916241.29870.0566807-0.001642927060.01085384750.006321910770.00711342040.0162691530.01008702720.06374193730.01613517660.0798600540.03541279210.04929362240.146900550.5679647920.09463840720.6347936390.127215192-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-0.09648529440.48574084-0.2598035930.5341712240.2659092551.978203652.252367262.2355487326.56391295650.42204583544126.69253238570.480264492514False24.94206259790.11023378231625.47255675550.160665168791False23.45012285010.053583092991724.22604952690.102026604509False26.29183997440.026.24041923890.0False22.81699599920.023690187774223.61622789870.0473860692239Falsenan-7.17281702797nannannannanFalse29.39787909571.22167147702nannannannanFalse28.37158764150.673166613494nannannannanFalse26.8889368530.274835471698nannannannanFalse26.64417600120.481454100877nannannannanFalse27.16802316513.23561624949nannannannanFalse24.51419646320.180913230019nannannannanFalse24.39341858440.217585891326nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan-5.46597716675nannannannanFalsenan-2.23233647672nannannannanFalse25.33816636688.07721913699nannannannanFalse23.01840198531.07762896254nannannannanFalse
78215.30054253.0513230.350.1335430.03448160.0259350.01878020.5196210.0421990.06216290.01869912.279750.07846050.1880880.03635010.1104050.00.03506630.03.852630.06158090.2675540.0305174-0.0004284318130.01120058730.006700600960.007460159250.01308786590.0102892620.07059539850.01715252180.06901455670.0340795740.3805668950.1332891291.290827750.08675744382.392681120.128329128-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.08.597502710.5479775679.480716710.5750444535.130839822.044680835.207224372.4994678526.08594717930.28034357111927.86528436920.786209488051False24.61078326410.08817384613926.9161718330.326598177794False23.0052819390.037366994404425.71409727880.209830609165False26.29252814480.027.53777514010.0False22.43560674470.017354537718825.33147137960.12383984562Falsenan-28.3846408627nannannannanFalse29.33471561191.20881172291nannannannanFalse28.60782790870.853571113809nannannannanFalse26.77805901480.263800677054nannannannanFalse26.80264824320.53613946251nannannannanFalse24.94892248270.380266478659nannannannanFalse23.62282926690.0729730963453nannannannanFalse22.95278794320.0582324068301nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalse21.56406919650.0692013836989nannannannanFalse21.45789707560.0658543653465nannannannanFalse22.12452885850.432674587823nannannannanFalse22.10848427240.52115341006nannannannanFalse
89215.30049453.0510580.310.1352650.03376090.08413850.03297770.4196980.04004260.2907210.03622271.941480.07599081.073860.07350180.1104860.00.1115290.03.252540.06004721.572180.0803190.02179882860.01033392080.03738103810.008005139420.06225186590.01199282330.1916825770.0199888870.373234540.04117084672.013929130.1547357742.110680340.101330663.428623680.152856126-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.07.098298070.4036178894.930630680.4303437475.257750991.605527763.632766961.7607533926.07203640790.2709897714526.58751308690.425549336388False24.84265775090.1035880574925.24130899050.135278486329False23.17966769740.042496426843723.82263083570.0743146828962False26.2917318730.026.28153047950.0False22.61944338440.020044463414523.40874433190.0554677239438False28.05391710840.514702517073nannannannanFalse27.46837160530.232510121019nannannannanFalse26.91461906690.209167103119nannannannanFalse25.69354340140.113221862145nannannannanFalse24.97004543110.119765654172nannannannanFalse23.13988954080.0834201310763nannannannanFalse23.08894383770.0521245989405nannannannanFalse22.56220044930.0484046794302nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalse21.77211441950.0617362853256nannannannanFalse22.16774381570.0947626818825nannannannanFalse22.09799996540.331544727031nannannannanFalse22.49940615250.526241766737nannannannanFalse
910215.29973153.0511610.520.3983670.03906750.2549650.03072850.7614930.04707480.5734690.03893661.23830.07034440.8881550.05648080.1104910.00.06557530.01.654280.05584591.245070.04364290.2148480270.02023977230.2638929190.01968244840.3244129120.02193788810.4722215240.02999712530.6491257550.04973911870.8129021530.1463050990.5581667420.09570658210.9978278280.130458206-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.0-99.00.2478419990.5358248350.3532952960.570816219-0.3182852862.147418743.311924222.384326724.89929161230.10647719108125.38379858180.130853430737False24.19583521140.067119218025324.50372513440.0737178056882False23.66793531770.061677672520424.02877808730.0690456614371False26.29168273960.026.85814928470.0False23.35347745190.036652752567523.66201557770.0380578414151False25.56967157550.102281849496nannannannanFalse25.34643065750.0809796144101nannannannanFalse25.12225467180.0734211200758nannannannanFalse24.71463555380.06896967487nannannannanFalse24.36917789820.0831942987154nannannannanFalse24.12490431550.19540942577nannannannanFalse24.53309011060.186166773117nannannannanFalse23.90236097090.141951540624nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalsenan1.08573620476nannannannanFalse25.41456274182.34731976467nannannannanFalse25.02965536251.75421479496nannannannanFalsenan-7.32528450214nannannannanFalse22.59979902210.781645246147nannannannanFalse

II - Removal of duplicated sources

We remove duplicated objects from the input catalogues.

In [7]:
SORT_COLS = ['ferr_ap_acs_f606w', 'ferr_ap_acs_f814w', 'ferr_ap_wfc3_f125w', 'ferr_ap_wfc3_f140w', 'ferr_ap_wfc3_f160w']
FLAG_NAME = 'candels-egs_flag_cleaned'

nb_orig_sources = len(catalogue)

catalogue = remove_duplicates(catalogue, RA_COL, DEC_COL, sort_col=SORT_COLS,flag_name=FLAG_NAME)

nb_sources = len(catalogue)

print("The initial catalogue had {} sources.".format(nb_orig_sources))
print("The cleaned catalogue has {} sources ({} removed).".format(nb_sources, nb_orig_sources - nb_sources))
print("The cleaned catalogue has {} sources flagged as having been cleaned".format(np.sum(catalogue[FLAG_NAME])))
The initial catalogue had 41457 sources.
The cleaned catalogue has 41449 sources (8 removed).
The cleaned catalogue has 8 sources flagged as having been cleaned

III - Astrometry correction

We match the astrometry to the Gaia one. We limit the Gaia catalogue to sources with a g band flux between the 30th and the 70th percentile. Some quick tests show that this give the lower dispersion in the results.

In [8]:
gaia = Table.read("../../dmu0/dmu0_GAIA/data/GAIA_EGS.fits")
gaia_coords = SkyCoord(gaia['ra'], gaia['dec'])
In [9]:
nb_astcor_diag_plot(catalogue[RA_COL], catalogue[DEC_COL], 
                    gaia_coords.ra, gaia_coords.dec)
In [10]:
delta_ra, delta_dec =  astrometric_correction(
    SkyCoord(catalogue[RA_COL], catalogue[DEC_COL]),
    gaia_coords
)

print("RA correction: {}".format(delta_ra))
print("Dec correction: {}".format(delta_dec))
RA correction: -0.07893977393678142 arcsec
Dec correction: -0.034441607530766305 arcsec
In [11]:
catalogue[RA_COL].unit = u.deg
catalogue[DEC_COL].unit = u.deg
catalogue[RA_COL] = catalogue[RA_COL] +  delta_ra.to(u.deg)
catalogue[DEC_COL] = catalogue[DEC_COL] + delta_dec.to(u.deg)
In [12]:
nb_astcor_diag_plot(catalogue[RA_COL], catalogue[DEC_COL], 
                    gaia_coords.ra, gaia_coords.dec)

IV - Flagging Gaia objects

In [13]:
catalogue.add_column(
    gaia_flag_column(SkyCoord(catalogue[RA_COL], catalogue[DEC_COL]), epoch, gaia)
)
In [14]:
GAIA_FLAG_NAME = "candels-egs_flag_gaia"

catalogue['flag_gaia'].name = GAIA_FLAG_NAME
print("{} sources flagged.".format(np.sum(catalogue[GAIA_FLAG_NAME] > 0)))
160 sources flagged.

V - Saving to disk

In [15]:
catalogue.write("{}/CANDELS-EGS.fits".format(OUT_DIR), overwrite=True)