The Spitzer catalogues were produced by the datafusion team are available in dmu0_DataFusion-Spitzer
.
Lucia told that the magnitudes are aperture corrected.
In the catalouge, we keep:
We keep:
A query of the position in the Spitzer heritage archive show that the ELAIS-N1 images were observed in 2004. Let's take this as epoch.
We do not use the MIPS fluxes as they will be extracted on MIPS maps using XID+.
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, flux_to_mag
OUT_DIR = os.environ.get('TMP_DIR', "./data_tmp")
try:
os.makedirs(OUT_DIR)
except FileExistsError:
pass
RA_COL = "swire_ra"
DEC_COL = "swire_dec"
imported_columns = OrderedDict({
'internal_id': "swire_intid",
'ra_spitzer': "swire_ra",
'dec_spitzer': "swire_dec",
'flux_ap2_36': "f_ap_swire_irac1",
'uncf_ap2_36': "ferr_ap_swire_irac1",
'flux_kr_36': "f_swire_irac1",
'uncf_kr_36': "ferr_swire_irac1",
'stell_36': "swire_stellarity_irac1",
'flux_ap2_45': "f_ap_swire_irac2",
'uncf_ap2_45': "ferr_ap_swire_irac2",
'flux_kr_45': "f_swire_irac2",
'uncf_kr_45': "ferr_swire_irac2",
'stell_45': "swire_stellarity_irac2",
'flux_ap2_58': "f_ap_irac3",
'uncf_ap2_58': "ferr_ap_irac3",
'flux_kr_58': "f_irac3",
'uncf_kr_58': "ferr_irac3",
'stell_58': "swire_stellarity_irac3",
'flux_ap2_80': "f_ap_irac4",
'uncf_ap2_80': "ferr_ap_irac4",
'flux_kr_80': "f_irac4",
'uncf_kr_80': "ferr_irac4",
'stell_80': "swire_stellarity_irac4",
})
catalogue = Table.read("../../dmu0/dmu0_DataFusion-Spitzer/data/DF-SWIRE_ELAIS-S1.fits")[list(imported_columns)]
for column in imported_columns:
catalogue[column].name = imported_columns[column]
epoch = 2004
# Clean table metadata
catalogue.meta = None
# Adding magnitude and band-flag columns
for col in catalogue.colnames:
if col.startswith('f_'):
errcol = "ferr{}".format(col[1:])
magnitude, error = flux_to_mag(
np.array(catalogue[col])/1.e6, np.array(catalogue[errcol])/1.e6)
# Note that some fluxes are 0.
catalogue.add_column(Column(magnitude, name="m{}".format(col[1:])))
catalogue.add_column(Column(error, name="m{}".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:])))
catalogue[:10].show_in_notebook()
We remove duplicated objects from the input catalogues.
SORT_COLS = ['ferr_ap_swire_irac1', 'ferr_ap_swire_irac2', 'ferr_ap_irac3', 'ferr_ap_irac4']
FLAG_NAME = "swire_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] += delta_ra.to(u.deg)
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 = "swire_flag_gaia"
catalogue['flag_gaia'].name = GAIA_FLAG_NAME
print("{} sources flagged.".format(np.sum(catalogue[GAIA_FLAG_NAME] > 0)))
catalogue.write("{}/SWIRE.fits".format(OUT_DIR), overwrite=True)