Herschel Stripe 82 IRAC merging¶

Both SHELA and SpIES provide IRAC fluxes which have marginally overlapping coverage. We chose which to use here since in order to run in low memory mode we must have one catalogue per band before merging

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))

import os
import time

from astropy import units as u
from astropy.coordinates import SkyCoord
from astropy.table import Column, Table
import numpy as np
from pymoc import MOC

from herschelhelp_internal.masterlist import merge_catalogues, nb_merge_dist_plot
from herschelhelp_internal.utils import coords_to_hpidx, ebv, gen_help_id, inMoc
In [3]:
TMP_DIR = os.environ.get('TMP_DIR', "./data_tmp")
OUT_DIR = os.environ.get('OUT_DIR', "./data")
SUFFIX = os.environ.get('SUFFIX', time.strftime("_%Y%m%d"))

try:
    os.makedirs(OUT_DIR)
except FileExistsError:
    pass

I - Reading the prepared pristine catalogues¶

In [4]:
shela = Table.read("{}/SHELA.fits".format(TMP_DIR))
spies= Table.read("{}/SpIES.fits".format(TMP_DIR))

II - Merging tables¶

We first merge the optical catalogues and then add the infrared ones: HSC, VHS, VICS82, UKIDSS-LAS, PanSTARRS, SHELA, SpIES.

At every step, we look at the distribution of the distances separating the sources from one catalogue to the other (within a maximum radius) to determine the best cross-matching radius.

SHELA¶

In [5]:
master_catalogue = shela
master_catalogue['shela_ra'].name = 'ra'
master_catalogue['shela_dec'].name = 'dec'

Add SpIES¶

In [6]:
nb_merge_dist_plot(
    SkyCoord(master_catalogue['ra'], master_catalogue['dec']),
    SkyCoord(spies['spies_ra'], spies['spies_dec'])
)
In [7]:
# Given the graph above, we use 1 arc-second radius
master_catalogue = merge_catalogues(master_catalogue, spies, "spies_ra", "spies_dec", radius=1.5*u.arcsec)
del spies

Cleaning¶

When we merge the catalogues, astropy masks the non-existent values (e.g. when a row comes only from a catalogue and has no counterparts in the other, the columns from the latest are masked for that row). We indicate to use NaN for masked values for floats columns, False for flag columns and -1 for ID columns.

In [8]:
for col in master_catalogue.colnames:
    if "m_" in col or "merr_" in col or "f_" in col or "ferr_" in col or "stellarity" in col:
        master_catalogue[col].fill_value = np.nan
    elif "flag" in col:
        master_catalogue[col].fill_value = 0
    elif "id" in col:
        master_catalogue[col].fill_value = -1
        
