COSMOS master catalogue¶

This notebook presents the merge of the various pristine catalogues to produce HELP mater catalogue on COSMOS.

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))

import os
import time

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

from herschelhelp_internal.masterlist import merge_catalogues, nb_merge_dist_plot
from herschelhelp_internal.utils import coords_to_hpidx, ebv, gen_help_id, inMoc
In [3]:
TMP_DIR = os.environ.get('TMP_DIR', "./data_tmp")
OUT_DIR = os.environ.get('OUT_DIR', "./data")
SUFFIX = os.environ.get('SUFFIX', time.strftime("_%Y%m%d"))

try:
    os.makedirs(OUT_DIR)
except FileExistsError:
    pass

I - Reading the prepared pristine catalogues¶

In [4]:
candels = Table.read("{}/CANDELS.fits".format(TMP_DIR))
cfhtls = Table.read("{}/CFHTLS.fits".format(TMP_DIR))
decals = Table.read("{}/DECaLS.fits".format(TMP_DIR))
hsc_deep = Table.read("{}/HSC-DEEP.fits".format(TMP_DIR))
hsc_udeep = Table.read("{}/HSC-UDEEP.fits".format(TMP_DIR))
kids = Table.read("{}/KIDS.fits".format(TMP_DIR))
ps1 = Table.read("{}/PS1.fits".format(TMP_DIR))
las = Table.read("{}/UKIDSS-LAS.fits".format(TMP_DIR))
wirds = Table.read("{}/CFHT-WIRDS.fits".format(TMP_DIR))

II - Merging tables¶

We first merge the optical catalogues and then add the infrared ones: CANDELS, CFHTLS, DECaLS, HSC, KIDS, PanSTARRS, UKIDSS-LAS, and CFHT-WIRDS.

At every step, we look at the distribution of the distances separating the sources from one catalogue to the other (within a maximum radius) to determine the best cross-matching radius.

PanSTARRS¶

In [5]:
master_catalogue = ps1
master_catalogue['ps1_ra'].name = 'ra'
master_catalogue['ps1_dec'].name = 'dec'

Add CANDELS¶

In [6]:
nb_merge_dist_plot(
    SkyCoord(master_catalogue['ra'], master_catalogue['dec']),
    SkyCoord(candels['candels_ra'], candels['candels_dec'])
)
In [7]:
# Given the graph above, we use 0.8 arc-second radius
master_catalogue = merge_catalogues(master_catalogue, candels, "candels_ra", "candels_dec", radius=0.8*u.arcsec)

Add CFHTLS¶

In [8]:
nb_merge_dist_plot(
    SkyCoord(master_catalogue['ra'], master_catalogue['dec']),
    SkyCoord(cfhtls['cfhtls_ra'], cfhtls['cfhtls_dec'])
)
In [9]:
# Given the graph above, we use 0.8 arc-second radius
master_catalogue = merge_catalogues(master_catalogue, cfhtls, "cfhtls_ra", "cfhtls_dec", radius=0.8*u.arcsec)

Add DECaLS¶

In [10]:
nb_merge_dist_plot(
    SkyCoord(master_catalogue['ra'], master_catalogue['dec']),
    SkyCoord(decals['decals_ra'], decals['decals_dec'])
)
In [11]:
# Given the graph above, we use 0.8 arc-second radius
master_catalogue = merge_catalogues(master_catalogue, decals, "decals_ra", "decals_dec", radius=0.8*u.arcsec)

Add HSC-UDEEP¶

In [12]:
nb_merge_dist_plot(
    SkyCoord(master_catalogue['ra'], master_catalogue['dec']),
    SkyCoord(hsc_udeep['hsc-udeep_ra'], hsc_udeep['hsc-udeep_dec'])
)
In [13]:
# Given the graph above, we use 0.8 arc-second radius
master_catalogue = merge_catalogues(master_catalogue, hsc_udeep, "hsc-udeep_ra", "hsc-udeep_dec", radius=0.8*u.arcsec)

Add HSC-DEEP¶

In [14]:
nb_merge_dist_plot(
    SkyCoord(master_catalogue['ra'], master_catalogue['dec']),
    SkyCoord(hsc_deep['hsc-deep_ra'], hsc_deep['hsc-deep_dec'])
)
In [15]:
# Given the graph above, we use 0.8 arc-second radius
master_catalogue = merge_catalogues(master_catalogue, hsc_deep, "hsc-deep_ra", "hsc-deep_dec", radius=0.8*u.arcsec)

Add KIDS¶

In [16]:
nb_merge_dist_plot(
    SkyCoord(master_catalogue['ra'], master_catalogue['dec']),
    SkyCoord(kids['kids_ra'], kids['kids_dec'])
)
In [17]:
# Given the graph above, we use 0.8 arc-second radius
master_catalogue = merge_catalogues(master_catalogue, kids, "kids_ra", "kids_dec", radius=0.8*u.arcsec)

Add UKIDSS LAS¶

In [18]:
nb_merge_dist_plot(
    SkyCoord(master_catalogue['ra'], master_catalogue['dec']),
    SkyCoord(las['las_ra'], las['las_dec'])
)
In [19]:
# Given the graph above, we use 0.8 arc-second radius
master_catalogue = merge_catalogues(master_catalogue, las, "las_ra", "las_dec", radius=0.8*u.arcsec)

Add CFHT-WIRDS¶

In [20]:
nb_merge_dist_plot(
    SkyCoord(master_catalogue['ra'], master_catalogue['dec']),
    SkyCoord(wirds['wirds_ra'], wirds['wirds_dec'])
)
In [21]:
#Given the graph above, we use 1 arc-second radius
master_catalogue = merge_catalogues(master_catalogue, wirds, "wirds_ra", "wirds_dec", radius=1.*u.arcsec)

Cleaning¶

When we merge the catalogues, astropy masks the non-existent values (e.g. when a row comes only from a catalogue and has no counterparts in the other, the columns from the latest are masked for that row). We indicate to use NaN for masked values for floats columns, False for flag columns and -1 for ID columns.

