HDF-N master catalogue

Preparation of CANDELS-GOODS-N data

CANDELS-GOODS-N catalogue: the catalogue comes from dmu0_CANDELS-GOODS-N.

In the catalogue, we keep:

  • The identifier (it's unique in the catalogue);
  • The position;
  • The stellarity;
  • The total magnitude.

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: 
33f5ec7 (Wed Dec 6 16:56:17 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-gn_ra"
DEC_COL = "candels-gn_dec"

I - Column selection

In [4]:
imported_columns = OrderedDict({
        'ID': "candels-gn_id",
        'RA': "candels-gn_ra",
        'DEC': "candels-gn_dec",
        'CLASS_STAR':  "candels-gn_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_F105W_FLUX': "f_acs_f105w", 
        'WFC3_F105W_FLUXERR': "ferr_acs_f105w", 
        'WFC3_F125W_FLUX': "f_acs_f125w", 
        'WFC3_F125W_FLUXERR': "ferr_acs_f125w", 
        'WFC3_F140W_FLUX': "f_acs_f140w", 
        'WFC3_F140W_FLUXERR': "ferr_acs_f140w", 
        'WFC3_F160W_FLUX': "f_acs_f160w", 
        'WFC3_F160W_FLUXERR': "ferr_acs_f160w", 
    #MOIRCS?
        'MOIRCS_K_FLUX':"f_moircs_k",
        'MOIRCS_K_FLUXERR':"ferr_moircs_k",
    #CFHT WIRCAM
        'CFHT_Ks_FLUX': "f_candels-wircam_k",# 33 WIRCAM_K_FLUX Flux density (in μJy) in the Ks-band (CFHT/WIRCam) (3)
        'CFHT_Ks_FLUXERR': "ferr_candels-wircam_k",# 34 WIRCAM_K_FLUXERR 
    #Spitzer/IRAC
        'IRAC_CH1_SCANDELS_FLUX': "f_candels-irac_i1",# 47 IRAC_CH1_FLUX Flux density (in μJy) in the 3.6μm-band (Spitzer/IRAC) (3)
        'IRAC_CH1_SCANDELS_FLUXERR': "ferr_candels-irac_i1",# 48 IRAC_CH1_FLUXERR Flux uncertainty (in μJy) in the 3.6μm-band (Spitzer/IRAC) (3)
        'IRAC_CH2_SCANDELS_FLUX': "f_candels-irac_i2",# 49 IRAC_CH2_FLUX Flux density (in μJy) in the 4.5μm-band (Spitzer/IRAC) (3)
        'IRAC_CH2_SCANDELS_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-N/data/CANDELS.GOODSN.F160W.v1_1.photom.fits")[list(imported_columns)]
for column in imported_columns:
    catalogue[column].name = imported_columns[column]

epoch = 2011

# Clean table metadata
catalogue.meta = None
WARNING: UnitsWarning: '0 use, gt 1 no-use' did not parse as fits unit: At col 2, Unit 'use' not supported by the FITS standard. Did you mean uS or us? [astropy.units.core]
WARNING: UnitsWarning: '0 galaxy, 1 star' did not parse as fits unit: At col 2, Unit 'galaxy' not supported by the FITS standard.  [astropy.units.core]
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:])))
        

        
        # 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: divide by zero encountered in log10
  magnitudes = 2.5 * (23 - np.log10(fluxes)) - 48.6