master_catalogue = master_catalogue.filled()
In [9]:
master_catalogue[:10].show_in_notebook()
Out[9]:
<Table length=10>
idxshela_intidradecf_shela_irac1ferr_shela_irac1f_ap_shela_irac1ferr_ap_shela_irac1f_shela_irac2ferr_shela_irac2f_ap_shela_irac2ferr_ap_shela_irac2m_shela_irac1merr_shela_irac1flag_shela_irac1m_ap_shela_irac1merr_ap_shela_irac1m_shela_irac2merr_shela_irac2flag_shela_irac2m_ap_shela_irac2merr_ap_shela_irac2shela_flag_cleanedshela_flag_gaiaflag_mergedspies_intidf_ap_spies_irac1ferr_ap_spies_irac1f_spies_irac1ferr_spies_irac1spies_stellarity_irac1f_ap_spies_irac2ferr_ap_spies_irac2f_spies_irac2ferr_spies_irac2spies_stellarity_irac2m_ap_spies_irac1merr_ap_spies_irac1m_spies_irac1merr_spies_irac1flag_spies_irac1m_ap_spies_irac2merr_ap_spies_irac2m_spies_irac2merr_spies_irac2flag_spies_irac2spies_flag_cleanedspies_flag_gaia
degdeg
0137939122.91601090270.2383122672922.629862.07571-0.02244740.45900536.91463.3150742.66511.1383322.85020.856956Falsenan-22.201119.9820.097503False19.82480.028968False0False-1nannannannannannannannannannannannannannanFalsenannannannanFalseFalse0
1143385323.66399313640.297376305167-1.66275nan-0.9994340.47879641.98280.87940457.09251.2495nannanFalsenan-0.52014119.84230.0227427False19.50860.023762False0False-1nannannannannannannannannannannannannannanFalsenannannannanFalseFalse0
2150146117.17807436590.3712092898550.8090251.80919-0.3678860.48066311.08212.471778.79210.7620424.13012.42799Falsenan-1.4185721.28850.242165False21.53980.0941042False0False-1nannannannannannannannannannannannannannanFalsenannannannanFalseFalse0
3204191018.08837760530.9559928881071.323590.4041581.531330.480682.938040.6342614.195990.7651923.59560.331529False23.43730.34080922.72990.234388False22.34290.197997False0False-1nannannannannannannannannannannannannannanFalsenannannannanFalseFalse0
4205128214.34978739380.9616957224360.4657280.6918271.69280.4808122.23410.9812121.804390.65220824.72971.61283False23.32850.30838523.02720.476854False23.25920.392445False0False-1nannannannannannannannannannannannannannanFalsenannannannanFalseFalse0
5149727318.78907994520.3683520335771.839740.8996522.059730.4823322.033281.366762.420530.71006623.23810.530935False23.11550.2542523.12950.729826False22.94020.318502False0False-1nannannannannannannannannannannannannannanFalsenannannannanFalseFalse0
654502622.4245506266-0.6425941441881.704250.9152791.755360.4851142.862041.232682.41440.6432323.32120.583102False23.28910.30005622.75830.467627False22.9430.289256False0False-1nannannannannannannannannannannannannannanFalsenannannannanFalseFalse0
747715922.4517375046-0.7140302993911.619520.7453051.456460.4855064.263860.9858515.679170.67795723.37650.499657False23.49180.36192622.32550.251034False22.01430.129611False0False-1nannannannannannannannannannannannannannanFalsenannannannanFalseFalse0
854388824.8499402825-0.642484862009-0.368214nan-0.7905270.4865576.090790.3349588.42270.788449nannanFalsenan-0.66825321.93830.0597091False21.58640.101636False0False-1nannannannannannannannannannannannannannanFalsenannannannanFalseFalse0
986958624.6311943916-0.3004279563830.7844290.6729381.705110.4874964.061121.113254.081630.78932224.16360.93142False23.32060.31041522.37840.297625False22.37290.209964False0False-1nannannannannannannannannannannannannannanFalsenannannannanFalseFalse0

III - Merging flags and stellarity¶

Each pristine catalogue contains a flag indicating if the source was associated to a another nearby source that was removed during the cleaning process. We merge these flags in a single one.

In [10]:
flag_cleaned_columns = [column for column in master_catalogue.colnames
                        if 'flag_cleaned' in column]

flag_column = np.zeros(len(master_catalogue), dtype=bool)
for column in flag_cleaned_columns:
    flag_column |= master_catalogue[column]
    
master_catalogue.add_column(Column(data=flag_column, name="irac_flag_cleaned"))
master_catalogue.remove_columns(flag_cleaned_columns)

Each pristine catalogue contains a flag indicating the probability of a source being a Gaia object (0: not a Gaia object, 1: possibly, 2: probably, 3: definitely). We merge these flags taking the highest value.

In [11]:
flag_gaia_columns = [column for column in master_catalogue.colnames
                     if 'flag_gaia' in column]

master_catalogue.add_column(Column(
    data=np.max([master_catalogue[column] for column in flag_gaia_columns], axis=0),
    name="irac_flag_gaia"
))
master_catalogue.remove_columns(flag_gaia_columns)

Each prisitine catalogue may contain one or several stellarity columns indicating the probability (0 to 1) of each source being a star. We merge these columns taking the highest value.

In [12]:
stellarity_columns = [column for column in master_catalogue.colnames
                      if 'stellarity' in column]

master_catalogue.add_column(Column(
    data=np.nanmax([master_catalogue[column] for column in stellarity_columns], axis=0),
    name="irac_stellarity"
))
master_catalogue.remove_columns(stellarity_columns)
/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/numpy/lib/nanfunctions.py:343: RuntimeWarning: All-NaN slice encountered
  warnings.warn("All-NaN slice encountered", RuntimeWarning)

VIII - Cross-identification table¶

We are producing a table associating to each HELP identifier, the identifiers of the sources in the pristine catalogue. This can be used to easily get additional information from them.