In [22]:
for col in master_catalogue.colnames:
    #print(col)
    if "m_" in col or "merr_" in col or "f_" in col or "ferr_" in col or "stellarity" in col:
        master_catalogue[col].fill_value = np.nan
    elif "flag" in col:
        master_catalogue[col].fill_value = 0
    elif "id" in col:
        master_catalogue[col].fill_value = -1
        
master_catalogue = master_catalogue.filled()
In [23]:
master_catalogue[:10].show_in_notebook()
Out[23]:
<Table length=10>
idxps1_idradecm_ap_gpc1_gmerr_ap_gpc1_gm_gpc1_gmerr_gpc1_gm_ap_gpc1_rmerr_ap_gpc1_rm_gpc1_rmerr_gpc1_rm_ap_gpc1_imerr_ap_gpc1_im_gpc1_imerr_gpc1_im_ap_gpc1_zmerr_ap_gpc1_zm_gpc1_zmerr_gpc1_zm_ap_gpc1_ymerr_ap_gpc1_ym_gpc1_ymerr_gpc1_yf_ap_gpc1_gferr_ap_gpc1_gf_gpc1_gferr_gpc1_gflag_gpc1_gf_ap_gpc1_rferr_ap_gpc1_rf_gpc1_rferr_gpc1_rflag_gpc1_rf_ap_gpc1_iferr_ap_gpc1_if_gpc1_iferr_gpc1_iflag_gpc1_if_ap_gpc1_zferr_ap_gpc1_zf_gpc1_zferr_gpc1_zflag_gpc1_zf_ap_gpc1_yferr_ap_gpc1_yf_gpc1_yferr_gpc1_yflag_gpc1_yps1_flag_cleanedps1_flag_gaiaflag_mergedcandels_idcandels_stellarityf_ap_candels_f140wferr_ap_candels_f140wf_candels_f140wferr_candels_f140wf_ap_candels_f160wferr_ap_candels_f160wf_candels_f160wferr_candels_f160wf_candels_f606wferr_candels_f606wf_candels_f814wferr_candels_f814wf_candels_f125wferr_candels_f125wm_ap_candels_f140wmerr_ap_candels_f140wm_candels_f140wmerr_candels_f140wflag_candels_f140wm_ap_candels_f160wmerr_ap_candels_f160wm_candels_f160wmerr_candels_f160wflag_candels_f160wm_candels_f606wmerr_candels_f606wflag_candels_f606wm_candels_f814wmerr_candels_f814wflag_candels_f814wm_candels_f125wmerr_candels_f125wflag_candels_f125wcandels_flag_cleanedcandels_flag_gaiacfhtls_idcfhtls_stellaritym_megacam_umerr_megacam_um_megacam_gmerr_megacam_gm_megacam_rmerr_megacam_rm_megacam_imerr_megacam_im_megacam_zmerr_megacam_zm_ap_megacam_umerr_ap_megacam_um_ap_megacam_gmerr_ap_megacam_gm_ap_megacam_rmerr_ap_megacam_rm_ap_megacam_imerr_ap_megacam_im_ap_megacam_zmerr_ap_megacam_zf_megacam_uferr_megacam_uflag_megacam_uf_megacam_gferr_megacam_gflag_megacam_gf_megacam_rferr_megacam_rflag_megacam_rf_megacam_iferr_megacam_iflag_megacam_if_megacam_zferr_megacam_zflag_megacam_zf_ap_megacam_uferr_ap_megacam_uf_ap_megacam_gferr_ap_megacam_gf_ap_megacam_rferr_ap_megacam_rf_ap_megacam_iferr_ap_megacam_if_ap_megacam_zferr_ap_megacam_zcfhtls_flag_cleanedcfhtls_flag_gaiadecals_idf_decam_gf_decam_rf_decam_zferr_decam_gferr_decam_rferr_decam_zf_ap_decam_gf_ap_decam_rf_ap_decam_zferr_ap_decam_gferr_ap_decam_rferr_ap_decam_zm_decam_gmerr_decam_gflag_decam_gm_decam_rmerr_decam_rflag_decam_rm_decam_zmerr_decam_zflag_decam_zm_ap_decam_gmerr_ap_decam_gm_ap_decam_rmerr_ap_decam_rm_ap_decam_zmerr_ap_decam_zdecals_stellaritydecals_flag_cleaneddecals_flag_gaiahsc-udeep_idm_ap_hsc-udeep_gmerr_ap_hsc-udeep_gm_hsc-udeep_gmerr_hsc-udeep_gm_ap_hsc-udeep_rmerr_ap_hsc-udeep_rm_hsc-udeep_rmerr_hsc-udeep_rm_ap_hsc-udeep_imerr_ap_hsc-udeep_im_hsc-udeep_imerr_hsc-udeep_im_ap_hsc-udeep_zmerr_ap_hsc-udeep_zm_hsc-udeep_zmerr_hsc-udeep_zm_ap_hsc-udeep_ymerr_ap_hsc-udeep_ym_hsc-udeep_ymerr_hsc-udeep_ym_ap_hsc-udeep_n921merr_ap_hsc-udeep_n921m_hsc-udeep_n921merr_hsc-udeep_n921hsc-udeep_stellarityf_ap_hsc-udeep_gferr_ap_hsc-udeep_gf_hsc-udeep_gferr_hsc-udeep_gflag_hsc-udeep_gf_ap_hsc-udeep_rferr_ap_hsc-udeep_rf_hsc-udeep_rferr_hsc-udeep_rflag_hsc-udeep_rf_ap_hsc-udeep_iferr_ap_hsc-udeep_if_hsc-udeep_iferr_hsc-udeep_iflag_hsc-udeep_if_ap_hsc-udeep_zferr_ap_hsc-udeep_zf_hsc-udeep_zferr_hsc-udeep_zflag_hsc-udeep_zf_ap_hsc-udeep_yferr_ap_hsc-udeep_yf_hsc-udeep_yferr_hsc-udeep_yflag_hsc-udeep_yf_ap_hsc-udeep_n921ferr_ap_hsc-udeep_n921f_hsc-udeep_n921ferr_hsc-udeep_n921flag_hsc-udeep_n921hsc-udeep_flag_cleanedhsc-udeep_flag_gaiahsc-deep_idm_ap_hsc-deep_gmerr_ap_hsc-deep_gm_hsc-deep_gmerr_hsc-deep_gm_ap_hsc-deep_rmerr_ap_hsc-deep_rm_hsc-deep_rmerr_hsc-deep_rm_ap_hsc-deep_imerr_ap_hsc-deep_im_hsc-deep_imerr_hsc-deep_im_ap_hsc-deep_zmerr_ap_hsc-deep_zm_hsc-deep_zmerr_hsc-deep_zm_ap_hsc-deep_ymerr_ap_hsc-deep_ym_hsc-deep_ymerr_hsc-deep_ym_ap_hsc-deep_n921merr_ap_hsc-deep_n921m_hsc-deep_n921merr_hsc-deep_n921hsc-deep_stellarityf_ap_hsc-deep_gferr_ap_hsc-deep_gf_hsc-deep_gferr_hsc-deep_gflag_hsc-deep_gf_ap_hsc-deep_rferr_ap_hsc-deep_rf_hsc-deep_rferr_hsc-deep_rflag_hsc-deep_rf_ap_hsc-deep_iferr_ap_hsc-deep_if_hsc-deep_iferr_hsc-deep_iflag_hsc-deep_if_ap_hsc-deep_zferr_ap_hsc-deep_zf_hsc-deep_zferr_hsc-deep_zflag_hsc-deep_zf_ap_hsc-deep_yferr_ap_hsc-deep_yf_hsc-deep_yferr_hsc-deep_yflag_hsc-deep_yf_ap_hsc-deep_n921ferr_ap_hsc-deep_n921f_hsc-deep_n921ferr_hsc-deep_n921flag_hsc-deep_n921hsc-deep_flag_cleanedhsc-deep_flag_gaiakids_idkids_stellaritym_kids_umerr_kids_um_kids_gmerr_kids_gm_kids_rmerr_kids_rm_kids_imerr_kids_if_ap_kids_uferr_ap_kids_uf_ap_kids_gferr_ap_kids_gf_ap_kids_rferr_ap_kids_rf_ap_kids_iferr_ap_kids_if_kids_uferr_kids_uflag_kids_uf_kids_gferr_kids_gflag_kids_gf_kids_rferr_kids_rflag_kids_rf_kids_iferr_kids_iflag_kids_im_ap_kids_umerr_ap_kids_um_ap_kids_gmerr_ap_kids_gm_ap_kids_rmerr_ap_kids_rm_ap_kids_imerr_ap_kids_ikids_flag_cleanedkids_flag_gaialas_idm_ukidss_ymerr_ukidss_ym_ap_ukidss_ymerr_ap_ukidss_ym_ukidss_jmerr_ukidss_jm_ap_ukidss_jmerr_ap_ukidss_jm_ap_ukidss_hmerr_ap_ukidss_hm_ukidss_hmerr_ukidss_hm_ap_ukidss_kmerr_ap_ukidss_km_ukidss_kmerr_ukidss_klas_stellarityf_ukidss_yferr_ukidss_yflag_ukidss_yf_ap_ukidss_yferr_ap_ukidss_yf_ukidss_jferr_ukidss_jflag_ukidss_jf_ap_ukidss_jferr_ap_ukidss_jf_ap_ukidss_hferr_ap_ukidss_hf_ukidss_hferr_ukidss_hflag_ukidss_hf_ap_ukidss_kferr_ap_ukidss_kf_ukidss_kferr_ukidss_kflag_ukidss_klas_flag_cleanedlas_flag_gaiam_ap_wirds_ksmerr_ap_wirds_ksm_wirds_ksmerr_wirds_ksf_ap_wirds_ksferr_ap_wirds_ksf_wirds_ksferr_wirds_ksflag_wirds_kswirds_flag_mergedm_ap_wirds_jmerr_ap_wirds_jm_wirds_jmerr_wirds_jf_ap_wirds_jferr_ap_wirds_jf_wirds_jferr_wirds_jflag_wirds_jm_ap_wirds_hmerr_ap_wirds_hm_wirds_hmerr_wirds_hf_ap_wirds_hferr_ap_wirds_hf_wirds_hferr_wirds_hflag_wirds_hwirds_intidwirds_stellaritywirds_flag_cleanedcfht-wirds_flag_gaia
degdeguJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJymagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmaguJyuJyuJyuJyuJyuJyuJyuJymagmagmagmagmagmagmagmagmagmagmagmag
0110031510155235338151.0154866811.695735496114.91909980770.034961998462714.75450038910.0056250002235213.67119979860.013.27429962160.015.18350028990.0064249997958515.71160030360.036345001310114.36769962310.041443999856714.71979999540.019004000350813.97669982910.081932999193713.11149978640.1045119985943911.65079366125.9598127384551.9747501823.5829466448False12345.8239750.017794.268990.0False3066.1957972618.14465363241885.2106240163.1073941343False6500.10168696248.1175558144699.8067625382.2622741809False9317.9434059703.16071824520672.83724281989.94887283FalseFalse0False-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannanFalsenannanFalsenannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannannannanFalse0-1nannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannannannanFalsenannannannanFalseFalse0nannannannannannannannanFalseFalsenannannannannannannannanFalsenannannannannannannannanFalse-1nanFalse0
1110721505995480992150.5995458312.267053506116.13570022580.056281000375716.74810028080.044941999018215.12959957120.015.94680023190.107364997268nannannannan14.45030021670.0009749999735514.19979953770.070114001631714.01270008090.02412299998113.16800022130.08329900354151275.6158582166.1237382343725.70461964630.0391717258False3222.256968020.01518.02843706150.113000085FalsenannannannanFalse6023.929954915.409538266277587.1764614489.95999255False9014.05010219200.27510318919624.55924261505.62007851FalseFalse0False-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannanFalsenannanFalsenannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannannannanFalse0-1nannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannannannanFalsenannannannanFalseFalse0nannannannannannannannanFalseFalsenannannannannannannannanFalsenannannannannannannannanFalse-1nanFalse0
2110781510031142219151.0030787212.318078356124.35409927370.99804902076724.7147998811.5764600038521.42849922180.024.7765998840.023.32379913330.75762897729924.49220085143.4702599048621.24589920040.32213398814221.25510025020.30997401475922.0506992342.2991700172421.60960006712.349499940870.6582036564070.6050452327770.4721500582560.685549288488False9.74092750670.00.4460258673070.0False1.700123015481.186349369080.5795883660971.85249626878False11.52498369983.4194208005811.42772813263.26257773603False5.4918707340511.62966149148.2444174367117.8406671852FalseFalse0False-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannanFalsenannanFalsenannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannannannanFalse0-1nannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannannannanFalsenannannannanFalseFalse0nannannannannannannannanFalseFalsenannannannannannannannanFalsenannannannannannannannanFalse-1nanFalse0
3111261495216158966149.5217340912.7238072761nannannannan14.69499969480.0nannan6.494949817660.001086000003859.468170166020.0010860000038514.44909954070.049091998487714.25160026550.0163369998336nannannannannannannannanFalse4808.394836030.0nannanFalse9162628.384879164.85460985592559.456893592.703429846False6030.59528355272.6757873997233.69001128108.844848309FalsenannannannanFalseFalse0False-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannanFalsenannanFalsenannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannannannanFalse0-1nannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannannannanFalsenannannannanFalseFalse0nannannannannannannannanFalseFalsenannannannannannannannanFalsenannannannannannannannanFalse-1nanFalse0
4111271488496798327148.8496775612.7315473361nannannannan20.17130088810.020.31870079040.026.625999450719.7346000671nannan23.01230049132.1335101127625.221099853526.458400726321.89800071720.0546469986439nannannannannannanFalse31.00842049790.027.07195901310.0False0.08120826271141.47606074084nannanFalse2.26506048394.450924107750.2961829528557.21770833522False6.32120264470.318157164548nannanFalseFalse0False-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannanFalsenannanFalsenannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannannannanFalse0-1nannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannannannanFalsenannannannanFalseFalse0nannannannannannannannanFalseFalsenannannannannannannannanFalsenannannannannannannannanFalse-1nanFalse0
5109681492253474637149.2253221711.403526626114.05270004270.0042489999905214.09720039370.0028119999915413.6761999138.60000000102e-0513.7580995560.013929000124313.71720027920.0015249999705713.85379981990.0012570000253613.57180023190.0021750000305513.64000034330.0026670000515913.53750038150.00082999997539413.61229991910.001279999967668688.0034141434.00027213118339.1126870421.5978657639False12289.09877110.97340633001411396.2030239146.20283697False11833.681830116.621315899310434.702510912.0806704828False13529.442686427.102843330912705.737034431.2103448127False13963.678704510.674649081713034.069498415.3661713254FalseFalse3False-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannanFalsenannanFalsenannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannannannanFalse0-1nannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannannannanFalsenannannannanFalseFalse0nannannannannannannannanFalseFalsenannannannannannannannanFalsenannannannannannannannanFalse-1nanFalse0
6111291493965294955149.3962831512.745474056114.67660045620.0024009998887814.20820045470.0080390004441112.44190025330.00058100000023813.32810020450.001556999981411.97319984440.0010860000038512.23849964140.0010860000038514.52910041810.013623000122613.98880004880.00073500000871713.5824003220.026924999430812.90439987180.01626800000674890.5738067510.81502773387528.6969868655.7439257858False38303.626919420.497066554316934.014145424.284222626False58982.077066158.996407820246195.550136846.2067741747False5602.2157835670.29238407259214.674111736.23796602044False13397.9968459332.25479252625017.277808374.843423075FalseFalse0False-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannanFalsenannanFalsenannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannannannanFalse0-1nannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannannannanFalsenannannannanFalseFalse0nannannannannannannannanFalseFalsenannannannannannannannanFalsenannannannannannannannanFalse-1nanFalse0
7110521489702298250148.9702079212.106383096116.73660087590.0023759999312516.79389953610.003038000082615.49300003050.00066600000718615.52849960330.0017790000420118.99419975280.41978499293319.39209938054.4332399368313.79349994660.055298000574113.86859989170.034726001322316.27429962160.44224798679417.36980056760.777338981628733.4316540311.60502482271695.7291268121.94672070016False2305.685072141.414327225972231.516789273.65638397656False91.689604385535.450526343763.5565402184259.511832716False11030.6224832561.80439202310293.4282903329.223252255False1122.74247089457.321580752409.335841271293.066312612FalseFalse0False-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannanFalsenannanFalsenannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannannannanFalse0-1nannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannannannanFalsenannannannanFalseFalse0nannannannannannannannanFalseFalsenannannannannannannannanFalsenannannannannannannannanFalse-1nanFalse0
8109751492017707125149.2017443711.463903956115.95119953160.0013970000436515.99590015410.0019000000320415.58829975130.00079299998469715.63840007780.00090400001499815.4288997650.0039929999038615.49419975280.0037000000011215.44279956820.0018619999755215.51319980620.0047820000909315.4076995850.0031999999191615.5052003860.004714999813591511.889975141.945325533051450.908210592.53903815174False2111.932820941.542513446032016.693826671.67912909376False2445.907867498.995288023852303.138731677.8486959101False2414.794470574.141288855782263.185111969.96793821903False2494.136201357.350989685832279.92124559.90095770999FalseFalse3False-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannanFalsenannanFalsenannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannannannanFalse0-1nannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannannannanFalsenannannannanFalseFalse0nannannannannannannannanFalseFalsenannannannannannannannanFalsenannannannannannannannanFalse-1nanFalse0
9110811488834132506148.8834147712.343358766115.95429992680.013682999648215.96510028840.0067099998705115.48910045620.00080199999501915.53899955750.0017920000245815.35190010070.001875999965715.40390014650.0028210000600715.32960033420.0023040000814915.39630031590.004298000130815.32590007780.0036410000175215.41619968410.007497999817131507.5788265518.99927483571492.656527999.22482373308False2313.981153711.709266823392210.040218083.64765594788False2625.668897384.536787794172502.879501196.50307431238False2680.154723855.687455825012520.46037229.97750555055False2689.304439989.018541953542474.6861421117.0899673048FalseFalse3False-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannanFalsenannanFalsenannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannannannanFalse0-1nannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalseFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannanFalsenannanFalsenannanFalsenannannannannannannannanFalse0-1nannannannannannannannannannannannannannannannannannannanFalsenannannannanFalsenannannannannannanFalsenannannannanFalseFalse0nannannannannannannannanFalseFalsenannannannannannannannanFalsenannannannannannannannanFalse-1nanFalse0

