ELAIS-N2 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/en2_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
0220090401629250.87774491840.6681949850.0nannannannan14.940.02213.8240.02214.750.01613.1380.01614.2710.01913.1470.01913.0720.03412.9120.034nannannannanFalse3837.0777.749710725.1217.3191607False4570.8867.35920174.4297.300547361False7105.59124.34520007.8350.129693747False21438.8671.3586784924842.8777.955False
1220090400005251.14012249840.5615978860.9nannannannannannannannan23.7540.21423.7920.162nannannannannannannannannannannannanFalsenannannannanFalse1.143930.225471.104590.16481272155FalsenannannannanFalsenannannannanFalse
2220090400006251.14200992140.6680525820.9nannannannannannannannan23.1480.12323.2710.136nannannannannannannannannannannannanFalsenannannannanFalse1.998940.2264541.784840.223570441449FalsenannannannanFalsenannannannanFalse
3220090400008251.14166729940.6504071510.0030764nannannannan23.6220.10823.7440.1222.2760.05722.4180.0621.8570.06421.9190.08321.4510.14421.0170.18nannannannanFalse1.291810.1284991.154520.127601801978False4.462720.2342883.915620.216384969463False6.564470.386956.200110.473972507734False9.541131.2654300662714.22982.35911False
4220090400010251.14073980640.605089030.05nannannannannannannannan23.2880.1423.4040.155nannannannannannannannannannannannanFalsenannannannanFalse1.757110.226571.579070.225427758664FalsenannannannanFalsenannannannanFalse
5220090400014251.13993234840.564745140.486486nannannannan22.9990.06923.1630.07722.5160.0722.5490.081nannannannannannannannannannannannanFalse2.292980.1457221.971510.139819001106False3.577660.230663.470560.25891709538FalsenannannannanFalsenannannannanFalse
6220090400015251.14168261540.6769371159.52581e-06nannannannan23.6840.12423.680.1422.9120.122.6360.11422.5420.11522.6070.10621.8930.21321.8660.24nannannannanFalse1.220110.1393471.224620.157907793437False2.484280.228813.203320.336341545335False3.493010.3699763.290030.321204103329False6.350391.245820434636.510291.43909False
7220090400016251.13867738140.5325064440.00306748nannannannan23.5490.1122.9520.10623.2690.13823.0030.137nannannannannannannannannannannannanFalse1.381660.1399812.394420.233766090787False1.788140.2272772.284550.288267815904FalsenannannannanFalsenannannannanFalse
8220090400017251.14009968640.6033900910.0524781nannannannan23.5020.10622.9790.11422.9260.10122.4790.12622.8570.19123.090.178nannannannannannannannanFalse1.442780.1408582.335610.245233698479False2.452450.2281383.701690.429582057222False2.613360.4597362.108630.345696951626FalsenannannannanFalse
9220090400004251.13986442840.5468535480.944606nannannannannannannannan23.7070.20523.7540.16122.6220.15522.7410.15321.4190.18821.6330.202nannannannanFalsenannannannanFalse1.194540.2255431.143930.169629625475False3.244890.4632412.908040.409795590485False9.826521.701504945238.068641.50116False

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 824958 sources.
The cleaned catalogue has 824957 sources (1 removed).
The cleaned catalogue has 1 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-N2.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.06821421482072765 arcsec
Dec correction: -0.07353264348779476 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)))
52708 sources flagged.

V - Flagging objects near bright stars

VI - Saving to disk

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