CDFS SWIRE master catalogue¶

Preparation of COMBO data¶

Classifying Objects by Medium-Band Observations - a spectrophotometric 17-filter survey (COMBO-17). COMBO catalogue: the catalogue comes from dmu0_COMBO-17.

In the catalogue, we keep:

  • The identifier (it's unique in the catalogue);
  • The position;
  • The stellarity;
  • The total magnitude (aperture magnitudes are not provided.

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: 
04829ed (Thu Nov 2 16:57:19 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 import constants as const
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, flux_to_mag
In [3]:
OUT_DIR =  os.environ.get('TMP_DIR', "./data_tmp")
try:
    os.makedirs(OUT_DIR)
except FileExistsError:
    pass

RA_COL = "combo_ra"
DEC_COL = "combo_dec"

I - Column selection¶

In [4]:
imported_columns = OrderedDict({
    'Seq':'combo_id', 
    'ra':'combo_ra', 
    'dec':'combo_dec',  
    #'dl':'combo_dl',
    'stellarity':'combo_stellarity',
    'Rmag':'m_combo_r',    #The catalogue is R selected
    'e_Rmag':'merr_combo_r',  
    #'Ap_Rmag':'m_ap_combo_r',
    #'UjMag':'m_combo_uj',   #These bands are derived absolute magnitudes
    #'e_UjMag':'merr_combo_uj', 
    #'BjMag':'m_combo_bj',   
    #'e_BjMag':'merr_combo_bj',
    #'VjMag':'m_combo_vj',   
    #'e_VjMag':'merr_combo_vj',
    #'usMag':'m_combo_us',   
    #'e_usMag':'merr_combo_us',
    #'gsMag':'m_combo_gs',   
    #'e_gsMag':'merr_combo_gs',
    #'rsMag':'m_combo_rs',   
    #'e_rsMag':'merr_combo_rs',
    #'UbMag':'m_combo_ub',   
    #'e_UbMag':'merr_combo_ub',
    #'BbMag':'m_combo_bb',   
    #'e_BbMag':'merr_combo_bb',
    #'VbMag':'m_combo_vb',   
    #'e_VbMag':'merr_combo_vb',
    #'S280Mag':'m_combo_s280', 
    #'e_S280Mag':'merr_combo_s280',
    ##'S145Mag':'m_combo_s145', 
    #'e_S145Mag':'merr_combo_s145',
    'W420F_E':'f_ap_combo_420', #The following values are given as fluxes
    'e_W420F_E':'ferr_ap_combo_420',
    'W462F_E':'f_ap_combo_462',
    'e_W462F_E':'ferr_ap_combo_462',
    'W485F_D':'f_ap_combo_485',
    'e_W485F_D':'ferr_ap_combo_485',
    'W518F_E':'f_ap_combo_518',
    'e_W518F_E':'ferr_ap_combo_518',
    'W571F_S':'f_ap_combo_571',   #Combined flux from two runs
    'e_W571F_S':'ferr_ap_combo_571',
    'W604F_E':'f_ap_combo_604',
    'e_W604F_E':'ferr_ap_combo_604',
    'W646F_D':'f_ap_combo_646',
    'e_W646F_D':'ferr_ap_combo_646',
    'W696F_E':'f_ap_combo_696',
    'e_W696F_E':'ferr_ap_combo_696',
    'W753F_E':'f_ap_combo_753',
    'e_W753F_E':'ferr_ap_combo_753',
    'W815F_S':'f_ap_combo_815',
    'e_W815F_S':'ferr_ap_combo_815',
    'W856F_D':'f_ap_combo_856',
    'e_W856F_D':'ferr_ap_combo_856',
    'W914F_D':'f_ap_combo_914', #Two runs but no combined - taking first
    'e_W914F_D':'ferr_ap_combo_914',
    'UF_S':'f_ap_combo_u',
    'e_UF_S':'ferr_ap_combo_u',
    'BF_S':'f_ap_combo_b',
    'e_BF_S':'ferr_ap_combo_b',
    'VF_D':'f_ap_combo_v',
    'e_VF_D':'ferr_ap_combo_v',
    'RF_S':'f_ap_combo_r',
    'e_RF_S':'ferr_ap_combo_r',
    'IF_D':'f_ap_combo_i',
    'e_IF_D':'ferr_ap_combo_i'
    })

catalogue = Table.read("../../dmu0/dmu0_COMBO-17/data/table3.fits")[list(imported_columns)]
for column in imported_columns:
    catalogue[column].name = imported_columns[column]

epoch = 2000 #table says 1999 to 2001

# Clean table metadata
catalogue.meta = None
WARNING: UnitsWarning: 'Mpc @H0=100' did not parse as fits unit: Invalid character at col 4 [astropy.units.core]
WARNING: UnitsWarning: 'mag @H0=100' did not parse as fits unit: Invalid character at col 4 [astropy.units.core]
WARNING: UnitsWarning: 'phot/m^2/s/nm' did not parse as fits unit: At col 0, Unit 'phot' not supported by the FITS standard. Did you mean photon? [astropy.units.core]
In [5]:
catalogue[:10].show_in_notebook()
Out[5]:
<Table masked=True length=10>
idxcombo_idcombo_racombo_deccombo_stellaritym_combo_rmerr_combo_rf_ap_combo_420ferr_ap_combo_420f_ap_combo_462ferr_ap_combo_462f_ap_combo_485ferr_ap_combo_485f_ap_combo_518ferr_ap_combo_518f_ap_combo_571ferr_ap_combo_571f_ap_combo_604ferr_ap_combo_604f_ap_combo_646ferr_ap_combo_646f_ap_combo_696ferr_ap_combo_696f_ap_combo_753ferr_ap_combo_753f_ap_combo_815ferr_ap_combo_815f_ap_combo_856ferr_ap_combo_856f_ap_combo_914ferr_ap_combo_914f_ap_combo_uferr_ap_combo_uf_ap_combo_bferr_ap_combo_bf_ap_combo_vferr_ap_combo_vf_ap_combo_rferr_ap_combo_rf_ap_combo_iferr_ap_combo_i
magmagphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nmphot/m^2/s/nm
0153.0465526019-28.0648239803nan25.8980.25970.002643550.002852580.001944190.005078240.006340750.003308230.01289990.005585380.004221650.003588990.005450720.0037928-0.002462950.01111530.00366880.0029749-0.006161140.005189210.00525790.002983740.01389970.00716615-0.01255960.008609210.01257560.002178330.008529390.0009664320.004752160.001655340.004542380.0005652420.007182070.00517013
1252.939626246-28.0646283765nan25.92280.19940.004972590.003325120.005396820.002838570.01482930.006130660.008219420.003868620.01043170.004339210.01148870.005198730.007749730.008125070.006271770.003935490.011430.006593330.008414530.004550590.02225150.009143420.002792120.00746470.009726690.002269720.004166310.001160230.004172190.00214280.006395360.0005845550.01242950.00564517
2353.2521450063-28.0651043505nan26.08090.22140.002937460.00424515-0.004971650.006426350.005597560.005283610.005128620.004365760.001201170.003988010.01163480.00397886-0.01030090.01616890.0007932980.00420210.002179220.00769792-0.006099480.0044404-0.01189840.01358210.02079120.0141984-0.001786390.00348119-1.93626e-050.001978340.003224320.00175771-0.0003300440.00080327-0.01437550.0109746
3453.3679577582-28.0651779258nan24.87360.15630.006392140.002596260.005631830.003582350.005637810.004416380.006852280.004843820.002698560.003692910.01164110.003986950.03109490.01303680.01026680.002992340.01140950.005070120.01151760.003473680.02398810.008725530.004260080.006738410.005680310.001896860.004119450.001192820.006712270.001764320.01159150.0004826170.00702930.00413979
4553.3210626453-28.0651334757nan25.78420.26980.002528490.002650290.0042570.003839940.002441140.004930290.007873710.003520790.004611650.003208730.003965780.00512525-0.01621740.006841740.003755870.003334580.01519170.005242810.007918890.003048350.01941580.007473470.0006095870.0062265-0.0001309330.002107490.003521780.001069310.002080020.001398660.003139520.00058712-8.12998e-050.00389229
5653.2920972875-28.0651280661nan24.9950.09720.01994860.003718040.01301560.00381310.01822010.004330240.01758720.003422120.01512890.003099240.01777750.004365620.01918040.005748830.02652960.003778870.02663210.005704560.02370830.00291960.02792420.006248070.04307270.006960830.02128550.002730960.01569040.001246530.01725050.001404050.01734930.0004557140.02764860.00540542
6753.2299678259-28.0650300589nan25.87150.28820.001204510.003897630.004413250.002797630.004582690.005546160.009875730.003962220.006781490.003316070.004781330.005216840.01554470.0154450.005833510.002925560.01635520.00603550.006013050.004282940.00746580.007704330.01908660.00732659-0.0008489180.002612260.003823570.001291820.005655410.002581350.003475050.0006231450.0018790.00664726
7853.1829388801-28.06501704nan25.73160.18310.006227680.00336940.01384640.002759920.01815490.003410120.01475210.005699130.01963930.00326260.01742620.003792640.02569570.006597950.01432560.002854820.01058360.00619090.01759440.003005610.01474220.006558470.02460170.006682470.01071650.002264240.01285760.001210770.0163540.001460290.01581360.0004481950.01675430.00431651
8952.9391529645-28.0645890368nan25.01340.18070.006106480.00308350.005264750.003310160.002637310.004690660.0007574690.004682930.0102160.002923310.009667670.004752370.00304020.009100710.01059150.003694150.01547050.005732430.01617210.00339030.01306510.007177290.01173770.007377460.008057590.002709480.004045440.001106020.003918710.001814810.007600180.0005253660.01089190.00515469
91052.8411456281-28.064384826nan25.76480.15690.01162350.002631590.006005890.002787120.0151490.004807780.01114350.003543910.009884890.00263180.01311950.003263110.02089270.007653940.01482790.003711660.01367690.005088270.01899480.00317760.01335370.006483030.009263920.01031830.007337050.001800920.0133370.0009769340.01205180.001406540.01074630.0004430480.01485380.00425644

Unit conversion¶

Using mid wavelength¶

The flux is presented in $\textrm{photons} .\textrm{s}^{-1} . \textrm{m}^{-2} .\textrm{nm}^{-1}$. We wish to convert these to micro Jansky; $10^{-32} \textrm{ W} . \textrm{m}^{-2} . \textrm{Hz}^{-1} $.

To convert $\textrm{photons} . \textrm{s}^{-1} $ to $\textrm{W}$ we must multiply by the average photon energy $h c / \lambda$. We presume that the COMBO mid point wavelength was used.

To convert $\textrm{nm}^{-1}$ to $\textrm{Hz}^{-1}$ we must differenciate:

$c = \nu \lambda $

$\nu = c / \lambda$

$\frac{d \nu}{d \lambda} = - c /\lambda^{2}$

$d \lambda = - (\lambda^{2} / c )\times d \nu$

The net result of this is to multiply by $\lambda^2 / c$.

Combining these two unit conversions leads to overall multiplying by $ h \lambda$:

$(\lambda^2 / c ) \times (h c / \lambda) = h \lambda$

In [6]:
#Example conversion from photon s^-1 m^-2 nm^-1 to Jy
flux_lambda = 0.0064185 * (u.m **-2) * (u.s ** -1) *( u.nm ** -1)

wavelength = 420 * u.nm
flux_nu = flux_lambda * const.h *  wavelength
print('flux_lambda:', flux_lambda)
#print('f_lambda:', flux_lambda.decompose())
print('flux_nu:', flux_nu)
print('flux_nu in Jy:',flux_nu.to(u.Jy))
flux_lambda: 0.0064185 1 / (m2 nm s)
flux_nu: 1.78623595647189e-33 J / m2
flux_nu in Jy: 1.7862359564718896e-07 Jy

Using Vega flux¶

The paper provides fluxes of Vega in each band allowing conversion to Vega mag. It then provides the difference between Vega mag and AB mag per band to convert to AB. We can therefore calculate the AB magnitude and convert that back to flux to get the flux in Jy.

In [7]:
#Set wavelengths for unit conversion.
#All from http://cds.aanda.org/component/article?access=bibcode&bibcode=2004A%252526A...421..913W
#Wavelengths in the table column headings are marginally different to those in the paper.
#   Band name   \lambda    Vega AB Fphot (Vega 10^8 photons s^-1 m^-2 nm^-1)
wavelengths = {
    'f_ap_combo_420':   [418, -0.19, 1.571], 
    'ferr_ap_combo_420':[418, -0.19, 1.571],
    'f_ap_combo_462':   [462, -0.18, 1.412],
    'ferr_ap_combo_462':[462, -0.18, 1.412],
    'f_ap_combo_485':   [486, -0.06, 1.207], 
    'ferr_ap_combo_485':[486, -0.06, 1.207],
    'f_ap_combo_518':   [519, -0.06, 1.125],
    'ferr_ap_combo_518':[519, -0.06, 1.125],
    'f_ap_combo_571':   [572,  0.04, 0.932],   
    'ferr_ap_combo_571':[572,  0.04, 0.932],
    'f_ap_combo_604':   [605,  0.10, 0.832],
    'ferr_ap_combo_604':[605,  0.10, 0.832],
    'f_ap_combo_646':   [645,  0.22, 0.703], 
    'ferr_ap_combo_646':[645,  0.22, 0.703], 
    'f_ap_combo_696':   [696,  0.27, 0.621],
    'ferr_ap_combo_696':[696,  0.27, 0.621],
    'f_ap_combo_753':   [753,  0.36, 0.525],
    'ferr_ap_combo_753':[753,  0.36, 0.525],
    'f_ap_combo_815':   [816,  0.45, 0.442], 
    'ferr_ap_combo_815':[816,  0.45, 0.442], 
    'f_ap_combo_856':   [857,  0.56, 0.386],  
    'ferr_ap_combo_856':[857,  0.56, 0.386],
    'f_ap_combo_914':   [914,  0.50, 0.380],
    'ferr_ap_combo_914':[914,  0.50, 0.380],
    'f_ap_combo_u':     [365,  0.77, 0.737],
    'ferr_ap_combo_u':  [365,  0.77, 0.737],
    'f_ap_combo_b':     [458, -0.13, 1.371],
    'ferr_ap_combo_b':  [458, -0.13, 1.371],
    'f_ap_combo_v':     [538, -0.02, 1.055],
    'ferr_ap_combo_v':  [538, -0.02, 1.055],
    'f_ap_combo_r':     [648,  0.19, 0.725],
    'ferr_ap_combo_r':  [648,  0.19, 0.725],
    'f_ap_combo_i':     [857,  0.49, 0.412],
    'ferr_ap_combo_i':  [857,  0.49, 0.412]
}
In [8]:
#Example conversion from photon s^-1 m^-2 nm^-1 to Jy
flux_lambda = 0.0064185 #* (u.m **-2) * (u.s ** -1) *( u.nm ** -1)

mag_vega = -2.5 *np.log10(flux_lambda/(wavelengths['f_ap_combo_420'][2]*1.e8))
print(mag_vega)
mag_AB = mag_vega + wavelengths['f_ap_combo_420'][1]
print(mag_AB)
flux_converted = mag_to_flux(mag_AB)
print(flux_converted)
#This is different to the value calculated using mid point wavelength as we expect 
#because it should take account of the filter response better.
25.9718565988
25.7818565988
(1.7670846750466056e-07, None)
In [9]:
#Replace 0.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] == 0.0)] = np.nan

# Add magnitude, fix flux units and add band-flag columns
nancol = np.zeros(len(catalogue))
nancol.fill(np.nan)
for col in catalogue.colnames:
    if col.startswith('f_'):
         
        errcol = "ferr{}".format(col[1:])
        
        #Replace mask with nan
        catalogue[col].fill_value = np.nan
        catalogue[errcol].fill_value = np.nan
        
        #Calculate magnitudes using Vega fluxes from wavelengths (values from paper)
        magnitude = -2.5*np.log10(catalogue[col].filled()/(wavelengths[col][2]*1.e8)) + wavelengths[col][1]
        magnitude_error = 2.5/np.log(10)*(catalogue[errcol].filled()/catalogue[col].filled() )

        catalogue.add_column(Column(nancol, 
                                    name="m{}".format(col[1:])))
        catalogue.add_column(Column(nancol, 
                                    name="m{}".format(errcol[1:])))
        # Add the AB magnitudes
        catalogue["m{}".format(col[1:])] = magnitude
        catalogue["m{}".format(errcol[1:])] = magnitude_error
    
        flux_new, flux_new_error = mag_to_flux(magnitude, magnitude_error)
        catalogue[col] = flux_new * 1.e6 # uJy
        catalogue[errcol] = flux_new_error * 1.e6 # uJy 
        
        
        #We add NAN filled total columns because no total fluxes are present
        if not col == 'f_ap_combo_r':
            catalogue.add_column(Column(nancol, 
                                    name="m{}".format(col[4:])))
            catalogue.add_column(Column(nancol, 
                                    name="merr{}".format(col[4:])))
            catalogue.add_column(Column(nancol, 
                                    name="f{}".format(col[4:])))
            catalogue.add_column(Column(nancol, 
                                    name="ferr{}".format(col[4:])))
        
        # 
        
        # Band-flag column
        catalogue.add_column(Column(np.zeros(len(catalogue), dtype=bool), name="flag{}".format(col[4:])))
        
#Add total fluxes for R band
f_combo_r, ferr_combo_r = mag_to_flux(catalogue['m_combo_r'],catalogue['merr_combo_r'])
catalogue['f_combo_r'] = f_combo_r
catalogue['ferr_combo_r'] = ferr_combo_r
/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:20: RuntimeWarning: invalid value encountered in log10
In [10]:
catalogue[:10].show_in_notebook()
Out[10]:
<Table masked=True length=10>
idxcombo_idcombo_racombo_deccombo_stellaritym_combo_rmerr_combo_rf_ap_combo_420ferr_ap_combo_420f_ap_combo_462ferr_ap_combo_462f_ap_combo_485ferr_ap_combo_485f_ap_combo_518ferr_ap_combo_518f_ap_combo_571ferr_ap_combo_571f_ap_combo_604ferr_ap_combo_604f_ap_combo_646ferr_ap_combo_646f_ap_combo_696ferr_ap_combo_696f_ap_combo_753ferr_ap_combo_753f_ap_combo_815ferr_ap_combo_815f_ap_combo_856ferr_ap_combo_856f_ap_combo_914ferr_ap_combo_914f_ap_combo_uferr_ap_combo_uf_ap_combo_bferr_ap_combo_bf_ap_combo_vferr_ap_combo_vf_ap_combo_rferr_ap_combo_rf_ap_combo_iferr_ap_combo_im_ap_combo_420merr_ap_combo_420m_combo_420merr_combo_420f_combo_420ferr_combo_420flag_combo_420m_ap_combo_462merr_ap_combo_462m_combo_462merr_combo_462f_combo_462ferr_combo_462flag_combo_462m_ap_combo_485merr_ap_combo_485m_combo_485merr_combo_485f_combo_485ferr_combo_485flag_combo_485m_ap_combo_518merr_ap_combo_518m_combo_518merr_combo_518f_combo_518ferr_combo_518flag_combo_518m_ap_combo_571merr_ap_combo_571m_combo_571merr_combo_571f_combo_571ferr_combo_571flag_combo_571m_ap_combo_604merr_ap_combo_604m_combo_604merr_combo_604f_combo_604ferr_combo_604flag_combo_604m_ap_combo_646merr_ap_combo_646m_combo_646merr_combo_646f_combo_646ferr_combo_646flag_combo_646m_ap_combo_696merr_ap_combo_696m_combo_696merr_combo_696f_combo_696ferr_combo_696flag_combo_696m_ap_combo_753merr_ap_combo_753m_combo_753merr_combo_753f_combo_753ferr_combo_753flag_combo_753m_ap_combo_815merr_ap_combo_815m_combo_815merr_combo_815f_combo_815ferr_combo_815flag_combo_815m_ap_combo_856merr_ap_combo_856m_combo_856merr_combo_856f_combo_856ferr_combo_856flag_combo_856m_ap_combo_914merr_ap_combo_914m_combo_914merr_combo_914f_combo_914ferr_combo_914flag_combo_914m_ap_combo_umerr_ap_combo_um_combo_umerr_combo_uf_combo_uferr_combo_uflag_combo_um_ap_combo_bmerr_ap_combo_bm_combo_bmerr_combo_bf_combo_bferr_combo_bflag_combo_bm_ap_combo_vmerr_ap_combo_vm_combo_vmerr_combo_vf_combo_vferr_combo_vflag_combo_vm_ap_combo_rmerr_ap_combo_rflag_combo_rm_ap_combo_imerr_ap_combo_im_combo_imerr_combo_if_combo_iferr_combo_iflag_combo_if_combo_rferr_combo_r
0153.0465526019-28.0648239803nan25.8980.25970.072780.07853470.05900710.1541270.2015730.1051690.4399810.1905020.1585130.1347580.2169350.150951nannan0.1672750.135638nannan0.2853580.1619340.7805810.402438nannan0.3048320.05280260.2546130.02884910.1665860.05802780.1909610.02376270.4030440.29013826.7451.17159nannannannanFalse26.97272.83595nannannannanFalse25.63890.566474nannannannanFalse24.79140.4701nannannannanFalse25.89980.923026nannannannanFalse25.55920.755493nannannannanFalsenan-4.89994nannannannanFalse25.84140.880385nannannannanFalsenan-0.91446nannannannanFalse25.26150.61613nannannannanFalse24.1690.559764nannannannanFalsenan-0.744241nannannannanFalse25.18980.18807nannannannanFalse25.38530.12302nannannannanFalse25.84590.3782nannannannanFalse25.69760.135106False24.88660.781585nannannannanFalse1.58786e-073.79803e-08
1252.939626246-28.0646283765nan25.92280.19940.1369010.09154430.1637960.0861520.4714260.1948950.2803420.1319480.3916880.1629270.4572440.2069060.3268370.3426660.2859550.1794350.5673960.3272990.4566760.246971.24960.5134780.1683250.4500170.2357750.05501790.1243690.03463430.1462550.07511540.268860.02457460.697520.31679726.0590.726022nannannannanFalse25.86420.571065nannannannanFalse24.71650.44886nannannannanFalse25.28080.511022nannannannanFalse24.91760.451625nannannannanFalse24.74960.491304nannannannanFalse25.11421.13832nannannannanFalse25.25930.681291nannannannanFalse24.51530.6263nannannannanFalse24.7510.587167nannannannanFalse23.65810.446143nannannannanFalse25.83462.90271nannannannanFalse25.46880.253356nannannannanFalse26.16320.302355nannannannanFalse25.98720.557625nannannannanFalse25.32620.0992395False24.29110.493116nannannannanFalse1.55193e-072.85019e-08
2353.2521450063-28.0651043505nan26.08090.22140.08087170.116874nannan0.1779470.1679670.1749230.1489040.04510120.1497410.463060.158356nannan0.03616970.1915910.1081780.382132nannannannan1.253420.855963nannannannan0.1130280.061616nannannannan26.63051.56908nannannannanFalsenan-1.40342nannannannanFalse25.77431.02484nannannannanFalse25.79290.924238nannannannanFalse27.26453.60476nannannannanFalse24.73590.371298nannannannanFalsenan-1.70423nannannannanFalse27.50415.75114nannannannanFalse26.31463.83528nannannannanFalsenan-0.790412nannannannanFalsenan-1.23937nannannannanFalse23.65480.741452nannannannanFalsenan-2.1158nannannannanFalsenan-110.933nannannannanFalse26.2670.591878nannannannanFalsenan-2.64249Falsenan-0.828878nannannannanFalse1.34162e-072.73579e-08
3453.3679577582-28.0651779258nan24.87360.15630.1759830.07147790.1709290.1087260.1792270.1403970.2337120.1652090.1013250.1386610.4633090.1586781.31140.5498160.4681040.1364330.566380.2516860.6250860.1885241.347130.4900090.2568230.4062310.1376910.04597990.122970.0356070.2352980.06184790.4873070.02028920.394470.23231725.78630.440988nannannannanFalse25.8180.690625nannannannanFalse25.76650.850512nannannannanFalse25.47830.767498nannannannanFalse26.38571.4858nannannannanFalse24.73530.371852nannannannanFalse23.60570.455206nannannannanFalse24.72410.316447nannannannanFalse24.51720.482475nannannannanFalse24.41020.327455nannannannanFalse23.57650.39493nannannannanFalse25.37591.71737nannannannanFalse26.05270.362566nannannannanFalse26.17550.314383nannannannanFalse25.4710.285385nannannannanFalse24.68050.045205False24.910.639426nannannannanFalse4.07913e-075.87222e-08
4553.3210626453-28.0651334757nan25.78420.26980.0696120.07296540.1292020.1165440.07760420.1567350.2685510.1200850.1731570.1204810.1578350.203981nannan0.1712450.1520370.7541310.2602580.4297750.165441.090360.4196960.03674960.375371nannan0.1051290.03192020.07291460.04902980.1319850.0246824nannan26.79331.13804nannannannanFalse26.12180.979365nannannannanFalse26.67532.19283nannannannanFalse25.32740.485495nannannannanFalse25.80390.755442nannannannanFalse25.90451.40317nannannannanFalsenan-0.458048nannannannanFalse25.8160.96395nannannannanFalse24.20640.374698nannannannanFalse24.81690.41795nannannannanFalse23.80610.417918nannannannanFalse27.486911.09nannannannanFalsenan-17.4759nannannannanFalse26.34570.32966nannannannanFalse26.7430.730079nannannannanFalse26.09870.203043Falsenan-51.9805nannannannanFalse1.76326e-074.38161e-08
5653.2920972875-28.0651280661nan24.9950.09720.5492070.1023620.3950290.1157290.5792170.1376590.5998530.1167190.5680550.1163690.7075330.1737490.8089150.2424511.209590.1722941.322050.283181.28670.1584531.568170.350882.596680.419640.515960.06619840.4683760.03721020.6047120.04921880.7293640.01915821.551590.30334124.55070.20236nannannannanFalse24.90840.318082nannannannanFalse24.49290.25804nannannannanFalse24.45490.211262nannannannanFalse24.5140.222419nannannannanFalse24.27560.266624nannannannanFalse24.13020.325421nannannannanFalse23.69340.154652nannannannanFalse23.59690.232563nannannannanFalse23.62630.133705nannannannanFalse23.41150.242935nannannannanFalse22.8640.175462nannannannanFalse24.61850.139302nannannannanFalse24.72350.0862566nannannannanFalse24.44610.0883704nannannannanFalse24.24260.028519False23.42310.212266nannannannanFalse3.64747e-073.26538e-08
6753.2299678259-28.0650300589nan25.87150.28820.03316140.1073060.1339440.08490940.1456840.1763130.3368340.135140.254630.1245110.1902940.2076270.6555810.6513760.2659730.1333880.8118910.2996080.326340.2324440.4192660.4326621.150650.44169nannan0.1141380.03856230.1982490.09048850.1460910.02619690.1054450.37303127.59843.5133nannannannanFalse26.08270.688266nannannannanFalse25.99151.314nannannannanFalse25.08150.435606nannannannanFalse25.38520.530911nannannannanFalse25.70141.18463nannannannanFalse24.35841.07877nannannannanFalse25.33790.544508nannannannanFalse24.12630.400664nannannannanFalse25.11580.773343nannannannanFalse24.84381.12042nannannannanFalse23.74760.416771nannannannanFalsenan-3.34099nannannannanFalse26.25640.366822nannannannanFalse25.6570.495572nannannannanFalse25.98840.194694False26.34243.84097nannannannanFalse1.62707e-074.31892e-08
7853.1829388801-28.06501704nan25.73160.18310.1714550.09276360.4202450.08376480.5771470.1084080.5031550.1943820.7374120.1225030.6935520.1509451.083690.2782620.6531610.1301630.525380.3073220.9548880.1631210.8278970.3683121.483140.4028590.2597660.0548850.3838160.03614290.5732850.05119020.6648030.01884210.9402180.24223425.81460.587423nannannannanFalse24.84120.216413nannannannanFalse24.49680.203939nannannannanFalse24.64570.419448nannannannanFalse24.23070.180369nannannannanFalse24.29730.2363nannannannanFalse23.81270.278787nannannannanFalse24.36240.216367nannannannanFalse24.59880.635104nannannannanFalse23.95010.185474nannannannanFalse24.10510.483018nannannannanFalse23.4720.294915nannannannanFalse25.36350.229401nannannannanFalse24.93970.102241nannannannanFalse24.50410.0969485nannannannanFalse24.34330.0307723False23.96690.279725nannannannanFalse1.85084e-073.12129e-08
8952.9391529645-28.0645890368nan25.01340.18070.1681180.08489220.1597870.1004650.08384040.1491170.02583520.1597220.383590.1097640.3847680.1891410.1282180.3838130.4829070.1684310.7679720.2845640.8776980.1839990.7337120.4030630.7076160.4447580.1953160.06567780.1207610.03301590.137370.0636180.319510.02208630.6112320.28927225.8360.548248nannannannanFalse25.89110.682647nannannannanFalse26.59141.93107nannannannanFalse27.86956.7124nannannannanFalse24.94030.310682nannannannanFalse24.9370.533718nannannannanFalse26.13013.2501nannannannanFalse24.69030.37869nannannannanFalse24.18660.402308nannannannanFalse24.04160.227612nannannannanFalse24.23620.596447nannannannanFalse24.27550.682417nannannannanFalse25.67320.365095nannannannanFalse26.19520.296838nannannannanFalse26.05530.502821nannannannanFalse25.13880.075052False24.43450.513835nannannannanFalse3.58609e-075.96836e-08
91052.8411456281-28.064384826nan25.76480.15690.3200070.07245080.1822810.08459030.481590.152840.3800750.1208730.3711550.0988180.522150.129870.8811290.3227970.6760620.169230.6789320.2525861.030890.1724550.7499180.3640750.5584850.6220490.177850.04365420.3981260.02916270.4224750.04930590.4517740.01862570.8335650.23886325.13710.245815nannannannanFalse25.74810.503851nannannannanFalse24.69330.344575nannannannanFalse24.95030.345291nannannannanFalse24.97610.289072nannannannanFalse24.60550.270046nannannannanFalse24.03740.397754nannannannanFalse24.3250.271778nannannannanFalse24.32040.403932nannannannanFalse23.8670.18163nannannannanFalse24.21250.527111nannannannanFalse24.53251.20931nannannannanFalse25.77490.266499nannannannanFalse24.89990.0795301nannannannanFalse24.83550.126713nannannannanFalse24.76270.0447627False24.09770.311125nannannannanFalse1.79508e-072.59407e-08

II - Removal of duplicated sources¶

We remove duplicated objects from the input catalogues.

In [11]:
SORT_COLS = ['merr_combo_u',  
     'merr_combo_b', 
     'merr_combo_v',
     'merr_combo_r',
     'merr_combo_i']
FLAG_NAME = 'combo_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 63501 sources.
The cleaned catalogue has 63501 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 [12]:
gaia = Table.read("../../dmu0/dmu0_GAIA/data/GAIA_CDFS-SWIRE.fits")
gaia_coords = SkyCoord(gaia['ra'], gaia['dec'])
In [13]:
nb_astcor_diag_plot(catalogue[RA_COL], catalogue[DEC_COL], 
                    gaia_coords.ra, gaia_coords.dec)
In [14]:
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.18399366377366277 arcsec
Dec correction: -0.283546868710971 arcsec
In [15]:
catalogue[RA_COL] +=  delta_ra.to(u.deg)
catalogue[DEC_COL] += delta_dec.to(u.deg)
In [16]:
nb_astcor_diag_plot(catalogue[RA_COL], catalogue[DEC_COL], 
                    gaia_coords.ra, gaia_coords.dec)

IV - Flagging Gaia objects¶

In [17]:
catalogue.add_column(
    gaia_flag_column(SkyCoord(catalogue[RA_COL], catalogue[DEC_COL]), epoch, gaia)
)
In [18]:
GAIA_FLAG_NAME = "combo_flag_gaia"

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

V - Flagging objects near bright stars¶

VI - Saving to disk¶

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