III - Merging flags and stellarity¶

Each pristine catalogue contains a flag indicating if the source was associated to a another nearby source that was removed during the cleaning process. We merge these flags in a single one.

In [24]:
flag_cleaned_columns = [column for column in master_catalogue.colnames
                        if 'flag_cleaned' in column]

flag_column = np.zeros(len(master_catalogue), dtype=bool)
for column in flag_cleaned_columns:
    flag_column |= master_catalogue[column]
    
master_catalogue.add_column(Column(data=flag_column, name="flag_cleaned"))
master_catalogue.remove_columns(flag_cleaned_columns)

Wirds was created with a merge so contains a flag to be merged with the merg flag produced here

In [25]:
master_catalogue['flag_merged'] |= master_catalogue['wirds_flag_merged']
master_catalogue.remove_columns('wirds_flag_merged')

Each pristine catalogue contains a flag indicating the probability of a source being a Gaia object (0: not a Gaia object, 1: possibly, 2: probably, 3: definitely). We merge these flags taking the highest value.

In [26]:
flag_gaia_columns = [column for column in master_catalogue.colnames
                     if 'flag_gaia' in column]

master_catalogue.add_column(Column(
    data=np.max([master_catalogue[column] for column in flag_gaia_columns], axis=0),
    name="flag_gaia"
))
master_catalogue.remove_columns(flag_gaia_columns)

