CDFS SWIRE master catalogue¶

Preparation of Fireworks data¶

FIREWORKS photometry of GOODS CDF-S catalogue: the catalogue comes from dmu0_Fireworks.

In the catalogue, we keep:

  • The identifier (it's unique in the catalogue);
  • The position;
  • The stellarity;
  • The total magnitude.
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.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 = "fireworks_ra"
DEC_COL = "fireworks_dec"

I - Column selection¶

In [4]:
imported_columns = OrderedDict({
    'Seq':'fireworks_id', 
    'RAJ2000':'fireworks_ra', 
    'DEJ2000':'fireworks_dec',   
    'FU38':'m_fireworks_fu38', 
    'e_FU38':'merr_fireworks_fu38', 
    'FB435':'m_fireworks_fb435', 
    'e_FB435':'merr_fireworks_fb435', 
    'FB':'m_fireworks_fb', 
    'e_FB':'merr_fireworks_fb',
    'FV':'m_fireworks_fv', 
    'e_FV':'merr_fireworks_fv',
    'FV606':'m_fireworks_fv606', 
    'e_FV606':'merr_fireworks_fv606',
    'FRc':'m_fireworks_frc', 
    'e_FRc':'merr_fireworks_frc',
    'Fi775':'m_fireworks_fi775', 
    'e_Fi775':'merr_fireworks_fi775',
    'FI':'m_fireworks_fi', 
    'e_FI':'merr_fireworks_fi',
    'Fz850':'m_fireworks_fz850', 
    'e_Fz850':'merr_fireworks_fz850',
    'FJ':'m_fireworks_fj', 
    'e_FJ':'merr_fireworks_fj',
    'FH':'m_fireworks_fh', 
    'e_FH':'merr_fireworks_fh',
    'FKs':'m_fireworks_fks', 
    'e_FKs':'merr_fireworks_fks',
    #'F3.6':'m_fireworks_f3.6', 
    #'e_F3.6':'merr_fireworks_F3.6',
    #'F4.5':'m_fireworks_F4.5', 
    #'e_F4.5':'merr_fireworks_F4.5',
    #'F5.8':'m_fireworks_F5.8', 
    #'e_F5.8':'merr_fireworks_F5.8',
    #'F8.0':'m_fireworks_F8.0', 
    #'e_F8.0':'merr_fireworks_F8.0',
    'FKs.t':'m_fireworks_fkst', 
    'e_FKs.t':'merr_fireworks_fkst',
    'F24.t':'m_fireworks_f24t',
    'e_F24.t':'merr_fireworks_f24t'
    })


catalogue = Table.read("../../dmu0/dmu0_Fireworks/data/fireworks.fits")[list(imported_columns)]
for column in imported_columns:
    catalogue[column].name = imported_columns[column]

epoch = 2008

# Clean table metadata
catalogue.meta = None
In [5]:
# Add flux and band-flag columns
for col in catalogue.colnames:
    if col.startswith('m_'):
        
        errcol = "merr{}".format(col[1:])
        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:])))
        
        # Band-flag column
        catalogue.add_column(Column(np.zeros(len(catalogue), dtype=bool), name="flag{}".format(col[1:])))
