Lockman SWIRE master catalogue

Preparation of Isaac Newton Telescope / Wide Field Camera (INT/WFC) data

Isaac Newton Telescope / Wide Field Camera (INT/WFC) catalogue: the catalogue comes from dmu0_INTWFC.

In the catalogue, we keep:

  • The identifier (it's unique in the catalogue);
  • The position;
  • The stellarity;
  • The magnitude for each band in apertude 4 ($1.2 * \sqrt{2}$ arcsec = 1.7 arcsec).
  • The kron magnitude to be used as total magnitude (no “auto” magnitude is provided).

We don't know when the maps have been observed. We will use the year of the reference paper.

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 = "wfc_ra"
DEC_COL = "wfc_dec"

I - Column selection

In [4]:
imported_columns = OrderedDict({
        'id': "wfc_id",
        'ra': "wfc_ra",
        'decl': "wfc_dec",
        'pstar':  "wfc_stellarity",
        'umag4': "m_ap_wfc_u", 
        'uemag4': "merr_ap_wfc_u", 
        'ukronmag': "m_wfc_u", 
        'uekronmag': "merr_wfc_u",
        'gmag4': "m_ap_wfc_g", 
        'gemag4': "merr_ap_wfc_g", 
        'gkronmag': "m_wfc_g", 
        'gekronmag': "merr_wfc_g",
        'rmag4': "m_ap_wfc_r", 
        'remag4': "merr_ap_wfc_r", 
        'rkronmag': "m_wfc_r", 
        'rekronmag': "merr_wfc_r",
        'imag4': "m_ap_wfc_i", 
        'iemag4': "merr_ap_wfc_i", 
        'ikronmag': "m_wfc_i", 
        'iekronmag': "merr_wfc_i",
        'zmag4': "m_ap_wfc_z", 
        'zemag4': "merr_ap_wfc_z", 
        'zkronmag': "m_wfc_z", 
        'zekronmag': "merr_wfc_z"
    })


catalogue = Table.read("../../dmu0/dmu0_INTWFC/data/lh_intwfc_v2.1_HELP_coverage.fits")[list(imported_columns)]
for column in imported_columns:
    catalogue[column].name = imported_columns[column]

epoch = 2011

# Clean table metadata
catalogue.meta = None
In [5]:
# Adding flux and band-flag columns
for col in catalogue.colnames:
    if col.startswith('m_'):
        
        errcol = "merr{}".format(col[1:])
        
        # Some object have a magnitude to 0, we suppose this means missing value
        catalogue[col][catalogue[col] <= 0] = np.nan
        catalogue[errcol][catalogue[errcol] <= 0] = np.nan  
        

        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/ipykernel/__main__.py:8: RuntimeWarning: invalid value encountered in less_equal
/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/ipykernel/__main__.py:9: RuntimeWarning: invalid value encountered in less_equal
In [6]:
catalogue[:10].show_in_notebook()
Out[6]:
<Table length=10>
idxwfc_idwfc_rawfc_decwfc_stellaritym_ap_wfc_umerr_ap_wfc_um_wfc_umerr_wfc_um_ap_wfc_gmerr_ap_wfc_gm_wfc_gmerr_wfc_gm_ap_wfc_rmerr_ap_wfc_rm_wfc_rmerr_wfc_rm_ap_wfc_imerr_ap_wfc_im_wfc_imerr_wfc_im_ap_wfc_zmerr_ap_wfc_zm_wfc_zmerr_wfc_zf_ap_wfc_uferr_ap_wfc_uf_wfc_uferr_wfc_uflag_wfc_uf_ap_wfc_gferr_ap_wfc_gf_wfc_gferr_wfc_gflag_wfc_gf_ap_wfc_rferr_ap_wfc_rf_wfc_rferr_wfc_rflag_wfc_rf_ap_wfc_iferr_ap_wfc_if_wfc_iferr_wfc_iflag_wfc_if_ap_wfc_zferr_ap_wfc_zf_wfc_zferr_wfc_zflag_wfc_z
0445739200533161.32127559457.6393190150.00306748nannannannan23.1160.11623.0490.14422.7460.14722.5680.174nannannannannannannannannannannannanFalse2.058730.2199552.189780.290428False2.894680.3919163.410360.546543FalsenannannannanFalsenannannannanFalse
1445739200534161.17498257257.6391438090.000171409nannannannan22.1840.06622.1050.11321.8590.06721.9070.08921.9230.1122.0420.141nannannannannannannannanFalse4.857360.295275.223960.543693False6.552390.4043446.269030.513885False6.177310.6258475.536050.718943FalsenannannannanFalse
2445739200535161.15192336257.6389307810.999657nannannannan23.150.15223.4120.23622.5620.12522.6730.14722.5950.20222.6510.238nannannannannannannannanFalse1.995260.2793311.567470.340712False3.429250.3948073.095990.419173False3.32660.618913.159370.692553FalsenannannannanFalse
3445739200536161.28670892157.639038090.999657nannannannan20.1550.02320.2450.02619.6290.01819.7520.01919.3850.02219.5270.023nannannannannannannannanFalse31.47750.66681228.97340.693823False51.09750.84712645.62470.798415False63.97341.2962856.13061.18906FalsenannannannanFalse
4445739200537161.08635855557.6375139920.000171409nannannannan21.9180.05321.950.08220.4330.02420.350.0319.8340.02519.7890.029nannannannannannannannanFalse6.205830.3029366.025590.455082False24.36690.53862526.30270.726769False42.30580.97412744.09611.17781FalsenannannannanFalse
5445739200538161.28216980357.6378755260.999657nannannannan21.5690.04121.7060.06720.3810.02320.4010.03119.030.02119.0790.022nannannannannannannannanFalse8.558540.3231917.543970.465533False25.56230.54150625.09570.716535False88.71551.7159184.80071.7183FalsenannannannanFalse
6445739200539161.13216500157.6372053470.9nannannannannannannannan22.7740.15122.6090.195nannannannannannannannannannannannanFalsenannannannanFalse2.820980.3923313.283980.589808FalsenannannannanFalsenannannannanFalse
7445739200541161.3644017457.6377935080.0524781nannannannan23.1230.14923.460.2821.3540.04421.3410.06120.3280.03220.1540.047nannannannannannannannanFalse2.04550.2807131.499690.386753False10.43280.42279310.55840.593206False26.84110.7910931.50651.36387FalsenannannannanFalse
8445739200544161.27428056357.6367552130.05nannannannannannannannan22.5630.12522.5150.158nannannannannannannannannannannannanFalsenannannannanFalse3.42610.3944443.580960.521114FalsenannannannanFalsenannannannanFalse
9445739200545161.28095675257.6368833790.000171409nannannannan22.40.07921.8850.09921.620.05421.4340.07621.4110.07121.0350.099nannannannannannannannanFalse3.981070.2896696.397340.583325False8.165820.4061349.691690.678405False9.89920.64734313.99591.27618FalsenannannannanFalse

II - Removal of duplicated sources

We remove duplicated objects from the input catalogues.

In [7]:
SORT_COLS = ['merr_ap_wfc_r', 'merr_ap_wfc_g', 'merr_ap_wfc_u', 'merr_ap_wfc_z']
FLAG_NAME = 'wfc_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])))
The initial catalogue had 949159 sources.
The cleaned catalogue has 948771 sources (388 removed).
The cleaned catalogue has 388 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.06007787097246364 arcsec
Dec correction: -0.12125572829972953 arcsec
In [11]:
catalogue[RA_COL] = catalogue[RA_COL] + delta_ra.to(u.deg)
catalogue[DEC_COL] = 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 = "wfc_flag_gaia"

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

V - Flagging objects near bright stars

VI - Saving to disk

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