Each prisitine catalogue may contain one or several stellarity columns indicating the probability (0 to 1) of each source being a star. We merge these columns taking the highest value.

In [27]:
stellarity_columns = [column for column in master_catalogue.colnames
                      if 'stellarity' in column]

master_catalogue.add_column(Column(
    data=np.nanmax([master_catalogue[column] for column in stellarity_columns], axis=0),
    name="stellarity"
))
master_catalogue.remove_columns(stellarity_columns)
/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/numpy/lib/nanfunctions.py:343: RuntimeWarning: All-NaN slice encountered
  warnings.warn("All-NaN slice encountered", RuntimeWarning)

IV - Adding E(B-V) column¶

In [28]:
master_catalogue.add_column(
    ebv(master_catalogue['ra'], master_catalogue['dec'])
)

V - Adding HELP unique identifiers and field columns¶

In [29]:
master_catalogue.add_column(Column(gen_help_id(master_catalogue['ra'], master_catalogue['dec']),
                                   name="help_id"))
master_catalogue.add_column(Column(np.full(len(master_catalogue), "COSMOS", dtype='<U18'),
                                   name="field"))
In [30]:
# Check that the HELP Ids are unique
if len(master_catalogue) != len(np.unique(master_catalogue['help_id'])):
    print("The HELP IDs are not unique!!!")
