XMM-LSS master catalogue¶

Preparation of VIMOS Public Extragalactic Redshift Survey (VIPERS) - Multi Lambda Survey (MLS) data¶

This catalogue comes from dmu0_VIPERS.

In the catalogue, we keep:

  • The ident as unique object identifier;
  • The position which is given for all the sources;
  • The ugrizy ks total magnitude.
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, mag_to_flux
In [3]:
OUT_DIR =  os.environ.get('TMP_DIR', "./data_tmp")
try:
    os.makedirs(OUT_DIR)
except FileExistsError:
    pass

RA_COL = "vipers_ra"
DEC_COL = "vipers_dec"

I - Column selection¶

In [4]:
imported_columns = OrderedDict({
        "ident": "vipers_id",
        "ra": "vipers_ra",
        "dec": "vipers_dec",
        "u": "m_vipers_u",
        "err_u": "merr_vipers_u",
        "g": "m_vipers_g",
        "err_g": "merr_vipers_g",
        "r": "m_vipers_r",
        "err_r": "merr_vipers_r",
        "i": "m_vipers_i",
        "err_i": "merr_vipers_i",
        "y": "m_vipers_y",
        "err_y": "merr_vipers_y",
        "z": "m_vipers_z",
        "err_z": "merr_vipers_z",
        "ks": "m_vipers_ks",
        "err_ks": "merr_vipers_ks",
    
    })


catalogue = Table.read("../../dmu0/dmu0_VIPERS-MLS/data/VIPERS-MLS_20160502.fits")[list(imported_columns)]
for column in imported_columns:
    catalogue[column].name = imported_columns[column]

epoch = 2012

# Clean table metadata
catalogue.meta = None
In [5]:
# Adding flux and band-flag columns
for col in catalogue.colnames:
    if col.startswith('m_'):
        
        errcol = "merr{}".format(col[1:])
        
        # -99.0 is used for missing values
        catalogue[col][catalogue[col] < -90.] = np.nan
        catalogue[errcol][catalogue[errcol] < -90.] = np.nan     
        
        flux, error = mag_to_flux(np.array(catalogue[col]), np.array(catalogue[errcol]))
        
        # Fluxes are added in µJy
        catalogue.add_column(Column(flux * 1.e6, name="f{}".format(col[1:])))
        catalogue.add_column(Column(error * 1.e6, name="f{}".format(errcol[1:])))
        
        # We add nan filled aperture photometry for consistency
        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/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/astropy/table/column.py:1096: MaskedArrayFutureWarning: setting an item on a masked array which has a shared mask will not copy the mask and also change the original mask array in the future.
Check the NumPy 1.11 release notes for more information.
  ma.MaskedArray.__setitem__(self, index, value)
