ELAIS-N1 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: 
284b2ef (Mon Aug 14 20:02:12 2017 +0100)
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_ELAIS-N1.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
0446677390759242.83887099456.486845805622.70550.13604622.73380.163164nannannannan0.053.004810.3765132.927510.439945FalsenannannannanFalse
1446677390773242.97085350556.487978269319.42160.012772319.56280.013560820.03520.019943719.98260.03372540.99386561.85090.72759754.30980.678327False35.14990.64566336.89281.14597False
2446677390774242.97734785256.488412209421.40020.047014721.37350.051034120.72770.034585120.60410.04887040.003067499.997890.4329310.24720.481662False18.5740.59165720.81370.936853False
3446677390775243.03712511456.48840567219.57360.013926119.67740.015381519.75160.016107919.65160.02901770.99386553.77120.68969348.86940.692328False45.64060.6771250.04611.33755False
4446677390776242.95752735356.488566737122.50580.11463322.84120.29554121.86210.091178521.56460.1507240.4864863.611310.3812842.651640.721783False6.533850.5487028.59361.19298False
5446677390777242.90896245656.488541947122.0810.080584622.2850.084134721.32660.057509721.49670.05779020.4864865.340570.3963834.425850.342963False10.69940.566739.147790.486907False
6446677390778242.81270314556.488090283521.23510.041605821.19660.042485320.11940.021311320.00360.02405020.0030674911.64070.44607412.05990.47191False32.52790.63847236.18730.801587False
7446677390779243.03356736656.488873857122.12530.083399721.63360.088838621.60220.072517121.26590.1012360.003067495.12720.393848.06390.659815False8.301130.55443811.31481.05501False
8446677390780243.03866198556.48877329421.11190.037907120.92550.050198120.11970.021258819.88360.02924970.0030674913.03880.45523515.48170.715783False32.51720.63668940.41741.08885False
9446677390781242.83846511556.488537013522.76620.14332222.95120.15918721.3490.058456221.5120.05945840.1333332.841420.3750792.396290.351335False10.48080.5642889.019890.493958False

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 780316 sources.
The cleaned catalogue has 779436 sources (880 removed).
The cleaned catalogue has 876 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_ELAIS-N1.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.09201103617897388 arcsec
Dec correction: -0.033934257209011776 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)))
35058 sources flagged.

V - Saving to disk

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