else:
    print("OK!")
OK!

VI - Choosing between multiple values for the same filter¶

There are currently no overlapping surveys here.

In [31]:
suprime_origin = Table()
suprime_origin.add_column(master_catalogue['help_id'])
In [33]:
suprime_stats = Table()
suprime_stats.add_column(Column(data=['g','r','i','z','y', 'n921'], name="Band"))
for col in ["HSC-UDEEP",  "HSC-DEEP"]:
    suprime_stats.add_column(Column(data=np.full(6, 0), name="{}".format(col)))
    suprime_stats.add_column(Column(data=np.full(6, 0), name="use {}".format(col)))
    suprime_stats.add_column(Column(data=np.full(6, 0), name="{} ap".format(col)))
    suprime_stats.add_column(Column(data=np.full(6, 0), name="use {} ap".format(col)))
    
/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/numpy/core/numeric.py:301: FutureWarning: in the future, full(6, 0) will return an array of dtype('int64')
  format(shape, fill_value, array(fill_value).dtype), FutureWarning)
In [35]:
suprime_bands = ['g','r','i','z','y', 'n921'] 
for band in suprime_bands:

    # Suprime total flux 
    has_hsc_udeep = ~np.isnan(master_catalogue['f_hsc-udeep_' + band])
    has_hsc_deep  = ~np.isnan(master_catalogue['f_hsc-deep_' + band])
    

    use_hsc_udeep = has_hsc_udeep
    use_hsc_deep = has_hsc_deep & ~has_hsc_udeep
 
    f_suprime = np.full(len(master_catalogue), np.nan)
    f_suprime[use_hsc_udeep] = master_catalogue['f_hsc-udeep_' + band][use_hsc_udeep]
    f_suprime[use_hsc_deep] = master_catalogue['f_hsc-deep_' + band][use_hsc_deep]
 

    ferr_suprime = np.full(len(master_catalogue), np.nan)
    ferr_suprime[use_hsc_udeep] = master_catalogue['ferr_hsc-udeep_' + band][use_hsc_udeep]
    ferr_suprime[use_hsc_deep] = master_catalogue['ferr_hsc-deep_' + band][use_hsc_deep]

    
    m_suprime = np.full(len(master_catalogue), np.nan)
    m_suprime[use_hsc_udeep] = master_catalogue['m_hsc-udeep_' + band][use_hsc_udeep]
    m_suprime[use_hsc_deep] = master_catalogue['m_hsc-deep_' + band][use_hsc_deep]


    merr_suprime = np.full(len(master_catalogue), np.nan)
    merr_suprime[use_hsc_udeep] = master_catalogue['merr_hsc-udeep_' + band][use_hsc_udeep]
    merr_suprime[use_hsc_deep] = master_catalogue['merr_hsc-deep_' + band][use_hsc_deep]


    flag_suprime = np.full(len(master_catalogue), False, dtype=bool)
    flag_suprime[use_hsc_udeep] = master_catalogue['flag_hsc-udeep_' + band][use_hsc_udeep]
    flag_suprime[use_hsc_deep] = master_catalogue['flag_hsc-deep_' + band][use_hsc_deep]


    master_catalogue.add_column(Column(data=f_suprime, name="f_suprime_" + band))
    master_catalogue.add_column(Column(data=ferr_suprime, name="ferr_suprime_" + band))
    master_catalogue.add_column(Column(data=m_suprime, name="m_suprime_" + band))
    master_catalogue.add_column(Column(data=merr_suprime, name="merr_suprime_" + band))
    master_catalogue.add_column(Column(data=flag_suprime, name="flag_suprime_" + band))

    old_hsc_udeep_columns = ['f_hsc-udeep_' + band,
                               'ferr_hsc-udeep_' + band,
                               'm_hsc-udeep_' + band, 
                               'merr_hsc-udeep_' + band,
                               'flag_hsc-udeep_' + band]
    old_hsc_deep_columns = ['f_hsc-deep_' + band,
                               'ferr_hsc-deep_' + band,
                               'm_hsc-deep_' + band, 
                               'merr_hsc-deep_' + band,
                               'flag_hsc-deep_' + band]

    
    old_columns = old_hsc_udeep_columns + old_hsc_deep_columns
    master_catalogue.remove_columns(old_columns)

    origin = np.full(len(master_catalogue), '     ', dtype='<U5')
    origin[use_hsc_udeep] = "HSC-UDEEP"
    origin[use_hsc_deep] = "HSC-DEEP"
 
    
    suprime_origin.add_column(Column(data=origin, name= 'f_suprime_' + band ))
    
  
    # Suprime aperture flux 
    has_ap_hsc_udeep = ~np.isnan(master_catalogue['f_ap_hsc-udeep_' + band])
    has_ap_hsc_deep  = ~np.isnan(master_catalogue['f_ap_hsc-deep_' + band])
 
    

    use_ap_hsc_udeep = has_ap_hsc_udeep
    use_ap_hsc_deep = has_ap_hsc_deep & ~has_ap_hsc_udeep
  

    f_ap_suprime = np.full(len(master_catalogue), np.nan)
    f_ap_suprime[use_ap_hsc_udeep] = master_catalogue['f_ap_hsc-udeep_' + band][use_ap_hsc_udeep]
    f_ap_suprime[use_ap_hsc_deep] = master_catalogue['f_ap_hsc-deep_' + band][use_ap_hsc_deep]


    ferr_ap_suprime = np.full(len(master_catalogue), np.nan)
    ferr_ap_suprime[use_ap_hsc_udeep] = master_catalogue['ferr_ap_hsc-udeep_' + band][use_ap_hsc_udeep]
    ferr_ap_suprime[use_ap_hsc_deep] = master_catalogue['ferr_ap_hsc-deep_' + band][use_ap_hsc_deep]
   
    
    m_ap_suprime = np.full(len(master_catalogue), np.nan)
    m_ap_suprime[use_ap_hsc_udeep] = master_catalogue['m_ap_hsc-udeep_' + band][use_ap_hsc_udeep]
    m_ap_suprime[use_ap_hsc_deep] = master_catalogue['m_ap_hsc-deep_' + band][use_ap_hsc_deep]
  

    merr_ap_suprime = np.full(len(master_catalogue), np.nan)
    merr_ap_suprime[use_ap_hsc_udeep] = master_catalogue['merr_ap_hsc-udeep_' + band][use_ap_hsc_udeep]
    merr_ap_suprime[use_ap_hsc_deep] = master_catalogue['merr_ap_hsc-deep_' + band][use_ap_hsc_deep]
  


    master_catalogue.add_column(Column(data=f_ap_suprime, name="f_ap_suprime_" + band))
    master_catalogue.add_column(Column(data=ferr_ap_suprime, name="ferr_ap_suprime_" + band))
    master_catalogue.add_column(Column(data=m_ap_suprime, name="m_ap_suprime_" + band))
    master_catalogue.add_column(Column(data=merr_ap_suprime, name="merr_ap_suprime_" + band))


    old_ap_hsc_udeep_columns = ['f_ap_hsc-udeep_' + band,
                               'ferr_ap_hsc-udeep_' + band,
                               'm_ap_hsc-udeep_' + band, 
                               'merr_ap_hsc-udeep_' + band]
    old_ap_hsc_deep_columns = ['f_ap_hsc-deep_' + band,
                               'ferr_ap_hsc-deep_' + band,
                               'm_ap_hsc-deep_' + band, 
                               'merr_ap_hsc-deep_' + band]

    
    old_ap_columns = old_ap_hsc_udeep_columns + old_ap_hsc_deep_columns 
    master_catalogue.remove_columns(old_ap_columns)

    origin_ap = np.full(len(master_catalogue), '     ', dtype='<U5')
    origin_ap[use_ap_hsc_udeep] = "HSC-UDEEP"
    origin_ap[use_ap_hsc_deep] = "HSC-DEEP"

    
    suprime_origin.add_column(Column(data=origin_ap, name= 'f_ap_suprime_' + band ))

   
    suprime_stats['HSC-UDEEP'][suprime_stats['Band'] == band] = np.sum(has_hsc_udeep)
    suprime_stats['HSC-DEEP'][suprime_stats['Band'] == band] = np.sum(has_hsc_deep)

    suprime_stats['use HSC-UDEEP'][suprime_stats['Band'] == band] = np.sum(use_hsc_udeep)
    suprime_stats['use HSC-DEEP'][suprime_stats['Band'] == band] = np.sum(use_hsc_deep)

    suprime_stats['HSC-UDEEP ap'][suprime_stats['Band'] == band] = np.sum(has_ap_hsc_udeep)
    suprime_stats['HSC-DEEP ap'][suprime_stats['Band'] == band] = np.sum(has_ap_hsc_deep)

    suprime_stats['use HSC-UDEEP ap'][suprime_stats['Band'] == band] = np.sum(use_ap_hsc_udeep)
    suprime_stats['use HSC-DEEP ap'][suprime_stats['Band'] == band] = np.sum(use_ap_hsc_deep)
