ELAIS S1 Master List Creation¶

Preparation of VIDEO/VISTA/VIRCAM data¶

The catalogue comes from dmu0_VISTA_VIDEO-private.

There is an old public version of the catalogue but we are using the newer private version in the hope that it will be public by the time we publish the masterlist.

Filters: Y,J,H,Ks

In the catalogue, we keep:

  • The identifier (it's unique in the catalogue);
  • The position (degrees);
  • The stellarity;
  • The magnitude for each band in apertude 3, which is 2 arcsec (rs548 presumes same for private catalogue).
  • The “auto” magnitude is provided, we presume this is standard Sextractor units etc.

Yannick said the dates of observation for VIDEO are from 2009/11 to 2016/12. There is a paper from 2012 (Jarvis et al). So will use 2012.

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]:
import locale
locale.setlocale(locale.LC_ALL, 'en_GB')
Out[3]:
'en_GB'
In [4]:
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
In [5]:
OUT_DIR =  os.environ.get('TMP_DIR', "./data_tmp")
try:
    os.makedirs(OUT_DIR)
except FileExistsError:
    pass

RA_COL = "video_ra"
DEC_COL = "video_dec"

I - Column selection¶

In [6]:
imported_columns = OrderedDict({
        'ID':              'video_id', 
        'ALPHA_J2000':     'video_ra', 
        'DELTA_J2000':     'video_dec', 
        'J_CLASS_STAR':    'video_stellarity', 
        'Z_MAG_APER_3':    'm_ap_video_z', 
        'Z_MAGERR_APER_3': 'merr_ap_video_z', 
        'Z_MAG_AUTO':      'm_video_z', 
        'Z_MAGERR_AUTO':   'merr_video_z',
        'Z_FLUX_APER_3':   'f_ap_video_z', 
        'Z_FLUXERR_APER_3':'ferr_ap_video_z', 
        'Z_FLUX_AUTO':     'f_video_z', 
        'Z_FLUXERR_AUTO':  'ferr_video_z',
        'Y_MAG_APER_3':    'm_ap_video_y', 
        'Y_MAGERR_APER_3': 'merr_ap_video_y', 
        'Y_MAG_AUTO':      'm_video_y', 
        'Y_MAGERR_AUTO':   'merr_video_y',
        'Y_FLUX_APER_3':   'f_ap_video_y', 
        'Y_FLUXERR_APER_3':'ferr_ap_video_y', 
        'Y_FLUX_AUTO':     'f_video_y', 
        'Y_FLUXERR_AUTO':  'ferr_video_y',
        'J_MAG_APER_3':    'm_ap_video_j', 
        'J_MAGERR_APER_3': 'merr_ap_video_j', 
        'J_MAG_AUTO':      'm_video_j', 
        'J_MAGERR_AUTO':   'merr_video_j',
        'J_FLUX_APER_3':   'f_ap_video_j', 
        'J_FLUXERR_APER_3':'ferr_ap_video_j', 
        'J_FLUX_AUTO':     'f_video_j', 
        'J_FLUXERR_AUTO':  'ferr_video_j',
        'H_MAG_APER_3':    'm_ap_video_h', 
        'H_MAGERR_APER_3': 'merr_ap_video_h', 
        'H_MAG_AUTO':      'm_video_h', 
        'H_MAGERR_AUTO':   'merr_video_h',
        'H_FLUX_APER_3':   'f_ap_video_h', 
        'H_FLUXERR_APER_3':'ferr_ap_video_h', 
        'H_FLUX_AUTO':     'f_video_h', 
        'H_FLUXERR_AUTO':  'ferr_video_h',    
        'K_MAG_APER_3':    'm_ap_video_k', 
        'K_MAGERR_APER_3': 'merr_ap_video_k', 
        'K_MAG_AUTO':      'm_video_k', 
        'K_MAGERR_AUTO':   'merr_video_k',
        'K_FLUX_APER_3':   'f_ap_video_k', 
        'K_FLUXERR_APER_3':'ferr_ap_video_k', 
        'K_FLUX_AUTO':     'f_video_k', 
        'K_FLUXERR_AUTO':  'ferr_video_k'
})


