ELAIS-N1 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: 
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 = "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/en1_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
0189636200346240.53827200555.8850302640.00017143723.8750.23523.9970.48822.6560.04522.6230.05221.3550.03721.4530.03721.0570.0521.1870.04620.6480.08420.7990.0881.023290.2214840.9145340.411051False3.144850.1303433.241910.155267False10.42320.3552049.523580.324547False13.71510.63160612.16750.515506False19.98941.5465217.3941.40980223659False
1189636201299240.61610079455.7707342940.00306748nannannannan24.0790.2223.5280.223.230.1823.0040.204nannannannannannannannannannannannanFalse0.8480070.171831.408640.259481False1.853530.307292.282440.42885FalsenannannannanFalsenannannannanFalse
2189636201298240.70360913155.7708773820.486486nannannannan23.9670.19923.9850.25623.5340.23823.4760.339nannannannannannannannannannannannanFalse0.9401570.1723170.9246970.218029False1.400880.307081.477750.461398FalsenannannannanFalsenannannannanFalse
3189636201297240.58410953155.7708684170.00306748nannannannannannannannan22.7240.11422.6230.18322.4420.1522.3710.273nannannannannannannannanFalsenannannannanFalse2.953920.3101563.241910.546421False3.830010.5291364.088841.02811FalsenannannannanFalse
4189636201296240.64166896555.7715585729.52581e-06nannannannan22.1920.04922.1950.05721.0690.03121.1280.03220.5170.03820.4760.04220.2270.06420.2110.076nannannannanFalse4.82170.2176064.80840.252436False13.56440.38729112.84690.378639False22.55280.78933123.42070.905993False29.45781.7364229.89512.09261364216False
5189636201295240.48764804655.771296969.52581e-06nannannannan23.3860.1223.3410.19322.2990.07922.3720.08221.4760.06721.5260.0721.3230.12521.3840.137nannannannanFalse1.605460.1774421.67340.297463False4.369180.3179094.085070.308524False9.323950.5753748.904310.574082False10.73491.2359110.14841.28054794823False
6189636201294240.58339839755.7715713165.29221e-0722.4910.07522.6420.06921.8090.04121.7880.0521.2060.03321.170.04320.9420.04720.890.05820.8950.09120.6260.1313.6610.2528933.185660.202453False6.86120.2590956.99520.322141False11.95640.36340412.35950.48949False15.24750.66004515.99560.854483False15.92211.3344920.39862.46119958865False
7189636201293240.63051017355.7715863580.999657nannannannan23.7530.16523.8730.14123.2480.18323.3130.11622.9890.24523.2590.216nannannannannannannannanFalse1.144980.1740041.025180.133136False1.823060.3072751.717120.183457False2.314190.5222061.804680.359029FalsenannannannanFalse
8189636201292240.41267579755.7711682439.52581e-06nannannannan22.9290.08222.7490.10422.0730.06521.8640.09921.9550.08622.0330.10821.5640.15221.5380.162nannannannanFalse2.445680.1847092.886690.276509False5.380220.3220986.522280.594717False5.997910.4750885.582120.555263False8.598051.20378.806431.31398556368False
9189636201291240.43010201355.7713308830.996753nannannannan21.90.04221.9530.04620.8410.02720.9480.02619.5870.02919.6810.02918.9170.05119.0120.052nannannannanFalse6.309580.2440766.008970.254585False16.7340.4161415.16350.363119False53.11291.4186448.7081.30099False98.44644.624390.19874.31995483814False

II - Removal of duplicated sources

We remove duplicated objects from the input catalogues.

In [7]:
SORT_COLS = ['merr_ap_wfc_r', 'merr_ap_wfc_u', 'merr_ap_wfc_g', '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 1143872 sources.
The cleaned catalogue has 1143463 sources (409 removed).
The cleaned catalogue has 409 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.084394594762216 arcsec
Dec correction: -0.04639860251529626 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 = "wfc_flag_gaia"

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

V - Saving to disk

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