In [36]:
suprime_stats.show_in_notebook()
Out[36]:
<Table length=6>
idxBandHSC-UDEEPuse HSC-UDEEPHSC-UDEEP apuse HSC-UDEEP apHSC-DEEPuse HSC-DEEPHSC-DEEP apuse HSC-DEEP ap
0g1146131.01146131.01257414.01257414.01643773.0956296.01838222.01044684.0
1r1156722.01156722.01268883.01268883.01679055.0989498.01903240.01102577.0
2i1160356.01160356.01291883.01291883.01714230.0987362.01953737.01086552.0
3z1132842.01132842.01260729.01260729.01701530.0985035.01933534.01081364.0
4y1035328.01035328.01157878.01157878.01467985.0850628.01669840.0926313.0
5n9211088153.01088153.01207243.01207243.0879166.0495021.0996296.0546345.0
In [37]:
suprime_origin.write("{}/cosmos_suprime_fluxes_origins{}.fits".format(OUT_DIR, SUFFIX), overwrite=True)

VII.a Wavelength domain coverage¶

We add a binary flag_optnir_obs indicating that a source was observed in a given wavelength domain:

  • 1 for observation in optical;
  • 2 for observation in near-infrared;
  • 4 for observation in mid-infrared (IRAC).

It's an integer binary flag, so a source observed both in optical and near-infrared by not in mid-infrared would have this flag at 1 + 2 = 3.