In [13]:
master_catalogue.add_column(Column(data=(np.char.array(master_catalogue['shela_intid'].astype(str)) 
                                    +  np.char.array(master_catalogue['spies_intid'].astype(str) )), 
                              name="irac_intid"))
In [14]:
id_names = []
for col in master_catalogue.colnames:
    if '_id' in col:
        id_names += [col]
    if '_intid' in col:
        id_names += [col]
        
print(id_names)
['shela_intid', 'spies_intid', 'irac_intid']
In [15]:
#master_catalogue[id_names].write(
#    "{}/master_list_irac_cross_ident_herschel-stripe-82{}.fits".format(OUT_DIR, SUFFIX), overwrite=True)

#Lets leave the shela and spies ids in so that the final cross ident table is complete
#master_catalogue.remove_columns(['shela_intid', 'spies_intid'])

VI - Choosing between multiple values for the same filter¶

Both SHELA and SpIES provide IRAC1 and IRAC2 fluxes. SpIES seems to go deeper and neither apear to suffer from the bright drop off that affects both SERVS and SWIRE.

In [16]:
seip = Table.read("../../dmu0/dmu0_SEIP/data/SEIP_Herschel-Stripe-82.fits")
seip_coords = SkyCoord(seip['ra'], seip['dec'])
idx, d2d, _ = seip_coords.match_to_catalog_sky(SkyCoord(master_catalogue['ra'], master_catalogue['dec']))
mask = d2d <= 2 * u.arcsec
WARNING: UnitsWarning: 'e/count' did not parse as fits unit: At col 0, Unit 'e' not supported by the FITS standard.  [astropy.units.core]
WARNING: UnitsWarning: 'image' did not parse as fits unit: At col 0, Unit 'image' not supported by the FITS standard.  [astropy.units.core]
In [17]:
# servs -> shela and swire -> spies
fig, ax = plt.subplots()
ax.scatter(seip['i1_f_ap1'][mask], master_catalogue[idx[mask]]['f_ap_shela_irac1'], label="SHELA", s=2.)
ax.scatter(seip['i1_f_ap1'][mask], master_catalogue[idx[mask]]['f_ap_spies_irac1'], label="SpIES", s=2.)
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel("SEIP flux [μJy]")
ax.set_ylabel("SHELA/SpIES flux [μJy]")
ax.set_title("IRAC 1")
ax.legend()
ax.axvline(2000, color="black", linestyle="--", linewidth=1.)
ax.plot(seip['i1_f_ap1'][mask], seip['i1_f_ap1'][mask], linewidth=.1, color="black", alpha=.5);
In [18]:
fig, ax = plt.subplots()
ax.scatter(seip['i2_f_ap1'][mask], master_catalogue[idx[mask]]['f_ap_shela_irac2'], label="SHELA", s=2.)
ax.scatter(seip['i2_f_ap1'][mask], master_catalogue[idx[mask]]['f_ap_spies_irac2'], label="SpIES", s=2.)
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel("SEIP flux [μJy]")
ax.set_ylabel("SHELA/SpIES flux [μJy]")
ax.set_title("IRAC 2")
ax.legend()
ax.axvline(2000, color="black", linestyle="--", linewidth=1.)

ax.plot(seip['i1_f_ap2'][mask], seip['i1_f_ap2'][mask], linewidth=.1, color="black", alpha=.5);

When both SHELA and SpIES fluxes are provided, we use the SpIES flux.

We create a table indicating for each source the origin on the IRAC1 and IRAC2 fluxes that will be saved separately.

In [19]:
irac_origin = Table()
irac_origin.add_column(master_catalogue['irac_intid'])
In [20]:
# IRAC1 aperture flux and magnitudes
has_shela = ~np.isnan(master_catalogue['f_ap_shela_irac1'])
has_spies = ~np.isnan(master_catalogue['f_ap_spies_irac1'])
has_both = has_shela & has_spies

print("{} sources with SHELA flux".format(np.sum(has_shela)))
print("{} sources with SpIES flux".format(np.sum(has_spies)))
print("{} sources with SHELA and SpIES flux".format(np.sum(has_both)))

use_shela = has_shela
use_spies = (has_spies & ~has_shela)

print("{} sources for which we use SHELA".format(np.sum(use_shela)))
print("{} sources for which we use SpIES".format(np.sum(use_spies)))

