GAMA-12 master catalogue

Preparation of Pan-STARRS1 - 3pi Steradian Survey (3SS) data

This catalogue comes from dmu0_PanSTARRS1-3SS.

In the catalogue, we keep:

  • The uniquePspsSTid as unique object identifier;
  • The r-band position which is given for all the sources;
  • The grizy <band>FApMag aperture magnitude (see below);
  • The grizy <band>FKronMag as total magnitude.

The 'F' above means we take the forced photometry from positions in the chi-squared image. We are alos using an updated catalogue which has significantly fewer duplicates.

The Pan-STARRS1-3SS catalogue provides for each band an aperture magnitude defined as “In PS1, an 'optimal' aperture radius is determined based on the local PSF. The wings of the same analytic PSF are then used to extrapolate the flux measured inside this aperture to a 'total' flux.”

The observations used for the catalogue where done between 2010 and 2015 (ref).

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 = "ps1_ra"
DEC_COL = "ps1_dec"

I - Column selection

In [4]:
imported_columns = OrderedDict({
        "objID": "ps1_id",
        "raMean": "ps1_ra",
        "decMean": "ps1_dec",
        "gFApMag": "m_ap_gpc1_g",
        "gFApMagErr": "merr_ap_gpc1_g",
        "gFKronMag": "m_gpc1_g",
        "gFKronMagErr": "merr_gpc1_g",
        "rFApMag": "m_ap_gpc1_r",
        "rFApMagErr": "merr_ap_gpc1_r",
        "rFKronMag": "m_gpc1_r",
        "rFKronMagErr": "merr_gpc1_r",
        "iFApMag": "m_ap_gpc1_i",
        "iFApMagErr": "merr_ap_gpc1_i",
        "iFKronMag": "m_gpc1_i",
        "iFKronMagErr": "merr_gpc1_i",
        "zFApMag": "m_ap_gpc1_z",
        "zFApMagErr": "merr_ap_gpc1_z",
        "zFKronMag": "m_gpc1_z",
        "zFKronMagErr": "merr_gpc1_z",
        "yFApMag": "m_ap_gpc1_y",
        "yFApMagErr": "merr_ap_gpc1_y",
        "yFKronMag": "m_gpc1_y",
        "yFKronMagErr": "merr_gpc1_y"
    })


catalogue = Table.read("../../dmu0/dmu0_PanSTARRS1-3SS/data/PanSTARRS1-3SS_GAMA-12_v2.fits")[list(imported_columns)]
for column in imported_columns:
    catalogue[column].name = imported_columns[column]

epoch = 2012

# 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:])
        
        # -999 is used for missing values
        catalogue[col][catalogue[col] < -900] = np.nan
        catalogue[errcol][catalogue[errcol] < -900] = 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>