Note 1: The observation flag is based on the creation of multi-order coverage maps from the catalogues, this may not be accurate, especially on the edges of the coverage.

Note 2: Being on the observation coverage does not mean having fluxes in that wavelength domain. For sources observed in one domain but having no flux in it, one must take into consideration de different depths in the catalogue we are using.

In [38]:
candels_moc = MOC(filename="../../dmu0/dmu0_CANDELS-3D-HST/data/CANDELS-3D-HST_COSMOS_MOC.fits")
cfhtls_moc = MOC(filename="../../dmu0/dmu0_CFHTLS/data/CFHTLS-DEEP_COSMOS_MOC.fits")
decals_moc = MOC(filename="../../dmu0/dmu0_DECaLS/data/DECaLS_COSMOS_MOC.fits")
hsc_udeep_moc = MOC(filename="../../dmu0/dmu0_HSC/data/HSC-PDR1_deep_COSMOS_MOC.fits")
hsc_deep_moc = MOC(filename="../../dmu0/dmu0_HSC/data/HSC-PDR1_uDeep_COSMOS_MOC.fits")
kids_moc = MOC(filename="../../dmu0/dmu0_KIDS/data/KIDS-DR3_COSMOS_MOC.fits")
ps1_moc = MOC(filename="../../dmu0/dmu0_PanSTARRS1-3SS/data/PanSTARRS1-3SS_COSMOS_MOC.fits")
las_moc = MOC(filename="../../dmu0/dmu0_UKIDSS-LAS/data/UKIDSS-LAS_COSMOS_MOC.fits")
wirds_moc = MOC(filename="../../dmu0/dmu0_CFHT-WIRDS/data/COSMOS_Ks-priors_MOC.fits")
In [39]:
was_observed_optical = inMoc(
    master_catalogue['ra'], master_catalogue['dec'],
    candels_moc + 
    cfhtls_moc + 
    decals_moc + 
    hsc_udeep_moc + 
    hsc_deep_moc + 
    kids_moc +
    ps1_moc) 

was_observed_nir = inMoc(
    master_catalogue['ra'], master_catalogue['dec'],
    las_moc + wirds_moc
)

was_observed_mir = np.zeros(len(master_catalogue), dtype=bool)

#was_observed_mir = inMoc(
#    master_catalogue['ra'], master_catalogue['dec'],   
#)
In [40]:
master_catalogue.add_column(
    Column(
        1 * was_observed_optical + 2 * was_observed_nir + 4 * was_observed_mir,
        name="flag_optnir_obs")
)

VII.b Wavelength domain detection¶

We add a binary flag_optnir_det indicating that a source was detected in a given wavelength domain:

  • 1 for detection in optical;
  • 2 for detection in near-infrared;
  • 4 for detection in mid-infrared (IRAC).

It's an integer binary flag, so a source detected both in optical and near-infrared by not in mid-infrared would have this flag at 1 + 2 = 3.

Note 1: We use the total flux columns to know if the source has flux, in some catalogues, we may have aperture flux and no total flux.

To get rid of artefacts (chip edges, star flares, etc.) we consider that a source is detected in one wavelength domain when it has a flux value in at least two bands. That means that good sources will be excluded from this flag when they are on the coverage of only one band.