catalogue = Table.read("../../dmu0/dmu0_VISTA-VIDEO-private/data/VIDEO-all_2017-02-12_fullcat_errfix_ELAIS-S1.fits"
                      )[list(imported_columns)]
for column in imported_columns:
    catalogue[column].name = imported_columns[column]
    
    
epoch = 2012

# Clean table metadata
catalogue.meta = None
In [7]:
#Replace 99.0 with NaN values
for col in catalogue.colnames:
    catalogue[col].unit = None
    if col.startswith('m'): # | col.endswith('ra') | col.endswith('dec'):
        catalogue[col][np.where(catalogue[col] == 99.0)] = np.nan

# Adding band-flag columns
for col in catalogue.colnames:
    if col.startswith('m_'):
        
        #errcol = "merr{}".format(col[1:])
        #flux, error = utils.mag_to_flux(np.array(video[col]), np.array(video[errcol]))

        # Fluxes are added in µJy
        #video.add_column(Column(flux * 1.e6, name="f{}".format(col[1:])))
        #video.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.
In [8]:
catalogue[:10].show_in_notebook()
Out[8]:
<Table length=10>
idxvideo_idvideo_ravideo_decvideo_stellaritym_ap_video_zmerr_ap_video_zm_video_zmerr_video_zf_ap_video_zferr_ap_video_zf_video_zferr_video_zm_ap_video_ymerr_ap_video_ym_video_ymerr_video_yf_ap_video_yferr_ap_video_yf_video_yferr_video_ym_ap_video_jmerr_ap_video_jm_video_jmerr_video_jf_ap_video_jferr_ap_video_jf_video_jferr_video_jm_ap_video_hmerr_ap_video_hm_video_hmerr_video_hf_ap_video_hferr_ap_video_hf_video_hferr_video_hm_ap_video_kmerr_ap_video_km_video_kmerr_video_kf_ap_video_kferr_ap_video_kf_video_kferr_video_kflag_video_zflag_video_yflag_video_jflag_video_hflag_video_k
010000019.22189563882-45.14970357493.56565e-0522.29370.096824822.84110.1503211209.27107.845730.395101.12723.95770.82694628.294337.0292261.166198.9234.81153164.10322.94150.17227225.14441.45016665.916105.66387.5491116.93824.24041.38406nannan201.305256.626-40.9425173.65220.43890.093399620.63950.09732666674.83574.2165548.92497.428FalseFalseFalseFalseFalse
110000029.11960666083-45.14924723780.74855922.64080.1142623.53440.240561878.38692.4417385.70285.460622.39250.082291722.84250.1310691104.0383.6814729.46788.063422.39760.11065522.59420.1419971098.94112.005916.927119.92322.1130.15522222.3310.1824561428.25204.1961168.47196.36521.58090.2315822.20450.2318442331.43497.2951312.74280.328FalseFalseFalseFalseFalse
210000039.4920486098-45.14962115950.9035823.70580.31150823.7280.292208329.35294.4972322.70286.853122.7240.19204122.66930.1578813.612143.914855.585124.35422.40710.14514322.26240.1248941089.34145.6291244.65143.17821.99290.17285522.16460.1857791595.28253.9861361.95233.04921.24280.15363821.50240.1566133183.39450.4852506.24361.527FalseFalseFalseFalseFalse
310000049.1708830207-45.149255480.93263523.38360.19134423.37180.206772443.16678.1035447.99285.320123.18180.15709322.98180.16224533.68877.2208641.64895.884122.87770.1696322.53660.147733706.204110.338966.885131.56521.86080.11820622.01720.1535071801.76196.1671559.94220.5621.43370.13398221.52870.1369662670.0329.4932446.46308.633FalseFalseFalseFalseFalse
410000059.4980769958-45.14959332010.97124323.41840.24167123.5640.306869429.18695.5343375.327106.08522.35490.0970922.31430.1108691143.03102.2171186.55121.16821.36850.062863521.37950.07050382835.37164.1712806.64182.25921.21350.077584621.20170.08775743270.35233.7013306.04267.22820.40550.077865720.39930.07761726883.4493.6726922.73494.909FalseFalseFalseFalseFalse
510000069.11701662708-45.14880849920.81550622.88450.093312922.95910.124259701.79160.3169655.18274.985722.65670.076166122.73460.119869865.60160.7253805.64688.949422.34010.081019222.3120.1107971158.7186.46731189.1121.34922.15790.11459222.4220.1970851370.39144.6411074.47195.04721.8220.13779521.78330.1521771867.29236.9921935.01271.221FalseFalseFalseFalseFalse
610000079.56032705231-45.14911610560.9823321.49540.033229421.46540.04000532522.5377.20582593.2195.553420.94550.022070920.91410.02800324186.0285.09644308.77111.13520.68470.030820820.66770.03504665322.41151.0925406.54174.52420.21060.030561620.23160.03705248236.84231.868078.67275.70619.73470.023250719.70810.027596112767.7273.42613084.9332.59FalseFalseFalseFalseFalse
710000089.47809268427-45.14911675260.98077521.66270.038019920.79340.04105752162.2675.71954815.56182.10821.2810.0242320.57350.02662053073.2768.58735896.54144.57820.8460.024091220.19230.02722734587.61101.7978376.72210.07220.10530.021643419.65290.02920929075.35180.91713767.6370.39619.86780.023095319.43510.034833111294.8240.26616825.7539.826FalseFalseFalseFalseFalse
810000099.088978899-45.14840410630.68679123.79930.18341223.76620.249672302.251.0519311.53171.641223.1640.11041723.43620.224896542.47655.1706422.21987.460123.8610.30950323.62350.36742285.49681.3871355.32120.24622.24570.11427822.3040.1737931263.94133.0381197.83191.74121.63230.10230821.77460.146592223.74209.5491950.59263.367FalseFalseFalseFalseFalse
910000109.843479474-45.14822473660.68637724.34820.67058224.4880.699839182.269112.578160.253103.29924.01430.7221223.9130.402956247.892164.878272.145101.00622.44180.12531222.56340.1560711055.09121.779943.275135.59722.14160.3030622.07140.2466121391.05388.2951483.96337.07520.90660.12335221.27090.1430154338.59492.9313101.94408.607FalseFalseFalseFalseFalse

