GAMA-15 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-15.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
0433860931989210.828151651-0.000720399124165nannannannannannannannan16.70460.0076405615.87740.0159975nannannannan0.05nannanFalsenannannannanFalsenannan755.365.315631618.2223.8432FalsenannannannanFalse
1433860932033211.055883817-1.22250062652e-05nannannannannannannannannannannannan19.18970.092021319.42270.09339840.9nannanFalsenannannannanFalsenannannannannannanFalse76.5836.4907761.78835.31522False
2433860932036211.057362115-0.000614968087839nannannannannannannannannannannannan18.98260.076357116.76480.02422670.05nannanFalsenannannannanFalsenannannannannannanFalse92.67666.51771714.64715.9463False
3433860932037211.057070717-0.000360071066638nannannannannannannannannannannannan17.8010.026668917.40550.08102880.05nannanFalsenannannannanFalsenannannannannannanFalse275.176.75899396.08629.56False
4433860932038211.057608576-0.000827967156775nannannannannannannannannannannannan17.99750.031688917.51820.05193190.05nannanFalsenannannannanFalsenannannannannannanFalse229.6246.70193357.03217.0772False
5433860932039211.056841576-0.00104414835665nannannannannannannannannannannannan18.27010.040318518.6020.03855790.05nannanFalsenannannannanFalsenannannannannannanFalse178.6326.63345131.5824.67289False
6433860932040211.056137141-0.00122609201088nannannannannannannannannannannannan17.90620.029242116.74750.02765750.05nannanFalsenannannannanFalsenannannannannannanFalse249.7526.72655726.10518.4965False
7433860932041211.05627277-0.000665954064997nannannannannannannannannannannannan18.48370.048750617.74150.07092960.05nannanFalsenannannannanFalsenannannannannannanFalse146.7326.5884290.65818.9883False
8433860932042211.057178089-0.00146604336658nannannannannannannannannannannannan17.78670.026353617.99950.02729750.05nannanFalsenannannannanFalsenannannannannannanFalse278.8196.76764229.1835.7621False
9433861303270213.21555745-0.00083989545238720.43180.12889821.17360.131036nannannannannannannannannannannannan0.0524.39362.89599False12.31891.48675nannanFalsenannannannannannanFalsenannannannanFalse

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 1497654 sources.
The cleaned catalogue has 1497176 sources (478 removed).
The cleaned catalogue has 471 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-15.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, near_ra0=True)
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.09769077962573647 arcsec
Dec correction: -0.09119343336112529 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, near_ra0=True)

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)))
183382 sources flagged.

V - Flagging objects near bright stars

VI - Saving to disk

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