In [41]:
# SpARCS is a catalogue of sources detected in r (with fluxes measured at 
# this prior position in the other bands).  Thus, we are only using the r
# CFHT band.
# Check to use catalogue flags from HSC and PanSTARRS.
nb_optical_flux = (
    1 * ~np.isnan(master_catalogue['f_megacam_u']) +
    1 * ~np.isnan(master_catalogue['f_megacam_g']) +
    1 * ~np.isnan(master_catalogue['f_megacam_r']) +
    1 * ~np.isnan(master_catalogue['f_megacam_i']) +
    1 * ~np.isnan(master_catalogue['f_megacam_z']) +
    
    1 * ~np.isnan(master_catalogue['f_suprime_g']) +
    1 * ~np.isnan(master_catalogue['f_suprime_r']) +
    1 * ~np.isnan(master_catalogue['f_suprime_i']) +
    1 * ~np.isnan(master_catalogue['f_suprime_z']) +
    1 * ~np.isnan(master_catalogue['f_suprime_y']) +
    1 * ~np.isnan(master_catalogue['f_suprime_n921']) +
    
    1 * ~np.isnan(master_catalogue['f_gpc1_g']) +
    1 * ~np.isnan(master_catalogue['f_gpc1_r']) +
    1 * ~np.isnan(master_catalogue['f_gpc1_i']) +
    1 * ~np.isnan(master_catalogue['f_gpc1_z']) +
    1 * ~np.isnan(master_catalogue['f_gpc1_y']) +
    
    1 * ~np.isnan(master_catalogue['f_decam_g']) +
    1 * ~np.isnan(master_catalogue['f_decam_r']) +
    1 * ~np.isnan(master_catalogue['f_decam_z']) +
    
    1 * ~np.isnan(master_catalogue['f_kids_u']) +
    1 * ~np.isnan(master_catalogue['f_kids_g']) +
    1 * ~np.isnan(master_catalogue['f_kids_r']) +
    1 * ~np.isnan(master_catalogue['f_kids_i']) 
)

nb_nir_flux = (
    1 * ~np.isnan(master_catalogue['f_ukidss_y']) +
    1 * ~np.isnan(master_catalogue['f_ukidss_j']) +
    1 * ~np.isnan(master_catalogue['f_ukidss_h']) +
    1 * ~np.isnan(master_catalogue['f_ukidss_k'])
)

nb_mir_flux = np.zeros(len(master_catalogue), dtype=bool)
In [42]:
has_optical_flux = nb_optical_flux >= 2
has_nir_flux = nb_nir_flux >= 2
has_mir_flux = nb_mir_flux >= 2

master_catalogue.add_column(
    Column(
        1 * has_optical_flux + 2 * has_nir_flux + 4 * has_mir_flux,
        name="flag_optnir_det")
)

VIII - Cross-identification table¶

We are producing a table associating to each HELP identifier, the identifiers of the sources in the pristine catalogue. This can be used to easily get additional information from them.

In [43]:
#
# Addind SDSS ids
#
sdss = Table.read("../../dmu0/dmu0_SDSS-DR13/data/SDSS-DR13_COSMOS.fits")['objID', 'ra', 'dec']
sdss_coords = SkyCoord(sdss['ra'] * u.deg, sdss['dec'] * u.deg)
idx_ml, d2d, _ = sdss_coords.match_to_catalog_sky(SkyCoord(master_catalogue['ra'], master_catalogue['dec']))
idx_sdss = np.arange(len(sdss))

# Limit the cross-match to 1 arcsec
mask = d2d <= 1. * u.arcsec
idx_ml = idx_ml[mask]
idx_sdss = idx_sdss[mask]
d2d = d2d[mask]
nb_orig_matches = len(idx_ml)

# In case of multiple associations of one master list object to an SDSS object, we keep only the
# association to the nearest one.
sort_idx = np.argsort(d2d)
idx_ml = idx_ml[sort_idx]
idx_sdss = idx_sdss[sort_idx]
_, unique_idx = np.unique(idx_ml, return_index=True)
idx_ml = idx_ml[unique_idx]
idx_sdss = idx_sdss[unique_idx]
print("{} master list rows had multiple associations.".format(nb_orig_matches - len(idx_ml)))

# Adding the ObjID to the master list
master_catalogue.add_column(Column(data=np.full(len(master_catalogue), -1, dtype='>i8'), name="sdss_id"))
master_catalogue['sdss_id'][idx_ml] = sdss['objID'][idx_sdss]
54 master list rows had multiple associations.
In [44]:
id_names = []
for col in master_catalogue.colnames:
    if '_id' in col:
        id_names += [col]
    if '_intid' in col:
        id_names += [col]
        
print(id_names)
['ps1_id', 'candels_id', 'cfhtls_id', 'decals_id', 'hsc-udeep_id', 'hsc-deep_id', 'kids_id', 'las_id', 'wirds_intid', 'help_id', 'sdss_id']
In [45]:
master_catalogue[id_names].write(
    "{}/master_list_cross_ident_cosmos{}.fits".format(OUT_DIR, SUFFIX), overwrite=True)
id_names.remove('help_id')
master_catalogue.remove_columns(id_names)

IX - Adding HEALPix index¶

We are adding a column with a HEALPix index at order 13 associated with each source.

In [46]:
master_catalogue.add_column(Column(
    data=coords_to_hpidx(master_catalogue['ra'], master_catalogue['dec'], order=13),
    name="hp_idx"
))

IX - Saving the catalogue¶

In [47]:
columns = ["help_id", "field", "ra", "dec", "hp_idx"]

bands = [column[5:] for column in master_catalogue.colnames if 'f_ap' in column]
for band in bands:
    columns += ["f_ap_{}".format(band), "ferr_ap_{}".format(band),
                "m_ap_{}".format(band), "merr_ap_{}".format(band),
                "f_{}".format(band), "ferr_{}".format(band),
                "m_{}".format(band), "merr_{}".format(band),
                "flag_{}".format(band)]    
    
columns += ['f_candels_f125w', 'ferr_candels_f125w', 'm_candels_f125w', 'merr_candels_f125w', 'flag_candels_f125w',
            'f_candels_f606w', 'ferr_candels_f606w', 'm_candels_f606w', 'merr_candels_f606w', 'flag_candels_f606w',
            'f_candels_f814w', 'ferr_candels_f814w', 'm_candels_f814w', 'merr_candels_f814w', 'flag_candels_f814w'
           ]
    
columns += ["stellarity", "flag_cleaned", "flag_merged", "flag_gaia", "flag_optnir_obs", "flag_optnir_det", "ebv"]
In [48]:
# We check for columns in the master catalogue that we will not save to disk.
print("Missing columns: {}".format(set(master_catalogue.colnames) - set(columns)))
Missing columns: set()
In [49]:
master_catalogue[columns].write("{}/master_catalogue_cosmos{}.fits".format(OUT_DIR, SUFFIX), overwrite = True)