HATLAS-SGP master catalogue

Preparation of ATLAS/VST data

ATLAS/VST catalogue: the catalogue comes from dmu0_ATLAS.

In the catalogue, we keep:

  • The identifier (it's unique in the catalogue);
  • The position;
  • The stellarity;
  • The aperture corrected aperture magnitude in each band (2")
  • The Petrosian magnitude to be used as total magnitude (no “auto” magnitude is 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: 
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, mag_to_flux
In [3]:
OUT_DIR =  os.environ.get('TMP_DIR', "./data_tmp")
try:
    os.makedirs(OUT_DIR)
except FileExistsError:
    pass

RA_COL = "atlas_ra"
DEC_COL = "atlas_dec"

I - Column selection

In [4]:
imported_columns = OrderedDict({
        'sourceID': "atlas_id",
        'ra': "atlas_ra",
        'dec': "atlas_dec",
        'pStar':  "atlas_stellarity",
        'uAperMag3': "m_ap_atlas_u", 
        'uAperMag3Err': "merr_ap_atlas_u", 
        'uPetroMag': "m_atlas_u", 
        'uPetroMagErr': "merr_atlas_u",  
        'ulAperMag3': "m_ap_atlas_ul", 
        'ulAperMag3Err': "merr_ap_atlas_ul", 
        'ulPetroMag': "m_atlas_ul", 
        'ulPetroMagErr': "merr_atlas_ul", 
        'gAperMag3': "m_ap_atlas_g", 
        'gAperMag3Err': "merr_ap_atlas_g", 
        'gPetroMag': "m_atlas_g", 
        'gPetroMagErr': "merr_atlas_g",     
        'rAperMag3': "m_ap_atlas_r", 
        'rAperMag3Err': "merr_ap_atlas_r", 
        'rPetroMag': "m_atlas_r", 
        'rPetroMagErr': "merr_atlas_r",     
        'iAperMag3': "m_ap_atlas_i", 
        'iAperMag3Err': "merr_ap_atlas_i", 
        'iPetroMag': "m_atlas_i", 
        'iPetroMagErr': "merr_atlas_i",    
        'zAperMag3': "m_ap_atlas_z", 
        'zAperMag3Err': "merr_ap_atlas_z", 
        'zPetroMag': "m_atlas_z", 
        'zPetroMagErr': "merr_atlas_z", 

    })


catalogue = Table.read("../../dmu0/dmu0_ATLAS/data/ATLAS_HATLAS-SGP.fits")[list(imported_columns)]
for column in imported_columns:
    catalogue[column].name = imported_columns[column]

epoch = 2011

# 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:])
        
        # Large negative numbers are used for missing values.
        catalogue[col][catalogue[col] <= 0] = np.nan
        catalogue[errcol][catalogue[errcol] <= 0] = 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:])))
        
        # 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/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)
