XMM-LSS master catalogue¶

Preparation of UKIRT Infrared Deep Sky Survey / Deep Extragalactic Survey (UKIDSS/DXS)¶

The catalogue comes from dmu0_UKIDSS-DXS_DR10plus.

In the catalogue, we keep:

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

The magnitudes are “Vega like”. The AB offsets are given by Hewett et al. (2016):

Band AB offset
J 0.938
H 1.379
K 1.900

A query to the UKIDSS database with 242.9+55.071 position returns a list of images taken between 2007 and 2009. Let's take 2008 for the epoch.

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 = "dxs_ra"
DEC_COL = "dxs_dec"

I - Column selection¶

In [4]:
imported_columns = OrderedDict({
        'sourceid': 'dxs_id',
        'RA': 'dxs_ra',
        'Dec': 'dxs_dec',
        'JAPERMAG3': 'm_ap_ukidss_j',
        'JAPERMAG3ERR': 'merr_ap_ukidss_j',
        'JKRONMAG': 'm_ukidss_j',
        'JKRONMAGERR': 'merr_ukidss_j',
        'KAPERMAG3': 'm_ap_ukidss_k',
        'KAPERMAG3ERR': 'merr_ap_ukidss_k',
        'KKRONMAG': 'm_ukidss_k',
         'KKRONMAGERR': 'merr_ukidss_k',
         'PSTAR': 'dxs_stellarity'
    })

catalogue = Table.read(
    "../../dmu0/dmu0_UKIDSS-DXS_DR10plus/data/UKIDSS-DR10plus_XMM-LSS.fits")[list(imported_columns)]
for column in imported_columns:
    catalogue[column].name = imported_columns[column]

epoch = 2008

# Clean table metadata
catalogue.meta = None
WARNING: UnitsWarning: 'degrees' did not parse as fits unit: At col 0, Unit 'degrees' 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('m_'):
        
        errcol = "merr{}".format(col[1:])
        
        # DXS uses a huge negative number for missing values
        catalogue[col][catalogue[col] < -100] = np.nan
        catalogue[errcol][catalogue[errcol] < -100] = np.nan
        
        # Vega to AB correction
        if col.endswith('j'):
            catalogue[col] += 0.938
        elif col.endswith('k'):
            catalogue[col] += 1.900
        else:
            print("{} column has wrong band...".format(col))

        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:])))
        
        # 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>
idxdxs_iddxs_radxs_decm_ap_ukidss_jmerr_ap_ukidss_jm_ukidss_jmerr_ukidss_jm_ap_ukidss_kmerr_ap_ukidss_km_ukidss_kmerr_ukidss_kdxs_stellarityf_ap_ukidss_jferr_ap_ukidss_jf_ukidss_jferr_ukidss_jflag_ukidss_jf_ap_ukidss_kferr_ap_ukidss_kf_ukidss_kferr_ukidss_kflag_ukidss_k
degreesdegrees
044667934781834.91798053-2.55580229131nannannannan19.31360.012187219.30940.01282820.05nannannannanFalse68.3210.76689368.58920.810394False
144667934781934.9572533827-2.55559991421nannannannan20.59120.031861520.58960.04311180.05nannannannanFalse21.06250.61808821.09370.837575False
244667934782034.9573000353-2.55565754591nannannannan21.04130.046225321.54790.148190.05nannannannanFalse13.91510.5924378.726481.19106False
344667934782234.8941725314-2.55479271224nannannannan21.56620.072557221.76440.0754050.9nannannannanFalse8.580420.5734097.149120.496511False
444667934782434.799567038-2.5547325608nannannannan20.95160.043097821.01560.05043310.05nannannannanFalse15.11320.59991214.24790.661823False
544667934782534.7684661738-2.55457775799nannannannan21.60570.075479722.04740.07176860.05nannannannanFalse8.274440.5752335.508360.36411False
644667934782634.7971903201-2.55448072181nannannannan21.30260.058023621.32650.08876330.05nannannannanFalse10.93870.58458110.70070.874826False
744667934782734.8328363286-2.55434509318nannannannan21.61780.076038821.85340.07925930.9nannannannanFalse8.18260.5730636.586010.480782False
844667934782834.9599928558-2.55436551507nannannannan19.99970.020016220.18690.02044460.05nannannannanFalse36.31770.66953730.56480.575539False
944667934782934.835910565-2.55451541625nannannannan19.22710.011510119.2340.01193820.05nannannannanFalse73.98840.78436673.52140.808402False

II - Removal of duplicated sources¶

We remove duplicated objects from the input catalogues.

In [7]:
SORT_COLS = ['merr_ap_ukidss_j', 'merr_ap_ukidss_k']
FLAG_NAME = 'dxs_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 428666 sources.
The cleaned catalogue has 428225 sources (441 removed).
The cleaned catalogue has 439 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.10588225883907398 arcsec
Dec correction: -0.09947294019285735 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 = "dxs_flag_gaia"

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

V - Saving to disk¶

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