In [6]:
catalogue[:10].show_in_notebook()
Out[6]:
<Table masked=True length=10>
idxvipers_idvipers_ravipers_decm_vipers_umerr_vipers_um_vipers_gmerr_vipers_gm_vipers_rmerr_vipers_rm_vipers_imerr_vipers_im_vipers_ymerr_vipers_ym_vipers_zmerr_vipers_zm_vipers_ksmerr_vipers_ksf_vipers_uferr_vipers_um_ap_vipers_umerr_ap_vipers_uf_ap_vipers_uferr_ap_vipers_uflag_vipers_uf_vipers_gferr_vipers_gm_ap_vipers_gmerr_ap_vipers_gf_ap_vipers_gferr_ap_vipers_gflag_vipers_gf_vipers_rferr_vipers_rm_ap_vipers_rmerr_ap_vipers_rf_ap_vipers_rferr_ap_vipers_rflag_vipers_rf_vipers_iferr_vipers_im_ap_vipers_imerr_ap_vipers_if_ap_vipers_iferr_ap_vipers_iflag_vipers_if_vipers_yferr_vipers_ym_ap_vipers_ymerr_ap_vipers_yf_ap_vipers_yferr_ap_vipers_yflag_vipers_yf_vipers_zferr_vipers_zm_ap_vipers_zmerr_ap_vipers_zf_ap_vipers_zferr_ap_vipers_zflag_vipers_zf_vipers_ksferr_vipers_ksm_ap_vipers_ksmerr_ap_vipers_ksf_ap_vipers_ksferr_ap_vipers_ksflag_vipers_ks
degdegmagmagmagmagmagmagmagmagmagmagmagmagmagmag
0181280632.8595944-5.997013424.1880.06523.920.03723.7410.0623.4530.057nannan23.6810.17122.260.1290.7670080.0459186372836nannannannanFalse0.9817470.0334562336661nannannannanFalse1.157710.0639775nannannannanFalse1.509390.0792411nannannannanFalsenannannannannannanFalse1.223490.19269548261nannannannanFalse4.528970.538102527571nannannannanFalse
1181327732.8597219-5.994880425.6020.22524.9790.09324.6730.13624.3070.12nannan23.5340.14521.730.0810.2085450.0432173592912nannannannanFalse0.3701690.0317072486666nannannannanFalse0.4906820.0614631nannannannanFalse0.6873850.0759726nannannannanFalsenannannannannannanFalse1.400880.187086810115nannannannanFalse7.379040.55050432411nannannannanFalse
2181294132.8600604-5.9963977nannan26.5160.38625.2120.26724.1840.136nannan23.3130.14720.4210.028nannannannannannanFalse0.08986680.0319493793199nannannannanFalse0.2986760.0734491nannannannanFalse0.7698390.0964305nannannannanFalsenannannannannannanFalse1.717120.232483890613nannannannanFalse24.63770.635380434687nannannannanFalse
3181150632.8788779-6.00388923.4040.03723.2390.02323.1290.04122.9740.049nannan22.9890.11422.710.2811.579070.0538117875521nannannannanFalse1.838230.0389406355907nannannannanFalse2.034230.0768174nannannannanFalse2.346390.105894nannannannanFalsenannannannannannanFalse2.314190.242985527166nannannannanFalse2.992270.774430237925nannannannanFalse
4181191632.8799722-6.000971726.6820.43725.2220.08624.7410.1124.8230.161nannan24.3860.24922.6170.1610.07712590.0310425543191nannannannanFalse0.2959380.0234408921642nannannannanFalse0.4608930.0466948nannannannanFalse0.4273660.0633726nannannannanFalsenannannannannannanFalse0.6391460.14658015823nannannannanFalse3.259870.483394129787nannannannanFalse
5181301532.8814126-5.996203124.8630.08924.8710.06524.4560.08824.1640.092nannan24.0950.19922.7010.1980.4119070.0337648779691nannannannanFalse0.4088840.0244787329962nannannannanFalse0.5992390.0485689nannannannanFalse0.7841520.0664452nannannannanFalsenannannannannannanFalse0.8356030.153154128611nannannannanFalse3.017170.550225646293nannannannanFalse
6180458732.9401338-6.037274123.0840.03322.5480.01522.0530.01821.9680.025nannan21.7090.04621.4470.12.120310.0644450244636nannannannanFalse3.473760.0479917468965nannannannanFalse5.480250.0908549nannannannanFalse5.926520.136463nannannannanFalsenannannannannannanFalse7.523150.318737741509nannannannanFalse9.576340.882013955561nannannannanFalse
7180434432.9387962-6.036027424.7330.09624.2550.0424.1640.07124.1980.099nannan23.8460.16522.6670.1710.4643010.0410531920352nannannannanFalse0.7211080.026566597171nannannannanFalse0.7841520.0512784nannannannanFalse0.7599760.0692964nannannannanFalsenannannannannannanFalse1.050990.159720036663nannannannanFalse3.113150.490310992063nannannannanFalse
8180366432.9445865-6.041129922.1740.01921.180.00620.7540.00720.4370.008nannan20.4020.01619.9610.0334.90230.0857885684127nannannannanFalse12.24620.0676747658872nannannannanFalse18.13010.116889nannannannanFalse24.27730.178881nannannannanFalsenannannannannannanFalse25.07260.369483575923nannannannanFalse37.63571.14390326416nannannannanFalse
9180430732.9500148-6.03943322.9350.02922.740.01822.3850.02521.9920.025nannan21.4890.03920.5810.0462.43220.0649641594919nannannannanFalse2.910720.0482556233692nannannannanFalse4.036450.0929428nannannannanFalse5.796950.13348nannannannanFalsenannannannannannanFalse9.212970.330933013174nannannannanFalse21.26180.900810711755nannannannanFalse

II - Removal of duplicated sources¶

We remove duplicated objects from the input catalogues.

In [7]:
SORT_COLS = ['merr_vipers_u',
             'merr_vipers_g',
             'merr_vipers_r',
             'merr_vipers_i',
             'merr_vipers_y',
             'merr_vipers_z',
             'merr_vipers_ks']
FLAG_NAME = 'vipers_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])))
/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/astropy/table/column.py:1096: MaskedArrayFutureWarning: setting an item on a masked array which has a shared mask will not copy the mask and also change the original mask array in the future.
Check the NumPy 1.11 release notes for more information.
  ma.MaskedArray.__setitem__(self, index, value)
The initial catalogue had 956549 sources.
The cleaned catalogue has 956536 sources (13 removed).
The cleaned catalogue has 13 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_XMM-LSS.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.09501634402795389 arcsec
Dec correction: -0.12179129389160437 arcsec
In [11]:
catalogue[RA_COL] +=  delta_ra.to(u.deg)
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 = "vipers_flag_gaia"

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

V - Saving to disk¶

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