Lockman SWIRE 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: 
44f1ae0 (Thu Nov 30 18:27:54 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_Lockman-SWIRE.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
0446676598786160.06032447459.491757933921.71260.06049121.68540.0540272nannannannan0.057.498560.4177777.688320.382578FalsenannannannanFalse
1446676598788160.05198678859.492133197421.8110.065401321.78140.0582999nannannannan0.056.84840.4125267.03810.377919FalsenannannannanFalse
2446676598791160.05127732659.492390293222.04180.078761922.04750.0722757nannannannan0.055.536920.4016615.507930.366654FalsenannannannanFalse
3446676598795160.05226021459.493181126622.36460.10281922.41930.0984169nannannannan0.054.113170.3895153.910940.354509FalsenannannannanFalse
4446676598821160.13130587959.495861044623.01890.1797623.23990.19968922.65950.20097422.6420.2122530.4864862.25130.3727371.836720.33781False3.134810.5802643.185660.622773False
5446676598825160.24752539559.496371805821.37190.04642421.27220.053348320.84970.04071320.68590.05542090.0030674910.26210.43878711.24940.552746False16.60070.62249319.30290.985308False
6446676598826160.3253811459.496844630622.94690.16856222.910.17562422.44610.16554922.36760.20770.4864862.405780.37352.488920.402598False3.815420.581764.101680.784649False
7446676598827160.21752794859.496536480922.15320.086172822.15370.087216221.44510.067999521.22150.1185690.003067494.997220.3966194.994630.401214False9.593380.60083211.7871.28722False
8446676598828160.23382855159.496812436722.51310.11637622.08950.13262921.16420.053293321.120.06042090.003067493.587280.3845075.298920.647293False12.42610.60993512.9420.720217False
9446676598830160.24302592959.496774693521.28850.043605321.48420.044172421.53520.073535521.62320.105090.99386511.08120.4450449.254070.376495False8.829440.5980068.141430.788022False

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 697325 sources.
The cleaned catalogue has 696542 sources (783 removed).
The cleaned catalogue has 781 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_Lockman-SWIRE.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.05655879374444339 arcsec
Dec correction: -0.12994021536201217 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)))
21766 sources flagged.

V - Flagging objects near bright stars

VI - Saving to disk

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