f_ap_irac = np.full(len(master_catalogue), np.nan)
f_ap_irac[use_shela] = master_catalogue['f_ap_shela_irac1'][use_shela]
f_ap_irac[use_spies] = master_catalogue['f_ap_spies_irac1'][use_spies]

ferr_ap_irac = np.full(len(master_catalogue), np.nan)
ferr_ap_irac[use_shela] = master_catalogue['ferr_ap_shela_irac1'][use_shela]
ferr_ap_irac[use_spies] = master_catalogue['ferr_ap_spies_irac1'][use_spies]

m_ap_irac = np.full(len(master_catalogue), np.nan)
m_ap_irac[use_shela] = master_catalogue['m_ap_shela_irac1'][use_shela]
m_ap_irac[use_spies] = master_catalogue['m_ap_spies_irac1'][use_spies]

merr_ap_irac = np.full(len(master_catalogue), np.nan)
merr_ap_irac[use_shela] = master_catalogue['merr_ap_shela_irac1'][use_shela]
merr_ap_irac[use_spies] = master_catalogue['merr_ap_spies_irac1'][use_spies]

master_catalogue.add_column(Column(data=f_ap_irac, name="f_ap_irac_i1"))
master_catalogue.add_column(Column(data=ferr_ap_irac, name="ferr_ap_irac_i1"))
master_catalogue.add_column(Column(data=m_ap_irac, name="m_ap_irac_i1"))
master_catalogue.add_column(Column(data=merr_ap_irac, name="merr_ap_irac_i1"))

master_catalogue.remove_columns(['f_ap_shela_irac1', 'f_ap_spies_irac1', 
                                 'ferr_ap_shela_irac1', 'ferr_ap_spies_irac1', 
                                 'm_ap_shela_irac1', 'm_ap_spies_irac1',
                                 'merr_ap_shela_irac1', 'merr_ap_spies_irac1'])

origin = np.full(len(master_catalogue), '     ', dtype='<U5')
origin[use_shela] = "SHELA"
origin[use_spies] = "SpIES"
irac_origin.add_column(Column(data=origin, name="IRAC1_ap"))
2240390 sources with SHELA flux
3365594 sources with SpIES flux
64802 sources with SHELA and SpIES flux
2240390 sources for which we use SHELA
3300792 sources for which we use SpIES
In [21]:
# IRAC1 total flux and magnitudes
has_shela = ~np.isnan(master_catalogue['f_shela_irac1'])
has_spies = ~np.isnan(master_catalogue['f_spies_irac1'])
has_both = has_shela & has_spies

print("{} sources with SHELA total flux".format(np.sum(has_shela)))
print("{} sources with SpIES total flux".format(np.sum(has_spies)))
print("{} sources with SHELA and SpIES total flux".format(np.sum(has_both)))

use_shela = has_shela
use_spies = (has_spies & ~has_shela)

print("{} sources for which we use SHELA".format(np.sum(use_shela)))
print("{} sources for which we use SpIES".format(np.sum(use_spies)))

f_ap_irac = np.full(len(master_catalogue), np.nan)
f_ap_irac[use_shela] = master_catalogue['f_shela_irac1'][use_shela]
f_ap_irac[use_spies] = master_catalogue['f_spies_irac1'][use_spies]

ferr_ap_irac = np.full(len(master_catalogue), np.nan)
ferr_ap_irac[use_shela] = master_catalogue['ferr_shela_irac1'][use_shela]
ferr_ap_irac[use_spies] = master_catalogue['ferr_spies_irac1'][use_spies]

flag_irac = np.full(len(master_catalogue), False, dtype=bool)
flag_irac[use_shela] = master_catalogue['flag_shela_irac1'][use_shela]
flag_irac[use_spies] = master_catalogue['flag_spies_irac1'][use_spies]

m_ap_irac = np.full(len(master_catalogue), np.nan)
m_ap_irac[use_shela] = master_catalogue['m_shela_irac1'][use_shela]
m_ap_irac[use_spies] = master_catalogue['m_spies_irac1'][use_spies]

merr_ap_irac = np.full(len(master_catalogue), np.nan)
merr_ap_irac[use_shela] = master_catalogue['merr_shela_irac1'][use_shela]
merr_ap_irac[use_spies] = master_catalogue['merr_spies_irac1'][use_spies]

