AKARI-SEP master catalogue¶

Preparation of Spitzer SIMES data¶

The Spitzer catalogues were produced by the datafusion team are available in dmu0_SIMES. Lucia told that the magnitudes are aperture corrected.

In the catalouge, we keep:

  • The internal identifier (this one is only in HeDaM data);
  • The position;
  • The fluxes in aperture 1 (4.8 arcsec);
  • The total flux;
  • The stellarity in each band

Paper descirbing data: http://irsa.ipac.caltech.edu/data/SPITZER/SEP/documentation/baronchelli16.pdf

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, flux_to_mag
In [3]:
OUT_DIR =  os.environ.get('TMP_DIR', "./data_tmp")
try:
    os.makedirs(OUT_DIR)
except FileExistsError:
    pass

RA_COL = "simes_ra"
DEC_COL = "simes_dec"

I - Column selection¶

In [4]:
imported_columns = OrderedDict({
        'ID': "simes_id",
        'ra': "simes_ra",
        'dec': "simes_dec",
        'FLUX_I1': "f_irac_i1",
        'FLUXERR_I1': "ferr_irac_i1",
        'AP1_FLUX_I1': "f_ap_irac_i1",
        'AP1_FLUXERR_I1': "ferr_ap_irac_i1",
        'CLASS_STAR_I1': "simes_stellarity",
        'FLUX_I2': "f_irac_i2",
        'FLUXERR_I2': "ferr_irac_i2",
        'AP1_FLUX_I2': "f_ap_irac_i2",
        'AP1_FLUXERR_I2': "ferr_ap_irac_i2"
    })


catalogue = Table.read("../../dmu0/dmu0_SIMES/data/SEP_catalog7.2_mJy_HELP-coverage.fits")[list(imported_columns)]
for column in imported_columns:
    catalogue[column].name = imported_columns[column]

epoch = 2009

# Clean table metadata
catalogue.meta = None
In [5]:
# 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:])))
/opt/herschelhelp_internal/herschelhelp_internal/utils.py:76: RuntimeWarning: divide by zero encountered in log10
  magnitudes = 2.5 * (23 - np.log10(fluxes)) - 48.6
/opt/herschelhelp_internal/herschelhelp_internal/utils.py:80: RuntimeWarning: invalid value encountered in true_divide
  errors = 2.5 / np.log(10) * errors_on_fluxes / fluxes
/opt/herschelhelp_internal/herschelhelp_internal/utils.py:76: RuntimeWarning: invalid value encountered in log10
  magnitudes = 2.5 * (23 - np.log10(fluxes)) - 48.6
/opt/herschelhelp_internal/herschelhelp_internal/utils.py:80: RuntimeWarning: divide by zero encountered in true_divide
  errors = 2.5 / np.log(10) * errors_on_fluxes / fluxes
In [6]:
catalogue[:10].show_in_notebook()
Out[6]:
<Table masked=True length=10>
idxsimes_idsimes_rasimes_decf_irac_i1ferr_irac_i1f_ap_irac_i1ferr_ap_irac_i1simes_stellarityf_irac_i2ferr_irac_i2f_ap_irac_i2ferr_ap_irac_i2m_irac_i1merr_irac_i1flag_irac_i1m_ap_irac_i1merr_ap_irac_i1m_irac_i2merr_irac_i2flag_irac_i2m_ap_irac_i2merr_ap_irac_i2
0170.7803779831-54.85828375480.4514440.004243670.440280.003777860.9998550.0167460.00178790.01243220.0014299124.76350.0102062False24.79070.0093162528.34020.115919False28.66360.124878
1270.7850447813-54.85449101490.05461550.0056410.03878480.002612710.971210.04145740.002957750.03380410.0015507427.05670.112141False27.42840.073139927.3560.0774609False27.57760.0498073
2370.7786285052-54.84998980520.08058110.002609780.08066260.002591960.9994450.0-99.00.00.026.63440.0351638False26.63330.0348883inf-infFalseinfnan
3470.7833559204-54.8476040650.01807710.002901540.01659140.002763370.9756360.01295440.0015330.01290910.0014686128.25720.17427False28.35030.18083428.6190.128485False28.62280.12352
4570.7620588774-54.854731890.06903040.005032220.04638690.002629650.07682350.05161780.002461770.04831330.0016824626.80240.0791486False27.2340.061549727.1180.0517812False27.18980.0378096
5670.7671466824-54.85232085520.1138550.009055420.05707480.002925530.02307520.09439010.004507150.04493970.001621926.25910.0863535False27.00890.055652626.46270.0518442False27.26840.0391848
6770.7741778283-54.84972659830.03593270.006442540.03433880.004890150.9735690.03833110.003333420.02945440.0027636427.51130.194667False27.56050.15461827.44110.0944199False27.72710.101872
7870.7598959945-54.854609210.07683320.002929160.07658480.002916510.9994460.005624430.001461080.005471580.0014267626.68610.0413921False26.68960.041347229.52480.282046False29.55470.283115
8970.7796735642-54.84784583610.03389510.005825330.0301460.002623790.97790.02688240.002182630.02467750.0014944827.57470.186598False27.70190.09449827.82630.0881529False27.91930.0657527
91070.764994688-54.85053996140.01278810.001923180.01318650.002340660.9894710.01578480.001307390.01711580.0014763128.6330.163282False28.59970.19272228.40440.0899272False28.31650.0936491

II - Removal of duplicated sources¶

We remove duplicated objects from the input catalogues.

In [7]:
SORT_COLS = ['ferr_ap_irac_i1', 'ferr_ap_irac_i2']
FLAG_NAME = "servs_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])))
/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/astropy/table/column.py:1096: MaskedArrayFutureWarning: setting an item on a masked array which has a shared mask will not copy the mask and also change the original mask array in the future.
Check the NumPy 1.11 release notes for more information.
  ma.MaskedArray.__setitem__(self, index, value)
The initial catalogue had 301420 sources.
The cleaned catalogue has 301420 sources (0 removed).
The cleaned catalogue has 0 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_AKARI-SEP.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.1570059799291812 arcsec
Dec correction: -0.025493045217217514 arcsec
In [11]:
catalogue[RA_COL] +=  delta_ra.to(u.deg)
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 = "servs_flag_gaia"

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

V - Saving to disk¶

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