AKARI-NEP master catalogue

Preparation of AKARI-NEP-OptNIR data

This product contains the 8-band (u*, g', r', i', z', Y, J, Ks) optical to near-infrared catalogue from Oi et al., 2014.

  • The identifier (it's unique in the catalogue);
  • The position;
  • The stellarity;
  • The total magnitude for each band (u*, g', r', i', z', Y, J, Ks).
  • There are no aperture mags so we put empty columns in the masterlist.

We don't know when the maps have been observed. We will use the year of the reference paper.

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: 
33f5ec7 (Wed Dec 6 16:56:17 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]:
OUT_DIR =  os.environ.get('TMP_DIR', "./data_tmp")
try:
    os.makedirs(OUT_DIR)
except FileExistsError:
    pass

RA_COL = "akari_ra"
DEC_COL = "akari_dec"

I - Column selection

In [4]:
imported_columns = OrderedDict({
        'OBJID': "akari_id",
        'RAJ2000': "akari_ra",
        'DEJ2000': "akari_dec",
        'stl':  "akari_stellarity",
        'umag': "m_megacam_u",
        'e_umag': "merr_megacam_u",
        'gmag': "m_megacam_g",
        'e_gmag': "merr_megacam_g",
        'rmag': "m_megacam_r",
        'e_rmag': "merr_megacam_r",
        'imag': "m_megacam_i",
        'e_imag': "merr_megacam_i",
        'zmag': "m_megacam_z",
        'e_zmag': "merr_megacam_z",
        'Ymag': "m_wircam_y",
        'e_Ymag': "merr_wircam_y",
        'Jmag': "m_wircam_j",
        'e_Jmag': "merr_wircam_j",
        'Kmag': "m_wircam_k",
        'e_Kmag': "merr_wircam_k"
    })


catalogue = Table.read("../../dmu0/dmu0_AKARI-NEP-OptNIR/data/AKARI-NEP_OptNIR.fits")[list(imported_columns)]
for column in imported_columns:
    catalogue[column].name = imported_columns[column]

epoch = 2014 #This is the paper year. The observations are multi-epoch

# Clean table metadata
catalogue.meta = None
In [5]:
# Adding flux and band-flag columns
for col in catalogue.colnames:
    if col.startswith('m_'):
        
        errcol = "merr{}".format(col[1:])
        
        # Bad values = -99
        catalogue[col][catalogue[col] <= -90.] = np.nan
        catalogue[errcol][catalogue[errcol] <= -90.] = np.nan  
        

        flux, error = mag_to_flux(np.array(catalogue[col]), np.array(catalogue[errcol]))
        
        # Fluxes are added in µJy
        catalogue.add_column(Column(flux * 1.e6, name="f{}".format(col[1:])))
        catalogue.add_column(Column(error * 1.e6, name="f{}".format(errcol[1:])))
        
        # We add nan filled aperture photometry for consistency
        #catalogue.add_column(Column(np.full(len(catalogue), np.nan), name="m_ap{}".format(col[1:])))
        #catalogue.add_column(Column(np.full(len(catalogue), np.nan), name="merr_ap{}".format(col[1:])))
        #catalogue.add_column(Column(np.full(len(catalogue), np.nan), name="f_ap{}".format(col[1:])))
        #catalogue.add_column(Column(np.full(len(catalogue), np.nan), name="ferr_ap{}".format(col[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.
/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/ipykernel/__main__.py:8: RuntimeWarning: invalid value encountered in less_equal
/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)
/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/ipykernel/__main__.py:9: RuntimeWarning: invalid value encountered in less_equal
In [6]:
catalogue[:10].show_in_notebook()
Out[6]:
<Table masked=True length=10>
idxakari_idakari_raakari_decakari_stellaritym_megacam_umerr_megacam_um_megacam_gmerr_megacam_gm_megacam_rmerr_megacam_rm_megacam_imerr_megacam_im_megacam_zmerr_megacam_zm_wircam_ymerr_wircam_ym_wircam_jmerr_wircam_jm_wircam_kmerr_wircam_kf_megacam_uferr_megacam_uflag_megacam_uf_megacam_gferr_megacam_gflag_megacam_gf_megacam_rferr_megacam_rflag_megacam_rf_megacam_iferr_megacam_iflag_megacam_if_megacam_zferr_megacam_zflag_megacam_zf_wircam_yferr_wircam_yflag_wircam_yf_wircam_jferr_wircam_jflag_wircam_jf_wircam_kferr_wircam_kflag_wircam_k
degdegmagmagmagmagmagmagmagmagmagmagmagmagmagmagmagmag
01269.22966.03920.65nannannannan23.7880.099nannan22.9730.152nannannannannannannannanFalsenannanFalse1.108660.101091FalsenannanFalse2.348550.328791FalsenannanFalsenannanFalsenannanFalse
12269.270266.03920.98nannannannan22.6880.052nannan20.4450.024nannannannannannannannanFalsenannanFalse3.053510.146244FalsenannanFalse24.09910.532705FalsenannanFalsenannanFalsenannanFalse
23269.497466.03920.61nannannannan23.4940.109nannan23.3880.172nannannannannannannannanFalsenannanFalse1.453450.145916FalsenannanFalse1.602510.253866FalsenannanFalsenannanFalsenannanFalse
34269.248266.03980.93nannan24.0640.11123.0960.07822.4340.09122.4440.129nannannannannannannannanFalse0.8598050.087902False2.097010.15065False3.858340.323383False3.822960.454219FalsenannanFalsenannanFalsenannanFalse
45269.21566.03980.74nannan23.6490.07523.0420.06723.110.13222.6890.143nannannannannannannannanFalse1.260090.0870436False2.203940.136004False2.070140.25168False3.050710.401802FalsenannanFalsenannanFalsenannanFalse
56269.650166.03880.95nannannannan23.0880.064nannan21.8750.086nannannannannannannannanFalsenannanFalse2.112520.124525FalsenannanFalse6.456540.511416FalsenannanFalsenannanFalsenannanFalse
67268.635466.03990.9nannannannan24.560.17423.5380.15922.7960.159nannannannannannannannanFalsenannanFalse0.5445030.087262False1.395720.204396False2.764390.40483FalsenannanFalsenannanFalsenannanFalse
78268.593566.03960.59nannan22.9330.03822.2770.03421.9180.05922.1140.071nannannannannannannannanFalse2.436690.0852823False4.458610.139622False6.205830.337231False5.180840.338793FalsenannanFalsenannanFalsenannanFalse
89269.486866.03950.75nannan23.8470.08522.7760.07422.6390.10922.570.131nannannannannannannannanFalse1.050030.0822043False2.815790.191914False3.194480.320702False3.404080.410721FalsenannanFalsenannanFalsenannanFalse
910269.481966.03940.97nannan24.7520.13123.290.06522.6140.06221.960.066nannannannannannannannanFalse0.4562470.0550487False1.753880.105False3.268880.186667False5.970350.362927FalsenannanFalsenannanFalsenannanFalse

II - Removal of duplicated sources

We remove duplicated objects from the input catalogues.

In [7]:
SORT_COLS = ['merr_megacam_u', 'merr_megacam_g', 'merr_megacam_r', 'merr_megacam_i', 'merr_megacam_z',
            'merr_wircam_y', 'merr_wircam_j', 'merr_wircam_k']
FLAG_NAME = 'akari_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 85797 sources.
The cleaned catalogue has 85797 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-NEP.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.07950606818667438 arcsec
Dec correction: -0.038150143166149064 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 = "akari_flag_gaia"

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

V - Saving to disk

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