CANDELS-GOODS-N catalogue: the catalogue comes from dmu0_CANDELS-GOODS-S
.
In the catalogue, we keep:
We don't know when the maps have been observed. We will use the year of the reference paper.
from herschelhelp_internal import git_version
print("This notebook was run with herschelhelp_internal version: \n{}".format(git_version()))
%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
OUT_DIR = os.environ.get('TMP_DIR', "./data_tmp")
try:
os.makedirs(OUT_DIR)
except FileExistsError:
pass
RA_COL = "candels_ra"
DEC_COL = "candels_dec"
imported_columns = OrderedDict({
'ID': "candels_id",
'RA': "candels_ra",
'DEC': "candels_dec",
'CLASS_STAR': "candels_stellarity",
#HST data
'ACS_F435W_FLUX': "f_acs_f435w",
'ACS_F435W_FLUXERR': "ferr_acs_f435w",
'ACS_F606W_FLUX': "f_acs_f606w",
'ACS_F606W_FLUXERR': "ferr_acs_f606w",
'ACS_F775W_FLUX': "f_acs_f775w",
'ACS_F775W_FLUXERR': "ferr_acs_f775w",
'ACS_F814W_FLUX': "f_acs_f814w",
'ACS_F814W_FLUXERR': "ferr_acs_f814w",
'ACS_F850LP_FLUX': "f_acs_f850lp",
'ACS_F850LP_FLUXERR': "ferr_acs_f850lp",
'WFC3_F098M_FLUX': "f_wfc3_f098m",
'WFC3_F098M_FLUXERR': "ferr_wfc3_f098m",
'WFC3_F105W_FLUX': "f_wfc3_f105w",
'WFC3_F105W_FLUXERR': "ferr_wfc3_f105w",
'WFC3_F125W_FLUX': "f_wfc3_f125w",
'WFC3_F125W_FLUXERR': "ferr_wfc3_f125w",
'WFC3_F160W_FLUX': "f_wfc3_f160w",
'WFC3_F160W_FLUXERR': "ferr_wfc3_f160w",
#ISAAC?
'ISAAC_KS_FLUX':"f_isaac_k",
'ISAAC_KS_FLUXERR':"ferr_isaac_k",
#HAWKI WIRCAM
'HAWKI_KS_FLUX': "f_hawki_k",# 33 WIRCAM_K_FLUX Flux density (in μJy) in the Ks-band (CFHT/WIRCam) (3)
'HAWKI_KS_FLUXERR': "ferr_hawki_k",# 34 WIRCAM_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-GOODS-S/data/hlsp_candels_hst_wfc3_goodss-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
# 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
mask = np.isclose(catalogue[col], -99.)
catalogue[col][mask] = np.nan
catalogue[errcol][mask] = 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:])))
# Band-flag column
if "ap" not in col:
catalogue.add_column(Column(np.zeros(len(catalogue), dtype=bool), name="flag{}".format(col[1:])))
catalogue['candels_stellarity'] = catalogue['candels_stellarity'].astype(float)
catalogue[:10].show_in_notebook()
We remove duplicated objects from the input catalogues.
SORT_COLS = ["ferr_acs_f435w","ferr_acs_f606w","ferr_acs_f775w","ferr_acs_f814w","ferr_acs_f850lp",
"ferr_wfc3_f098m","ferr_wfc3_f105w","ferr_wfc3_f125w","ferr_wfc3_f160w",
"ferr_isaac_k","ferr_hawki_k",
"ferr_candels-irac_i1","ferr_candels-irac_i2","ferr_candels-irac_i3","ferr_candels-irac_i4"]
FLAG_NAME = 'candels_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])))
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.
gaia = Table.read("../../dmu0/dmu0_GAIA/data/GAIA_CDFS-SWIRE.fits")
gaia_coords = SkyCoord(gaia['ra'], gaia['dec'])
nb_astcor_diag_plot(catalogue[RA_COL], catalogue[DEC_COL],
gaia_coords.ra, gaia_coords.dec)
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))
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)
nb_astcor_diag_plot(catalogue[RA_COL], catalogue[DEC_COL],
gaia_coords.ra, gaia_coords.dec)
catalogue.add_column(
gaia_flag_column(SkyCoord(catalogue[RA_COL], catalogue[DEC_COL]), epoch, gaia)
)
GAIA_FLAG_NAME = "candels_flag_gaia"
catalogue['flag_gaia'].name = GAIA_FLAG_NAME
print("{} sources flagged.".format(np.sum(catalogue[GAIA_FLAG_NAME] > 0)))
catalogue.write("{}/CANDELS.fits".format(OUT_DIR), overwrite=True)