xFLS 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: 
255270d (Fri Nov 24 10:35:51 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/fls_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
0465698102894258.78060904559.502364639.52581e-06nannannannan19.1340.01817.2920.01818.6750.01616.8520.01618.3150.02217.0830.02217.9550.05616.6540.055nannannannanFalse80.6121.33644439.7447.29035False123.0271.81299659.4789.71842091531False171.3963.47295533.08910.8018479077False238.78112.3158791.40740.0902False
1465698201129258.44361188259.6724588970.999981nannannannan22.00.02822.0480.03320.6940.0220.7650.02119.1960.0219.2470.0218.5230.05418.5550.055nannannannanFalse5.75440.14845.505540.167336False19.16020.35294417.94730.347132421666False76.13781.4025172.6441.3381523604False141.5147.03832137.4046.96046False
2465698201128258.28126476459.6717892130.486486nannannannan24.2790.16124.470.23123.9080.20624.2630.29nannannannannannannannannannannannanFalse0.7053430.1045930.5915620.12586False0.9926580.188340.7158130.191193632872FalsenannannannanFalsenannannannanFalse
3465698201127258.58954573259.6725421620.000171409nannannannan23.1290.1623.2690.16922.4820.05922.4990.06422.2960.11222.2840.149nannannannannannannannanFalse2.034230.2997751.788140.278332False3.691470.2005983.634120.214217623579False4.381270.4519544.429960.607941012731FalsenannannannanFalse
4465698201125258.44117641759.6724050250.486486nannannannan24.1980.15123.7440.17624.0570.23824.0110.254nannannannannannannannannannannannanFalse0.7599760.1056941.154520.187149False0.8653660.1896940.9028170.211207429402FalsenannannannanFalsenannannannanFalse
5465698201124258.313406659.6722131350.944606nannannannan24.3440.17124.3240.17322.9090.08423.1130.07821.5570.0621.7170.049nannannannannannannannanFalse0.6643550.1046340.6767060.107826False2.491150.1927322.064430.148309703036False8.653660.4782197.467930.337032785865FalsenannannannanFalse
6465698201122258.57655799359.6732339010.0030764nannannannan23.9560.12224.0810.17622.8370.0822.810.09321.6780.06521.4240.08620.9720.15720.9390.196nannannannanFalse0.949730.1067170.8464470.137211False2.661950.196142.728980.233753704606False7.741060.4634359.781370.774772102886False14.8322.1447415.28972.76014False
7465698201121258.38957530359.6729898770.0524781nannannannan23.990.12524.1850.24623.2280.11223.4420.10322.0760.09321.9290.099nannannannannannannannanFalse0.9204490.1059710.7691310.174265False1.856950.1915551.524750.144648117498False5.365370.4595776.143270.560158001008FalsenannannannanFalse
8465698201120258.38534707859.6730510880.999657nannannannan23.1640.08423.0410.11922.2250.04722.3430.0521.7740.07221.9320.061nannannannannannannannanFalse1.96970.152392.205970.241781False4.677350.2024764.195660.193217101696False7.085980.4699036.126320.344195753314FalsenannannannanFalse
9465698201119258.42354871459.6732492610.134544nannannannan22.4660.09221.9980.10121.080.02321.0880.02420.4360.02820.4550.0320.070.08319.9890.102nannannannanFalse3.746280.3174415.765010.536287False13.42760.28444813.32910.294636905892False24.29960.62666223.87810.659776324028False34.04082.6022836.67753.44568False

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 490954 sources.
The cleaned catalogue has 490467 sources (487 removed).
The cleaned catalogue has 487 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_xFLS.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.07881807600824686 arcsec
Dec correction: -0.05963852196089192 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)))
31269 sources flagged.

V - Saving to disk

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