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:
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.
from herschelhelp_internal import git_version
print("This notebook was run with herschelhelp_internal version: \n{}".format(git_version()))
%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
import locale
locale.setlocale(locale.LC_ALL, 'en_GB')
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
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"
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
#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.
catalogue[:10].show_in_notebook()
We remove duplicated objects from the input catalogues.
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])))
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.
gaia = Table.read("../../dmu0/dmu0_GAIA/data/GAIA_ELAIS-S1.fits")
gaia_coords = SkyCoord(gaia['ra'], gaia['dec'])
nb_astcor_diag_plot(catalogue[RA_COL], catalogue[DEC_COL],
gaia_coords.ra, gaia_coords.dec)
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))
catalogue[RA_COL] = catalogue[RA_COL] + delta_ra.to(u.deg)
catalogue[DEC_COL] = catalogue[DEC_COL] + delta_dec.to(u.deg)
nb_astcor_diag_plot(catalogue[RA_COL], catalogue[DEC_COL],
gaia_coords.ra, gaia_coords.dec)
catalogue.add_column(
gaia_flag_column(SkyCoord(catalogue[RA_COL], catalogue[DEC_COL]), epoch, gaia)
)
GAIA_FLAG_NAME = "video_flag_gaia"
catalogue['flag_gaia'].name = GAIA_FLAG_NAME
print("{} sources flagged.".format(np.sum(catalogue[GAIA_FLAG_NAME] > 0)))
#This section may be superseeded by merely using multiband detection as evidence of good data
#starmask.flag_artefacts
catalogue.write("{}/VISTA-VIDEO.fits".format(OUT_DIR), overwrite=True)