master_catalogue.add_column(Column(data=f_ap_irac, name="f_irac_i1"))
master_catalogue.add_column(Column(data=ferr_ap_irac, name="ferr_irac_i1"))
master_catalogue.add_column(Column(data=m_ap_irac, name="m_irac_i1"))
master_catalogue.add_column(Column(data=merr_ap_irac, name="merr_irac_i1"))
master_catalogue.add_column(Column(data=flag_irac, name="flag_irac_i1"))

master_catalogue.remove_columns(['f_shela_irac1', 'f_spies_irac1', 
                                 'ferr_shela_irac1', 'ferr_spies_irac1', 
                                 'm_shela_irac1', 'm_spies_irac1',
                                 'merr_shela_irac1', 'merr_spies_irac1',
                                'flag_shela_irac1', 'flag_spies_irac1'])

origin = np.full(len(master_catalogue), '     ', dtype='<U5')
origin[use_shela] = "SHELA"
origin[use_spies] = "SpIES"
irac_origin.add_column(Column(data=origin, name="IRAC1_total"))
2240390 sources with SHELA total flux
3365594 sources with SpIES total flux
64802 sources with SHELA and SpIES total flux
2240390 sources for which we use SHELA
3300792 sources for which we use SpIES
In [22]:
# IRAC2 aperture flux and magnitudes
has_shela = ~np.isnan(master_catalogue['f_ap_shela_irac2'])
has_spies = ~np.isnan(master_catalogue['f_ap_spies_irac2'])
has_both = has_shela & has_spies

print("{} sources with SHELA flux".format(np.sum(has_shela)))
print("{} sources with SpIES flux".format(np.sum(has_spies)))
print("{} sources with SHELA and SpIES flux".format(np.sum(has_both)))

use_shela = has_shela
use_spies = (has_spies & ~has_shela)

print("{} sources for which we use SHELA".format(np.sum(use_shela)))
print("{} sources for which we use SpIES".format(np.sum(use_spies)))

f_ap_irac = np.full(len(master_catalogue), np.nan)
f_ap_irac[use_shela] = master_catalogue['f_ap_shela_irac2'][use_shela]
f_ap_irac[use_spies] = master_catalogue['f_ap_spies_irac2'][use_spies]

ferr_ap_irac = np.full(len(master_catalogue), np.nan)
ferr_ap_irac[use_shela] = master_catalogue['ferr_ap_shela_irac2'][use_shela]
ferr_ap_irac[use_spies] = master_catalogue['ferr_ap_spies_irac2'][use_spies]

m_ap_irac = np.full(len(master_catalogue), np.nan)
m_ap_irac[use_shela] = master_catalogue['m_ap_shela_irac2'][use_shela]
m_ap_irac[use_spies] = master_catalogue['m_ap_spies_irac2'][use_spies]

merr_ap_irac = np.full(len(master_catalogue), np.nan)
merr_ap_irac[use_shela] = master_catalogue['merr_ap_shela_irac2'][use_shela]
merr_ap_irac[use_spies] = master_catalogue['merr_ap_spies_irac2'][use_spies]

master_catalogue.add_column(Column(data=f_ap_irac, name="f_ap_irac_i2"))
master_catalogue.add_column(Column(data=ferr_ap_irac, name="ferr_ap_irac_i2"))
master_catalogue.add_column(Column(data=m_ap_irac, name="m_ap_irac_i2"))
master_catalogue.add_column(Column(data=merr_ap_irac, name="merr_ap_irac_i2"))

master_catalogue.remove_columns(['f_ap_shela_irac2', 'f_ap_spies_irac2', 
                                 'ferr_ap_shela_irac2', 'ferr_ap_spies_irac2', 
                                 'm_ap_shela_irac2', 'm_ap_spies_irac2',
                                 'merr_ap_shela_irac2', 'merr_ap_spies_irac2'])

origin = np.full(len(master_catalogue), '     ', dtype='<U5')
origin[use_shela] = "SHELA"
origin[use_spies] = "SpIES"
irac_origin.add_column(Column(data=origin, name="IRAC2_ap"))
2244367 sources with SHELA flux
3365594 sources with SpIES flux
66244 sources with SHELA and SpIES flux
2244367 sources for which we use SHELA
3299350 sources for which we use SpIES
In [23]:
# IRAC2 total flux and magnitudes
has_shela = ~np.isnan(master_catalogue['f_shela_irac2'])
has_spies = ~np.isnan(master_catalogue['f_spies_irac2'])
has_both = has_shela & has_spies

