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))
plt.style.use('ggplot')
import locale
locale.setlocale(locale.LC_ALL, 'en_GB')
import os
import time
import itertools
from astropy.coordinates import SkyCoord
from astropy.table import Table
from astropy import units as u
from astropy import visualization as vis
import numpy as np
from matplotlib_venn import venn3, venn2
from herschelhelp_internal.masterlist import nb_compare_mags, nb_ccplots, nb_histograms, find_last_ml_suffix, quick_checks
OUT_DIR = os.environ.get('OUT_DIR', "./data")
SUFFIX = find_last_ml_suffix()
#SUFFIX = "20171016"
master_catalogue_filename = "master_catalogue_akari-sep_{}.fits".format(SUFFIX)
master_catalogue = Table.read("{}/{}".format(OUT_DIR, master_catalogue_filename))
print("Diagnostics done using: {}".format(master_catalogue_filename))
# 0 - Quick checks
quick_checks(master_catalogue).show_in_notebook()
flag_obs = master_catalogue['flag_optnir_obs']
flag_det = master_catalogue['flag_optnir_det']
venn3(
[
np.sum(flag_obs == 4),
np.sum(flag_obs == 2),
np.sum(flag_obs == 6),
np.sum(flag_obs == 1),
np.sum(flag_obs == 5),
np.sum(flag_obs == 3),
np.sum(flag_obs == 7)
],
set_labels=('Optical', 'near-IR', 'mid-IR'),
subset_label_formatter=lambda x: "{}%".format(int(100*x/len(flag_obs)))
)
plt.title("Wavelength domain observations");
venn3(
[
np.sum(flag_det[flag_obs == 7] == 4),
np.sum(flag_det[flag_obs == 7] == 2),
np.sum(flag_det[flag_obs == 7] == 6),
np.sum(flag_det[flag_obs == 7] == 1),
np.sum(flag_det[flag_obs == 7] == 5),
np.sum(flag_det[flag_obs == 7] == 3),
np.sum(flag_det[flag_obs == 7] == 7)
],
set_labels=('Optical', 'near-IR', 'mid-IR'),
subset_label_formatter=lambda x: "{}%".format(int(100*x/np.sum(flag_det != 0)))
)
plt.title("Detection of the {} sources detected\n in any wavelength domains "
"(among {} sources)".format(
locale.format('%d', np.sum(flag_det != 0), grouping=True),
locale.format('%d', len(flag_det), grouping=True)));
Om AKARI-SEP there are no bands with multiple observations. It is still instructive to plot magnitude histograms to give a measure of depth.
u_bands = []
g_bands = ["DECam g"]
r_bands = ["DECam r"]
i_bands = ["DECam i"]
z_bands = ["DECam z"]
y_bands = ["DECam y"]
j_bands = [ "VISTA j"]
h_bands = [ "VISTA h"]
k_bands = [ "VISTA k"]
We compare the histograms of the total aperture magnitudes of similar bands. This revealed that there were no VISTA y band measurements in VHS so we removed that column.
for bands in [g_bands, r_bands, i_bands, z_bands, y_bands, j_bands, h_bands, k_bands]:
colnames = ["m_{}".format(band.replace(" ", "_").lower()) for band in bands]
nb_histograms(master_catalogue, colnames, bands)
Cross-match the master list to 2MASS to compare its magnitudes to 2MASS ones.
master_catalogue_coords = SkyCoord(master_catalogue['ra'], master_catalogue['dec'])
The catalogue is cross-matched to 2MASS-PSC withing 0.2 arcsecond. We compare the UKIDSS total J and K magnitudes to those from 2MASS.
The 2MASS magnitudes are “Vega-like” and we have to convert them to AB magnitudes using the zero points provided on this page:
Band | Fν - 0 mag (Jy) |
---|---|
J | 1594 |
H | 1024 |
Ks | 666.7 |
In addition, UKIDSS uses a K band whereas 2MASS uses a Ks (“short”) band, this page give a correction to convert the K band in a Ks band with the formula:
$$K_{s(2MASS)} = K_{UKIRT} + 0.003 + 0.004 * (J−K)_{UKIRT}$$# The AB zero point is 3631 Jy
j_2mass_to_ab = 2.5 * np.log10(3631/1595)
k_2mass_to_ab = 2.5 * np.log10(3631/666.7)
twomass = Table.read("../../dmu0/dmu0_2MASS-point-sources/data/2MASS-PSC_AKARI-SEP.fits")
twomass_coords = SkyCoord(twomass['raj2000'], twomass['dej2000'])
idx, d2d, _ = twomass_coords.match_to_catalog_sky(master_catalogue_coords)
mask = (d2d < 0.2 * u.arcsec)
twomass = twomass[mask]
ml_twomass_idx = idx[mask]
nb_compare_mags(twomass['jmag'] + j_2mass_to_ab, master_catalogue['m_vista_j'][ml_twomass_idx],
labels=("2MASS J", "VISTA J (total)"))
ukidss_ks_like = master_catalogue['m_vista_k'] + 0.003 + 0.004 * (
master_catalogue['m_vista_j'] - master_catalogue['m_vista_k'])
nb_compare_mags(twomass['kmag'] + k_2mass_to_ab, ukidss_ks_like[ml_twomass_idx],
labels=("2MASS Ks", "VISTA Ks-like (total)"))
From here, we are only comparing sources with a signal to noise ratio above 3, i.e. roughly we a magnitude error below 0.3.
To make it easier, we are setting to NaN in the catalogue the magnitudes associated with an error above 0.3 so we can't use these magnitudes after the next cell.
for error_column in [_ for _ in master_catalogue.colnames if _.startswith('merr_')]:
column = error_column.replace("merr", "m")
keep_mask = np.isfinite(master_catalogue[error_column])
keep_mask[keep_mask] &= master_catalogue[keep_mask][error_column] <= 0.3
master_catalogue[column][~keep_mask] = np.nan
nb_ccplots(
master_catalogue['m_vista_k'],
master_catalogue['m_ap_vista_k'] - master_catalogue['m_vista_k'],
"k total magnitude (VISTA)", "k aperture mag - total mag (VISTA)",
master_catalogue["stellarity"],
invert_x=True
)
nb_ccplots(
master_catalogue['m_irac_i1'] - master_catalogue['m_irac_i2'],
master_catalogue['m_vista_j'] - master_catalogue['m_vista_k'],
"irac 1 - irac 2 (SIMES)", "J - K (VISTA)",
master_catalogue["stellarity"]
)