idxps1_idps1_raps1_decm_ap_gpc1_gmerr_ap_gpc1_gm_gpc1_gmerr_gpc1_gm_ap_gpc1_rmerr_ap_gpc1_rm_gpc1_rmerr_gpc1_rm_ap_gpc1_imerr_ap_gpc1_im_gpc1_imerr_gpc1_im_ap_gpc1_zmerr_ap_gpc1_zm_gpc1_zmerr_gpc1_zm_ap_gpc1_ymerr_ap_gpc1_ym_gpc1_ymerr_gpc1_yf_ap_gpc1_gferr_ap_gpc1_gf_gpc1_gferr_gpc1_gflag_gpc1_gf_ap_gpc1_rferr_ap_gpc1_rf_gpc1_rferr_gpc1_rflag_gpc1_rf_ap_gpc1_iferr_ap_gpc1_if_gpc1_iferr_gpc1_iflag_gpc1_if_ap_gpc1_zferr_ap_gpc1_zf_gpc1_zferr_gpc1_zflag_gpc1_zf_ap_gpc1_yferr_ap_gpc1_yf_gpc1_yferr_gpc1_yflag_gpc1_y
0103921807002903165180.70004978-3.3976693722.74060058590.34223899245322.85370063780.31362000107821.9328002930.090075001120622.01090049740.13991199433821.04179954530.069909997284421.44190025330.13289199769521.02919960020.12603999674321.05470085140.16658599674720.68670082090.3020299971120.74769973750.2130180001262.909107470760.9169907067352.621318212190.757180074617False6.121810512450.5078785126195.696915804750.734125700447False13.90849638230.8955609475449.621436073651.1776450439False14.07084438111.6334438993513.74420611472.10879241668False19.28944230935.3659352791318.23560200063.57776728107False
1103961798026260154179.80259708-3.3669715122.35569953920.27099400758722.23089981080.28022599220322.59440040590.28254899382623.04520034790.66242897510521.75709915160.057183999568221.56310081480.1979600042120.95779991150.11118800193120.95409965520.0023439999204120.76379966740.64803999662419.66909980770.02939499914654.146867741041.035036229944.652003959311.20067141495False3.328433141340.8661822558562.197454345191.34071003928False7.197146440140.3790622594358.6051743511.56896338474False15.02726812481.5389114869315.07856935620.0325531793228False17.96718886810.724020219949.24476586211.33324268284False
2103961798376867600179.83766964-3.3607257623.64419937130.27206400036823.31629943850.23288199305522.62739944460.24065999686722.64620018010.12026000022924.52160072332.82224011421nannan21.9109001161.0418200492922.20590019231.2295299768420.79360008240.38145899772621.17799949650.327053993941.26566931590.3171516761791.711907224050.367190819019False3.228793142430.7156815293953.173364273060.351493103511False0.5641046902631.46632200207nannanFalse6.246546159875.993884149424.760361379095.39081868188False17.48074618536.1416280401412.26874673643.69568832943False
3103961798785535247179.87859452-3.3627325121.91049957280.10105399787421.99180030820.12823499739221.89240074160.10122100263821.77269935610.069136999547521.20700073240.10706599801821.41040039060.097947001457220.47949981690.11416699737320.85199928280.18311099708120.99670028690.33107501268420.93560028080.1995880007746.24885102290.581606632645.798022237650.684797433542False6.353890167060.5923604007547.0944749170.451758638035False11.94537277121.177950271759.904666197990.893524919107False23.34533300612.45480123116.56533743512.79376835868False14.49839358414.4210148088515.33768759782.81948634551False
4103961798458234249179.84575423-3.363353820.9701995850.02922499924920.9554996490.038371000438920.21850013730.025402000173920.22929954530.060685999691520.13400077820.10887300223120.17040061950.076155997812719.50169944760.067723996937319.59189987180.089469999074919.54120063780.062143001705419.60709953310.14827799797114.85662515950.39989903369415.0591389450.532204990986False29.6892991070.69461401192629.39545466461.64302575974False32.09221467853.2180706003731.034142662.17680509334False57.45399350333.5837564069452.87374245384.35705622388False55.4012731143.1709372815652.13869859297.12053426078False
5103961798998490676179.89993035-3.3664059622.42930030820.099186003208222.47970008850.17736199498222.83320045470.28619199991222.54640007020.15841899812222.01090049740.22023800015421.89430046080.11233299970621.10190010070.3786700069921.03820037840.31248700618720.30769920350.20190200209620.40850067140.2083400040863.875072896460.3540021886133.699303510480.604305030804False2.671282494420.7041302261623.478884192740.5076015205False5.696915804751.155600539426.342782447260.656240231893False13.1595173114.5896180769313.95467892884.01631245386False27.34766923855.0855347253924.92296636894.78242402933False
6103961798173977463179.81741758-3.3607251621.83099937440.11124899983421.92169952390.1360049992822.11989974980.25331199169222.07959938050.13395699858721.9820003510.25740000605622.08429908750.31011900305723.93099975592.41648006439nannan22.05509948730.49631801247621.04640007020.8230360150346.723574946520.6889251595666.184722104450.774730658954False5.152762198421.202185622515.347616415950.659783326313False5.850592628361.387024372385.324518802371.52084314359False0.9718519214732.1630123261nannanFalse5.469658414652.5003218842513.849687426610.4986749996False
7103961797997160472179.79969713-3.3667281623.70420074460.17348000407223.21890068050.84672302007721.83259963990.25791001319921.01810073850.19509300589621.67620086670.072420999407821.34280014040.45561000704821.50979995730.30472299456621.19790077210.41033500433nannannannan1.19762182590.1913571992191.872577185151.4603493948False6.713672375641.5947919240714.21542029392.55433047461False7.753890315890.51720158498310.54095462484.42332528827False9.038159830052.5366521966512.04591213884.55254175734FalsenannannannanFalse
8103961798641203102179.86410198-3.3644339815.20489978790.0028870000969615.26159954070.0021619999315614.83180046080.0018749999580914.91660022740.009087000042214.71720027920.0016179999802314.77379989620.0065620001405514.69849967960.0030110001098414.76150035860.0025639999657914.66189956670.0018299999646814.7440996170.004110000096263006.353772537.993970906332853.38375075.6818732273False4239.160069097.320769922793920.6665647632.813769204False4711.07359067.020597584414471.7760076227.0266337826False4792.9194267313.29188513484522.7216142410.6805483812False4957.242602238.355394014924595.7897606117.3971322645False
9103961799127698055179.91276548-3.360261422.27330017090.084201000630922.37899971010.15461200475722.07369995120.07884299755122.26889991760.088596001267421.90730094910.15384599566522.03240013120.10790199786421.52919960020.27177000045821.62999916080.32903501391422.29710006710.75403600931221.80089950561.444090008744.473834679080.346954771324.058823030420.577988246995False5.37675217590.3904440662284.492002951640.366547138663False6.267287539880.8880583400135.585215666070.555066623209False8.87810260532.222272720148.090965245792.45198681831False4.376832968893.039679114346.912580434179.19411943326False

II - Removal of duplicated sources

We remove duplicated objects from the input catalogues.

In [7]:
SORT_COLS = ['merr_ap_gpc1_r', 'merr_ap_gpc1_g', 'merr_ap_gpc1_i', 'merr_ap_gpc1_z', 'merr_ap_gpc1_y']
FLAG_NAME = 'ps1_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 1281409 sources.
The cleaned catalogue has 1280946 sources (463 removed).
The cleaned catalogue has 463 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_GAMA-12.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.001237971645196012 arcsec
Dec correction: -0.0002818848545582675 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 = "ps1_flag_gaia"

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

V - Flagging objects near bright stars

VI - Saving to disk

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