/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: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-gn_idcandels-gn_racandels-gn_deccandels-gn_stellarityf_acs_f435wferr_acs_f435wf_acs_f606wferr_acs_f606wf_acs_f775wferr_acs_f775wf_acs_f814wferr_acs_f814wf_acs_f850lpferr_acs_f850lpf_acs_f105wferr_acs_f105wf_acs_f125wferr_acs_f125wf_acs_f140wferr_acs_f140wf_acs_f160wferr_acs_f160wf_moircs_kferr_moircs_kf_candels-wircam_kferr_candels-wircam_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_acs_f435wmerr_acs_f435wflag_acs_f435wm_acs_f606wmerr_acs_f606wflag_acs_f606wm_acs_f775wmerr_acs_f775wflag_acs_f775wm_acs_f814wmerr_acs_f814wflag_acs_f814wm_acs_f850lpmerr_acs_f850lpflag_acs_f850lpm_acs_f105wmerr_acs_f105wflag_acs_f105wm_acs_f125wmerr_acs_f125wflag_acs_f125wm_acs_f140wmerr_acs_f140wflag_acs_f140wm_acs_f160wmerr_acs_f160wflag_acs_f160wm_moircs_kmerr_moircs_kflag_moircs_km_candels-wircam_kmerr_candels-wircam_kflag_candels-wircam_km_candels-irac_i1merr_candels-irac_i1flag_candels-irac_i1m_candels-irac_i2merr_candels-irac_i2flag_candels-irac_i2m_candels-irac_i3merr_candels-irac_i3flag_candels-irac_i3m_candels-irac_i4merr_candels-irac_i4flag_candels-irac_i4
0 galaxy, 1 star
01189.1521617862.091777640-0.030410.03046-0.016370.039210.0360.0591-0.0010564894254393.4-0.079840.07474-0.079280.054250.005830.03354-2e-0540607499435.50.731550.379620.010841444.70263-0.202610.09029-0.084550.13695-0.189520.13653-0.377121.00009-0.350611.52074nan-1.08752136787Falsenan-2.60059356069False27.50924374811.78241693614Falsenan-6.71028966435e+13Falsenan-1.01638181292Falsenan-0.742951426692False29.48582861316.2462422483Falsenan-2.20445161609e+15False24.23938996340.563416277835False28.8124267945144701.65595Falsenan-0.483841478346Falsenan-1.75862298334Falsenan-0.782163170302Falsenan-2.8792795954Falsenan-4.70928517733False
12189.1488335662.092027430-0.040390.128650.025560.154450.051390.23871-0.00188264842218594.0-0.180390.3039-0.04240.250530.238430.15215-0.00038165724690769.01.097670.388180.009921395.405240.008360.085570.053140.138610.625880.13547-0.547970.99801-1.13071.33768nan-3.45828083046False27.88109787636.56071818564False27.12280345585.04331756057Falsenan-1.5295148153e+14Falsenan-1.82912152905Falsenan-6.41531819288False25.4565977530.692843868448Falsenan-4.73508675765e+14False23.79882051290.383959732855False28.9087208196152726.006994False29.094484306411.1132113686False27.08644612482.8320266342False24.40877231530.235004607367Falsenan-1.97743597224Falsenan-1.28448536869False
23189.1513383462.0921321800.016980.0183-0.010120.0216-0.059570.03347-0.0010737153131237.0-0.036460.043460.024560.03178-0.008870.01767-2e-0523193730332.70.367650.045150.010551448.69502-0.010340.089980.113920.146620.271290.144990.900091.016760.474531.5545328.32515578521.17013972598Falsenan-2.3173816228Falsenan-0.61003174036Falsenan-3.76995324338e+13Falsenan-1.29418802685False27.92442909381.40491435616Falsenan-2.1629040291Falsenan-1.25911363728e+15False24.98641357420.133336025146False28.8418688509149090.107381Falsenan-9.44821505843False26.25850005931.39738976775False25.31641553610.580267950635False24.01428515821.22646973475False24.70934081523.55680252541False
34189.1496060362.092117040-0.020570.067940.067380.08303-0.081150.12626-0.00202142937077016.0-0.02380.163210.162670.12396-0.081330.06801-0.0003489442699180.22.038120.369950.013631618.731090.00570.093250.555630.134830.300430.13159-0.068760.975091.998781.36655nan-3.58604364372False26.82867248341.33791447137Falsenan-1.68927976849Falsenan-7.68277027319e+13Falsenan-7.44550445288False25.87173133330.827367430638Falsenan-0.907917364879Falsenan-2.85621108092e+14False23.12692562320.197077752512False28.5637603604128944.603828False29.510312860817.7622633498False24.53803578390.263466357986False25.20564175550.475558456826Falsenan-15.3968952283False23.1480875120.742309213927False
45189.1480845462.0924969900.031490.04246-0.055970.05101-0.020360.07891-0.0016187996244750.6-0.065620.102560.227970.080410.151020.04451-0.0003255063541332.51.882130.407440.015391705.735920.415020.100398.863120.127744.063940.125484.952550.964672.103681.2926327.65456834841.4639682202Falsenan-0.989519453363Falsenan-4.20802769732Falsenan-5.93420551606e+13Falsenan-1.69693851204False25.50530575190.382962882066False25.95241383520.319998135835Falsenan-1.86826501209e+14False23.21337595710.235038153192False28.4319034504120336.53308False24.85482743480.26263085537False21.53103342660.0156482077187False22.37763178150.033523668896False22.1629278280.211482396875False23.09255080480.667142906885False
56189.1487053962.0926973500.000720.05542-0.009560.06588-0.046160.10169-0.0039114216919405.0-0.162950.12953-0.023330.098920.021090.05702-0.0002271471096072.11.074390.247420.012491542.031640.142650.09545-4.623120.12194-1.854030.11972-3.12530.87925-2.15861.2391231.756668758983.5715284274Falsenan-7.48203987128Falsenan-2.39186556893Falsenan-3.17972934857e+13Falsenan-0.863058672Falsenan-4.60355873873False28.08980855072.93545179684Falsenan-3.52721620905e+14False23.82209510640.250032904049False28.6585939041134046.403557False26.014320560.726488052886Falsenan-0.028637515965Falsenan-0.0701090804537Falsenan-0.305453415043Falsenan-0.623254630798False
67189.1463635962.0928818100.110110.144990.003570.169211.091220.27022-0.01357292273460385.01.984030.352712.746720.327873.652310.15878-0.00097182889756397.04.561032.854840.017111758.972572.16760.1079951.329740.0999339.136220.1012833.169820.720922.668821.0426926.29543309341.42966935181False30.018329459751.4614630832False23.8052192070.268862041797Falsenan-2.3384810437e+13False23.15612941320.193016243091False22.80296402550.129601972336False22.4935809190.0472011397147Falsenan-2.04711371134e+14False22.2523426780.679584029658False28.3168749761111617.779218False23.06005214410.0540914618711False19.62407733890.00211373794104False19.91855280820.00280975942025False20.09814221310.0235969694744False20.5114277150.0499402387658False
78189.1450998162.0934018800.01780.02649-0.020020.03159-0.010460.04839-0.0022952742979131.0-0.043170.062160.037310.046880.012650.02578-5e-0533003853966.81.49360.212410.011421471.11023-0.109970.084890.460670.145880.209610.138882.108530.908425.193031.3559928.27394999421.61579505978Falsenan-1.71320712829Falsenan-5.02282743291Falsenan-2.50065336198e+13Falsenan-1.56333941366False27.47043687741.36422710477False28.64477368622.21267030503Falsenan-7.16669582967e+14False23.46441423760.154406284984False28.7558347402139863.190709Falsenan-0.838120818604False24.7415251730.343819214514False25.59647000510.71936951537False23.09005053870.467768769297False22.11144792120.283504512065False
89189.1442804262.093531380-0.007890.04863-0.028970.05807-0.092210.08945-0.00363101034871370.00.064390.116540.255040.092690.054820.05020.000163222445815.31.963270.459210.013951625.22483-0.02310.094011.175440.179311.100550.165431.081350.94592-2.243091.45174nan-6.69193303389Falsenan-2.17634454299Falsenan-1.05323829862Falsenan-3.02196192257e+13False26.87795393731.96508304554False25.38347925070.394592569083False27.0526524220.994234904758False33.96.8642898375e+14False23.16754992410.253954332612False28.538564481126492.146151Falsenan-4.41861734239False23.7244988360.16562594337False23.79597555470.16320325324False23.81508428860.949756869473Falsenan-0.702694353724False
910189.1549121762.0941116100.021940.007540.0850.009290.255590.015530.281420.044710.347150.02010.407750.021160.508320.008912e-059395352460.950.47470.038880.010881479.211050.542320.09135-0.027450.151040.069790.14957-0.633391.0126-1.799541.5249628.04690844190.373129032993False26.57645268570.118664580497False25.38114035510.065970825384False25.27661260320.172494015048False25.0487070760.0628641731691False24.87401507570.0563437844088False24.63465700630.0190311409828False35.64742501085.10043716166e+14False24.70895192070.088926529684False28.8084277616147613.326421False24.56436094770.182884648002Falsenan-5.97412008622False26.79051700422.3268887254Falsenan-1.73576545405Falsenan-0.920070841886False

II - Removal of duplicated sources

We remove duplicated objects from the input catalogues.

In [7]:
SORT_COLS = ["merr_acs_f435w","ferr_acs_f606w",
             "ferr_acs_f775w","ferr_acs_f814w",
             "ferr_acs_f850lp", "ferr_acs_f105w",
             "ferr_acs_f125w","ferr_acs_f140w","ferr_acs_f160w"]
FLAG_NAME = 'candels-gn_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 35445 sources.
The cleaned catalogue has 35423 sources (22 removed).
The cleaned catalogue has 21 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_HDF-N.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.02082349079728374 arcsec
Dec correction: -0.02865639995377478 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-gn_flag_gaia"

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

V - Saving to disk

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