II - Removal of duplicated sources¶

We remove duplicated objects from the input catalogues.

In [9]:
SORT_COLS = ['merr_ap_video_z', 'merr_ap_video_y', 'merr_ap_video_j', 'merr_ap_video_h', 'merr_ap_video_k']
FLAG_NAME = 'video_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 831778 sources.
The cleaned catalogue has 830089 sources (1689 removed).
The cleaned catalogue has 1680 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 [10]:
gaia = Table.read("../../dmu0/dmu0_GAIA/data/GAIA_ELAIS-S1.fits")
gaia_coords = SkyCoord(gaia['ra'], gaia['dec'])
In [11]:
nb_astcor_diag_plot(catalogue[RA_COL], catalogue[DEC_COL], 
                    gaia_coords.ra, gaia_coords.dec)
In [12]:
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.19172828544000708 arcsec
Dec correction: -0.07611326062857415 arcsec
In [13]:
catalogue[RA_COL] = catalogue[RA_COL] +  delta_ra.to(u.deg)
catalogue[DEC_COL] = catalogue[DEC_COL] + delta_dec.to(u.deg)
In [14]:
nb_astcor_diag_plot(catalogue[RA_COL], catalogue[DEC_COL], 
                    gaia_coords.ra, gaia_coords.dec)

IV - Flagging Gaia objects¶

In [15]:
catalogue.add_column(
    gaia_flag_column(SkyCoord(catalogue[RA_COL], catalogue[DEC_COL]), epoch, gaia)
)
In [16]:
GAIA_FLAG_NAME = "video_flag_gaia"

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

IV - Flagging objects near bright stars¶

In [17]:
#This section may be superseeded by merely using multiband detection as evidence of good data
#starmask.flag_artefacts

V - Saving to disk¶

In [18]:
catalogue.write("{}/VISTA-VIDEO.fits".format(OUT_DIR), overwrite=True)