In [6]:
catalogue[:10].show_in_notebook()
Out[6]:
<Table masked=True length=10>
idxatlas_idatlas_raatlas_decatlas_stellaritym_ap_atlas_umerr_ap_atlas_um_atlas_umerr_atlas_um_ap_atlas_ulmerr_ap_atlas_ulm_atlas_ulmerr_atlas_ulm_ap_atlas_gmerr_ap_atlas_gm_atlas_gmerr_atlas_gm_ap_atlas_rmerr_ap_atlas_rm_atlas_rmerr_atlas_rm_ap_atlas_imerr_ap_atlas_im_atlas_imerr_atlas_im_ap_atlas_zmerr_ap_atlas_zm_atlas_zmerr_atlas_zf_ap_atlas_uferr_ap_atlas_uf_atlas_uferr_atlas_uflag_atlas_uf_ap_atlas_ulferr_ap_atlas_ulf_atlas_ulferr_atlas_ulflag_atlas_ulf_ap_atlas_gferr_ap_atlas_gf_atlas_gferr_atlas_gflag_atlas_gf_ap_atlas_rferr_ap_atlas_rf_atlas_rferr_atlas_rflag_atlas_rf_ap_atlas_iferr_ap_atlas_if_atlas_iferr_atlas_iflag_atlas_if_ap_atlas_zferr_ap_atlas_zf_atlas_zferr_atlas_zflag_atlas_z
073014446044422.7457438512-31.05974942850.9999989918.5375020.01366370318.6792550.02413136118.5402130.01498238718.6712340.02945553517.8137470.003264942417.8509330.003654344917.3547360.003035974217.3778270.003566026517.1920340.004019278117.2253040.006115703817.0158710.009091716317.0826680.017598459139.6365788851.75728941658122.5456782962.72367633039False139.288351991.92208013785123.4543507943.34926102195False271.9576000550.817809975878262.8008708360.884528873447False415.0549522171.16059142266406.3209357551.33453339592False482.1546949141.78488457656467.6041964242.633907526False567.0894919834.74868274193533.2523769818.64337032496False
173014446044522.7233211913-31.05196133190.05000000120.4518430.05490156321.0477240.097468987nannannannannannannannannannannannannannannannannannannannan23.94764436381.2109415712413.83280962591.24180250754FalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalse
273014446044622.7856996673-31.04768996990.05000000119.6738910.02989116120.1718670.046140529nannannannannannannannannannannannannannannannannannannannan49.02793481381.3497771250530.99225666241.3170778602FalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalse
373014446044722.750519051-31.04352171880.05000000120.4397130.05450902121.0350530.09726382nannannannannannannannannannannannannannannannannannannannan24.21669098321.2157908261413.99519003661.25373515097FalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalsenannannannanFalse
473014446073722.7232689813-30.9370889570.0030674851nannannannan23.2234570.7940986224.1997132.111772823.0146980.1502535922.4755420.1558348522.754580.1811802522.8232570.17119166nannannannannannannannannannannannanFalse1.864735333381.363852239990.7587781214791.4758345454False2.260064324840.3127672973883.71349804830.532995407905False2.871891313230.4792416277762.695859162660.425065133831FalsenannannannanFalsenannannannanFalse
573014446073822.7196088838-30.9370638649.5258065e-06nannannannannannan16.2726590.1747271322.277870.07797151121.6964660.1281649321.3013080.04974113820.7828690.1322361520.7593920.06809050620.307970.135551220.3310910.1529015620.3261990.15353543nannannannanFalsenannan1124.44029391180.9557649False4.45504402380.3199363828757.610507179630.898376710353False10.95158050490.50172783667417.6543771432.15019712321False18.04027693171.1313720397927.34084923023.41343035807False26.76477519683.7692174790726.88564129313.80193501762False
673014446073922.7675309726-30.93576584470.00017140902nannannannan26.72318619.91832221.201630.1372334422.7847610.1235721322.4927480.1434565222.095020.101106821.9450150.1829228621.7444110.1678155521.7647060.15280862nannannannannannannannanFalse0.07425498248771.3622412560412.00460846671.51734252622False2.793158623570.3179009404223.655112932880.482943996213False5.272201495790.4909621875546.053325117181.01985320015False7.28174724221.125494768497.146898264511.00586832814FalsenannannannanFalse
773014446074022.7016215352-30.9343264579.5258065e-06nannannannan22.0577430.2709672719.6862140.08184964221.2475720.03221306920.3628030.06403096819.9779620.01667969119.4446350.03887413119.4744740.02201429918.8332020.04992978318.9939770.04579565718.3191010.089043707nannannannanFalse5.456357279991.3617435154448.47461851963.65432243535False11.50724076780.34141215815425.99434029261.53300844548False37.05230241190.5692183353260.554441092.1681152984False58.91289979651.19451316572106.3455202034.89051458675False91.70841762213.86820225671170.74956266114.0035617872False
873014446074122.7390010308-30.93325853859.5258065e-06nannannannannannan17.1624360.2100279623.1758960.1744243723.2416690.1839102221.3587740.05271057421.4120370.1360376820.8371720.07322578920.8772450.1793107520.2499260.1424375520.4951270.21415308nannannannanFalsenannan495.47939656195.8469713229False1.94823616110.3129856621911.83371737470.310608934584False10.38700641880.5042708054489.889747419091.23913920231False16.79311260031.1325853504116.18460110512.67290797698False28.84228075373.7838139586523.01172630464.53888526757False
973014446074222.7966467785-30.93245260140.00017140902nannannannannannan16.5943660.1310227222.6106870.1063289922.3275170.09575497421.718330.0730860921.1627980.1111383721.2099760.1035529721.0935040.1165689nannannannannannannannanFalsenannan836.091099054100.896451169False3.278877563570.3211090669544.255917493450.375344643704False7.458783475530.50208634288412.44173079031.27356320435False11.9126834051.136181829313.26167559311.42382553816FalsenannannannanFalse

II - Removal of duplicated sources

We remove duplicated objects from the input catalogues.

In [7]:
SORT_COLS = ['merr_ap_atlas_g', 
             'merr_ap_atlas_r', 
             'merr_ap_atlas_i', 
             'merr_ap_atlas_u', 
             'merr_ap_atlas_ul', 
             'merr_ap_atlas_z']
FLAG_NAME = 'atlas_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 7937203 sources.
The cleaned catalogue has 7562634 sources (374569 removed).
The cleaned catalogue has 362887 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_SGP.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, near_ra0=True)
In [10]:
delta_ra, delta_dec =  astrometric_correction(
    SkyCoord(catalogue[RA_COL], catalogue[DEC_COL]),
    gaia_coords, near_ra0=True
)

print("RA correction: {}".format(delta_ra))
print("Dec correction: {}".format(delta_dec))
RA correction: 0.12983922202352005 arcsec
Dec correction: -0.11415334424285106 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, near_ra0=True)

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 = "atlas_flag_gaia"

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

V - Flagging objects near bright stars

VI - Saving to disk

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