print("{} sources with SHELA total flux".format(np.sum(has_shela)))
print("{} sources with SpIES total flux".format(np.sum(has_spies)))
print("{} sources with SHELA and SpIES total flux".format(np.sum(has_both)))

use_shela = has_shela
use_spies = (has_spies & ~has_shela)

print("{} sources for which we use SHELA".format(np.sum(use_shela)))
print("{} sources for which we use SpIES".format(np.sum(use_spies)))

f_ap_irac = np.full(len(master_catalogue), np.nan)
f_ap_irac[use_shela] = master_catalogue['f_shela_irac2'][use_shela]
f_ap_irac[use_spies] = master_catalogue['f_spies_irac2'][use_spies]

ferr_ap_irac = np.full(len(master_catalogue), np.nan)
ferr_ap_irac[use_shela] = master_catalogue['ferr_shela_irac2'][use_shela]
ferr_ap_irac[use_spies] = master_catalogue['ferr_spies_irac2'][use_spies]

flag_irac = np.full(len(master_catalogue), False, dtype=bool)
flag_irac[use_shela] = master_catalogue['flag_shela_irac2'][use_shela]
flag_irac[use_spies] = master_catalogue['flag_spies_irac2'][use_spies]

m_ap_irac = np.full(len(master_catalogue), np.nan)
m_ap_irac[use_shela] = master_catalogue['m_shela_irac2'][use_shela]
m_ap_irac[use_spies] = master_catalogue['m_spies_irac2'][use_spies]

merr_ap_irac = np.full(len(master_catalogue), np.nan)
merr_ap_irac[use_shela] = master_catalogue['merr_shela_irac2'][use_shela]
merr_ap_irac[use_spies] = master_catalogue['merr_spies_irac2'][use_spies]

master_catalogue.add_column(Column(data=f_ap_irac, name="f_irac_i2"))
master_catalogue.add_column(Column(data=ferr_ap_irac, name="ferr_irac_i2"))
master_catalogue.add_column(Column(data=m_ap_irac, name="m_irac_i2"))
master_catalogue.add_column(Column(data=merr_ap_irac, name="merr_irac_i2"))
master_catalogue.add_column(Column(data=flag_irac, name="flag_irac_i2"))

master_catalogue.remove_columns(['f_shela_irac2', 'f_spies_irac2', 
                                 'ferr_shela_irac2', 'ferr_spies_irac2', 
                                 'm_shela_irac2', 'm_spies_irac2',
                                 'merr_shela_irac2', 'merr_spies_irac2',
                                'flag_shela_irac2', 'flag_spies_irac2'])

origin = np.full(len(master_catalogue), '     ', dtype='<U5')
origin[use_shela] = "SHELA"
origin[use_spies] = "SpIES"
irac_origin.add_column(Column(data=origin, name="IRAC2_total"))
2244367 sources with SHELA total flux
3365594 sources with SpIES total flux
66244 sources with SHELA and SpIES total flux
2244367 sources for which we use SHELA
3299350 sources for which we use SpIES
In [24]:
irac_origin.write("{}/herschel-stripe-82_irac_fluxes_origins{}.fits".format(OUT_DIR, SUFFIX), overwrite = True)

IX - Saving the catalogue¶

In [25]:
master_catalogue.colnames
Out[25]:
['shela_intid',
 'ra',
 'dec',
 'flag_merged',
 'spies_intid',
 'irac_flag_cleaned',
 'irac_flag_gaia',
 'irac_stellarity',
 'irac_intid',
 'f_ap_irac_i1',
 'ferr_ap_irac_i1',
 'm_ap_irac_i1',
 'merr_ap_irac_i1',
 'f_irac_i1',
 'ferr_irac_i1',
 'm_irac_i1',
 'merr_irac_i1',
 'flag_irac_i1',
 'f_ap_irac_i2',
 'ferr_ap_irac_i2',
 'm_ap_irac_i2',
 'merr_ap_irac_i2',
 'f_irac_i2',
 'ferr_irac_i2',
 'm_irac_i2',
 'merr_irac_i2',
 'flag_irac_i2']
In [26]:
master_catalogue["ra"].name = "irac_ra"
master_catalogue["dec"].name = "irac_dec"
master_catalogue["flag_merged"].name = "irac_flag_merged"
In [27]:
columns = ["irac_intid", "shela_intid", "spies_intid",
           'irac_ra', 'irac_dec', 'irac_flag_merged',  
           'irac_flag_cleaned',  'irac_flag_gaia', 'irac_stellarity']