In [6]:
catalogue[:10].show_in_notebook()
Out[6]:
<Table masked=True length=10>
idxfireworks_idfireworks_rafireworks_decm_fireworks_fu38merr_fireworks_fu38m_fireworks_fb435merr_fireworks_fb435m_fireworks_fbmerr_fireworks_fbm_fireworks_fvmerr_fireworks_fvm_fireworks_fv606merr_fireworks_fv606m_fireworks_frcmerr_fireworks_frcm_fireworks_fi775merr_fireworks_fi775m_fireworks_fimerr_fireworks_fim_fireworks_fz850merr_fireworks_fz850m_fireworks_fjmerr_fireworks_fjm_fireworks_fhmerr_fireworks_fhm_fireworks_fksmerr_fireworks_fksm_fireworks_fkstmerr_fireworks_fkstm_fireworks_f24tmerr_fireworks_f24tf_fireworks_fu38ferr_fireworks_fu38flag_fireworks_fu38f_fireworks_fb435ferr_fireworks_fb435flag_fireworks_fb435f_fireworks_fbferr_fireworks_fbflag_fireworks_fbf_fireworks_fvferr_fireworks_fvflag_fireworks_fvf_fireworks_fv606ferr_fireworks_fv606flag_fireworks_fv606f_fireworks_frcferr_fireworks_frcflag_fireworks_frcf_fireworks_fi775ferr_fireworks_fi775flag_fireworks_fi775f_fireworks_fiferr_fireworks_fiflag_fireworks_fif_fireworks_fz850ferr_fireworks_fz850flag_fireworks_fz850f_fireworks_fjferr_fireworks_fjflag_fireworks_fjf_fireworks_fhferr_fireworks_fhflag_fireworks_fhf_fireworks_fksferr_fireworks_fksflag_fireworks_fksf_fireworks_fkstferr_fireworks_fkstflag_fireworks_fkstf_fireworks_f24tferr_fireworks_f24tflag_fireworks_f24t
degdeguJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJyuJy
0153.2033631-27.93727140.3790.037490.07nan0.5360.013130.7210.017571.1790.046911.4450.015822.6360.069752.3370.099363.0670.096194.0730.2020.16314.316.3780.340847.4210.3966-20.4987.010842560943517.1688428268.3376False3404081897.01nanFalse2216154325.9626800346.3202False1868959971.6530244571.8933False1225744632.0552959163.043False959400631.51613979194.8763False320331760.08520578792.6828False421890746.56838608885.2847False215377335.56619081196.535False85270733.734415864524.1255False3124640085.8141182747182.9False10204694.31943203511.12599False3904810.837491426357.49951False5.74380913496e+173.70890522572e+18False
1253.2103094-27.9374250.2950.040150.148nan1.0080.013861.6550.018612.0270.040632.4180.016563.0040.058693.3980.105363.5120.086943.9460.276-0.17114.315.3230.539085.9760.60521-0.3630.02766941645.41102320164.49False3168108159.33nanFalse1434828518.2318316349.0133False790678628.013552582.2963False561306407.67521004991.1239False391561514.845972222.95556False228244331.21712337858.6257False158781536.42115408183.5016False142955214.00411447095.7596False95851739.768624366029.299False4250108331.7656016415369.6False26964973.635413388406.8006False14777467.06178237241.05471False5072242398.930.0False
2353.2042533-27.93710530.2390.041780.109nan2.1890.014595.4470.019628.7970.0446713.0270.0176330.4940.0637642.0970.1106447.7280.0949966.0750.2490.16314.3158.3540.404964.6010.44825-11.146.918292913399222.57112109938.847False3283976192.5nanFalse483503920.5926497270.85688False24054703.0499434685.029172False1099512.0668845236.7746532False22346.0105773362.850722626False0.002303562500120.00013527700777False5.2625956208e-085.36275364986e-09False2.9430659897e-102.57485968632e-11False1.34896288259e-173.09367741716e-18False3124640085.8141182747182.9False1.65348401217e-146.16628305839e-15False5.24324317246e-172.16469133271e-17False1.03752841582e+146.61111090559e+14False
3453.1488222-27.93760470.3490.043050.4870.023080.460.014670.5720.019630.7410.025940.8450.017591.5150.036931.9830.111742.5690.053053.5340.2480.05514.316.5920.3917110.2791.553845.75.276532632691674.22104387581.512False2318462095.4149284628.1884False2376840286.6232114842.3088False2143877665.9738761089.8473False1834847607.7643837487.1692False1667247212.5527011053.2745False899497581.5330595319.1395False584520840.35960156747.482False340721861.65916647961.7073False140087698.39531998333.5269False3451437393.3645489934739.7False8379150.674383023015.25571False280801.872812401856.314695False1.90546071796e-099.26027942892e-09False
4553.1564111-27.93866470.00.01675-0.0110.009390.0010.00578-0.0040.00778-0.0090.01009-0.0030.007010.0040.016040.0240.04537-0.0040.02234-0.03614.31-0.02514.310.4340.310750.680.48759-10.3785.959893630780547.756013213.806False3667752315.9931720591.1494False3627438014.7619310944.6231False3644181507.8926112910.3065False3661002285.4734022548.8461False3640826637.8923506810.0518False3617428867.6453441672.8324False3551403349.83148403607.871False3644181507.8974982315.713False3753185242.3849466970506.3False3715352290.9748968332317.6False2434445183.69696765786.677False1940885877.59871626589.321False5.14280431949e+132.82301979996e+14False
5653.1297942-27.93824390.4970.046840.6250.024330.9190.016121.3760.021541.4140.025271.7490.018721.9740.035832.090.12092.2130.051692.5250.3920.00614.312.5950.376572.2631.50047.9075.00472297206307.1699104315.5379False2041737944.6745752811.7568False1557399389.0823122815.6913False1022350938.520282495.0654False987188301.06822976343.8473False725103497.61712502058.4336False589386250.24119450129.0954False529663443.89258979621.4641False472933414.91922515531.9589False354813389.234128103721.668False3610771451.047589957153.0False332659553.294115377572.78False451647904.929624141033.14False2495743.7948311504128.6412False
6753.1597975-27.93865110.0040.022280.113nan0.00.00764-0.0030.010360.02nan0.0070.009260.041nan-0.0030.058320.077nan-0.08114.310.02914.310.4360.299950.6840.470640.4256.701513617428867.6474231949.5453False3271899836.23nanFalse3630780547.725548713.6405False3640826637.8934740449.6629False3564511334.26nanFalse3607447338.6430767107.341False3496230040.03nanFalse3640826637.89195565928.99False3382205566.7nanFalse3912010393.8751560285538.1False3535086133.6246592424891.4False2429964897.7671312209.975False1933748545.3838232538.778False2454708915.6915151246014.9False
7853.1559294-27.93864-0.0190.027120.0020.00928-0.010.009390.0230.01252-0.0090.010120.0090.011280.0010.01605-0.0170.07367-0.0080.02229-0.03514.31-0.02514.310.4720.280560.7790.41097-14.3576.065063694877122.5492292277.9255False3624098559.030975880.2185False3664375746.4831691388.8555False3554675819.9940990197.3161False3661002285.4734123706.0775False3600808291.7337409747.7387False3627438014.7653622951.7647False3688077172.26250245542.232False3657631930.0975090630.0854False3749730022.4549421430717.9False3715352290.9748968332317.6False2350715115.94607437267.024False1771740039.94670634359.455False2.00816780418e+151.12178797843e+16False
8953.1508114-27.9385994-0.0150.03074-0.0040.008080.0040.010460.0020.01413-0.0080.008320.0050.01268-0.0060.01316-0.0320.08013-0.0190.01826-0.02914.31-0.05514.310.8370.277881.3130.436013.4545.445543681289736.43104226833.371False3644181507.8927119834.8685False3617428867.6434850367.6949False3624098559.047164783.1344False3657631930.0928028445.1463False3614098626.442208015.5215False3650900524.8444251864.0314False3739383436.43275975686.772False3694877122.5462140744.6504False3729065399.6249149071049.4False3819442708.450340243714.5False1679577313.99429865875.307False1083427862.15435083015.659False150799534.18756339239.459False
91053.1419553-27.9386-0.0360.0245-0.0090.009650.0110.008340.0020.011020.0040.009180.0080.01-0.0070.01416-0.0410.064860.0050.02018-0.03514.31-0.0614.310.5250.275710.8240.43261-5.6264.845183753185242.3884691878.2254False3661002285.4732538909.4514False3594181463.1527608431.285False3624098559.036783857.7595False3617428867.6430585695.5487False3604126286.4933195229.8422False3654264677.5147658342.4286False3770509158.33225243685.287False3614098626.467173324.3868False3749730022.4549421430717.9False3837072454.9250572603722.1False2238721138.57568497027.556False1699808513.2677286211.581False646249172495.02.88393585096e+12False

II - Removal of duplicated sources¶

We remove duplicated objects from the input catalogues.

In [7]:
SORT_COLS = ['merr_fireworks_fu38', 
     'merr_fireworks_fb435', 
     'merr_fireworks_fb',
     'merr_fireworks_fv',
     'merr_fireworks_fv606',
     'merr_fireworks_frc',
     'merr_fireworks_fi775',
     'merr_fireworks_fi',
     'merr_fireworks_fz850',
     'merr_fireworks_fj',
     'merr_fireworks_fh',
     'merr_fireworks_fks',
     #'merr_fireworks_F3.6',
     #'merr_fireworks_F4.5',
     #'merr_fireworks_F5.8',
     #'merr_fireworks_F8.0',
     'merr_fireworks_fkst',
     'merr_fireworks_f24t']
FLAG_NAME = 'fireworks_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 6308 sources.
The cleaned catalogue has 6308 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_CDFS-SWIRE.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.16079856930133474 arcsec
Dec correction: -0.2589072199192799 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 = "fireworks_flag_gaia"

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

V - Flagging objects near bright stars¶

VI - Saving to disk¶

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