GAMA-12 master catalogue

Preparation of UKIRT Infrared Deep Sky Survey / Large Area Survey (UKIDSS/LAS)

Information about UKIDSS can be found at http://www.ukidss.org/surveys/surveys.html

The catalogue comes from dmu0_UKIDSS-LAS.

In the catalogue, we keep:

  • The identifier (it's unique in the catalogue);
  • The position;
  • The stellarity;
  • The magnitude for each band in aperture 3 (2 arcsec).
  • The hall magnitude is described as the total magnitude.

J band magnitudes are available in two eopchs. We take the first arbitrarily.

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

Band AB offset
Y 0.634
J 0.938
H 1.379
K 1.900

Each source is associated with an epoch. These range between 2005 and 2007. We take 2006 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 = "las_ra"
DEC_COL = "las_dec"

I - Column selection

In [4]:
#Is the following standard (different names for radec vs mag)?
imported_columns = OrderedDict({
        'SOURCEID': 'las_id',
        'RA': 'las_ra',
        'Dec': 'las_dec',
        'YHALLMAG': 'm_ukidss_y',
        'YHALLMAGERR': 'merr_ukidss_y',
        'YAPERMAG3': 'm_ap_ukidss_y',
        'YAPERMAG3ERR': 'merr_ap_ukidss_y',
        'J_1HALLMAG': 'm_ukidss_j',
        'J_1HALLMAGERR': 'merr_ukidss_j',
        'J_1APERMAG3': 'm_ap_ukidss_j',
        'J_1APERMAG3ERR': 'merr_ap_ukidss_j',
        'HAPERMAG3': 'm_ap_ukidss_h',
        'HAPERMAG3ERR': 'merr_ap_ukidss_h',
        'HHALLMAG': 'm_ukidss_h',
        'HHALLMAGERR': 'merr_ukidss_h',
        'KAPERMAG3': 'm_ap_ukidss_k',
        'KAPERMAG3ERR': 'merr_ap_ukidss_k',
        'KHALLMAG': 'm_ukidss_k',
        'KHALLMAGERR': 'merr_ukidss_k',
        'PSTAR': 'las_stellarity'
    })

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

#Epochs between 2005 and 2007. Rough average:
epoch = 2006

# Clean table metadata
catalogue.meta = None
WARNING: UnitsWarning: 'RADIANS' did not parse as fits unit: At col 0, Unit 'RADIANS' 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:])
        
        # LAS 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('y'):
            catalogue[col] += 0.634
        elif col.endswith('j'):
            catalogue[col] += 0.938
        elif col.endswith('h'):
            catalogue[col] += 1.379
        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>
idxlas_idlas_ralas_decm_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_k
0433868214611177.621028054-0.657633289682nannannannan20.28220.2799520.00340.20376519.44750.094625719.56570.14379119.74980.15938819.36110.2150730.944606nannanFalsenannan27.99737.21892False36.19516.7928860.39625.2637454.16667.17365False45.71716.7113665.400112.9551False
1433868214612177.643909694-0.658838966029nannannannan17.48340.049666518.0510.035061217.84270.022860417.20590.034890917.92180.030844917.19290.04558420.000171409nannanFalsenannan368.68116.8651False218.5717.05822264.8065.57556476.02415.2974False246.1966.99423481.75920.2265False
2433868214613177.661135574-0.659288988821nannannannan18.0350.069280918.41660.04859418.19190.031046817.96630.049341718.27360.042251617.94820.06357720.000171409nannanFalsenannan221.82214.1545False156.0826.98571191.975.48943236.31410.7394False178.0646.9294240.2914.0706False
3433868214618177.702763524-0.666044924906nannannannan14.81290.0033367914.7760.0027888214.65270.0022391714.68830.0028769814.92350.0029932414.97570.004078330.999657nannanFalsenannan4313.6513.2571False4462.7411.4634999.610.31094838.012.8197False3895.910.74053712.8213.9464False
4433868214621177.630615438-0.672197056659nannannannan14.40720.0024980114.3650.0021610314.20080.0017239414.22870.0021966214.63070.002469714.66660.003255650.999657nannanFalsenannan6268.0914.4213False6516.2912.96997580.3612.03627388.0314.9472False5101.811.60494935.6914.8False
5433868214623177.696541646-0.672701277414nannannannan14.72010.0030877414.68180.0026239514.81120.0024515614.84240.0031569715.31650.003871415.37390.005284670.999657nannanFalsenannan4698.5213.3622False4867.1311.76264320.49.755334198.0812.2067False2712.739.672772573.0912.5242False
6433868214626177.715707747-0.674883265918nannannannan17.61910.039383817.54650.022698717.42230.016063917.48740.023078117.68240.025125917.74710.04065630.999657nannanFalsenannan325.36311.8022False347.8667.27259390.035.77066367.3197.80764False306.9197.10265289.16510.828False
7433868214627177.624008287-0.675781383366nannannannan18.26050.092848719.01890.08292718.76520.050966117.99010.075575918.5450.053237818.0020.09762860.000171409nannanFalsenannan180.21415.4114False89.6256.84544113.2225.31481231.17916.0919False138.6696.7995228.66420.5613False
8433868214628177.687379304-0.676687549685nannannannan19.08230.1497219.39630.11740119.23530.078382519.02040.14431719.18730.095896519.51920.3514180.000171409nannanFalsenannan84.545211.6586False63.30876.8456173.43175.3012589.504411.897False76.75096.7789456.533418.2981False
9433868214629177.637922593-0.676547415089nannannannan18.04360.071603618.57120.055455818.27010.03292717.5970.054494218.1690.038122617.71590.06218530.000171409nannanFalsenannan220.06614.5132False135.3756.91451178.6365.41749332.03216.665False196.0736.88457297.61817.046False

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 = 'las_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 949148 sources.
The cleaned catalogue has 948556 sources (592 removed).
The cleaned catalogue has 589 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_GAMA-12.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, near_ra0=True
)

print("RA correction: {}".format(delta_ra))
print("Dec correction: {}".format(delta_dec))
RA correction: -0.11539355086824798 arcsec
Dec correction: -0.09543808613279303 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 = "las_flag_gaia"

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

V - Flagging objects near bright stars

VI - Saving to disk

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