bands = [column[5:] for column in master_catalogue.colnames if 'f_ap' in column]
for band in bands:
    columns += ["f_ap_{}".format(band), "ferr_ap_{}".format(band),
                "m_ap_{}".format(band), "merr_ap_{}".format(band),
                "f_{}".format(band), "ferr_{}".format(band),
                "m_{}".format(band), "merr_{}".format(band),
                "flag_{}".format(band)]    
In [28]:
# We check for columns in the master catalogue that we will not save to disk.
print("Missing columns: {}".format(set(master_catalogue.colnames) - set(columns)))
Missing columns: set()
In [29]:
master_catalogue[:10].show_in_notebook()
Out[29]:
<Table length=10>
idxshela_intidirac_rairac_decirac_flag_mergedspies_intidirac_flag_cleanedirac_flag_gaiairac_stellarityirac_intidf_ap_irac_i1ferr_ap_irac_i1m_ap_irac_i1merr_ap_irac_i1f_irac_i1ferr_irac_i1m_irac_i1merr_irac_i1flag_irac_i1f_ap_irac_i2ferr_ap_irac_i2m_ap_irac_i2merr_ap_irac_i2f_irac_i2ferr_irac_i2m_irac_i2merr_irac_i2flag_irac_i2
degdeg
0137939122.91601090270.238312267292False-1False0nan1379391-1-0.02244743518530.459004551172nan-22.20110321042.629861354832.0757107734722.85016632080.856955587864False42.66508483891.1383256912219.82482147220.028967984020736.91461181643.3150653839119.98200988770.09750302881False
1143385323.66399313640.297376305167False-1False0nan1433853-1-0.9994336366650.478795945644nan-0.520140647888-1.66275298595nannannanFalse57.09251403811.2495038509419.50855255130.023761985823541.98275756840.8794037699719.84232330320.0227426812053False
2150146117.17807436590.371209289855False-1False0nan1501461-1-0.3678855001930.480662703514nan-1.418574213980.8090254068371.8091912269624.13009643552.42798852921False8.79210376740.76203960180321.53977203370.094104208052211.08208751682.4717743396821.28845214840.242165103555False
3204191018.08837760530.955992888107False-1False0nan2041910-11.531331658360.48067951202423.43732452390.3408086597921.323593258860.40415823459623.59561920170.331528753042False4.195992946620.76518988609322.34291076660.19799707832.938036203380.63426148891422.72985839840.234388068318False
4205128214.34978739380.961695722436False-1False0nan2051282-11.692801237110.48081177473123.32849121090.3083851337430.4657284617420.69182699918724.72966766361.61283159256False1.804394364360.6522078514123.25917053220.3924450576312.234096050260.98121178150223.02724456790.476853758097False
5149727318.78907994520.368352033577False-1False0nan1497273-12.059726953510.48233154416123.11547851560.2542496025561.839744329450.89965182542823.23810577390.530934929848False2.420528173450.7100657820722.94022369380.318502455952.033278703691.3667585849823.12950897220.729825854301False
654502622.4245506266-0.642594144188False-1False0nan545026-11.75536012650.48511439561823.28908538820.300055950881.704250097270.91527885198623.32116699220.583101809025False2.414396762850.64322990179122.94297790530.2892556786542.862038373951.2326800823222.75830841060.46762663126False
747715922.4517375046-0.714030299391False-1False0nan477159-11.456461310390.48550558090223.49175262450.361925870181.619518876080.74530512094523.37654113770.499657481909False5.679172515870.67795693874422.0142898560.1296108514074.263857364650.98585087060922.32549285890.251034170389False
854388824.8499402825-0.642484862009False-1False0nan543888-1-0.7905268073080.48655667901nan-0.668253362179-0.368213504553nannannanFalse8.422697067260.78844881057721.58637237550.1016357839116.090794086460.33495756983821.93831634520.0597090534866False
986958624.6311943916-0.300427956383False-1False0nan869586-11.705112457280.48749649524723.32061767580.3104150295260.7844287157060.67293757200224.16361236570.931420087814False4.081634044650.78932219743722.37291717530.2099638730294.061122417451.1132450103822.37838745120.297624707222False
In [30]:
master_catalogue[columns].write("{}/IRAC.fits".format(TMP_DIR, SUFFIX), overwrite=True)