GAMA-09 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 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-09_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
0105121358456166697135.84567347-2.3948378722.94529914860.35381400585222.87490081790.27456501126321.8071002960.12325499951821.72859954830.17781099677121.62310028080.14529199898221.6767005920.10262099653521.5930004120.22825700044621.54439926150.30768999457421.39649963380.62468302249921.39800071721.215019941332.409241528540.7851109620732.570630599450.650070630782False6.87321424620.7802613700217.388566400781.21002537326False8.142539756151.089625521177.750322300110.732540551211False8.371433567771.759947128268.75468038262.48101476916False10.03229158965.7721223675910.018431039711.2113729291False
1105121358831250102135.88312345-2.4004067723.86930084230.657841980457nannan21.04969978330.10561600327521.10289955140.1423760056520.20649909970.049123000353620.2273998260.030719999223919.49589920040.047077998518919.61179924010.036040000617519.24099922180.089111000299519.44389915470.06156099960211.028678500410.623271010948nannanFalse13.80766007121.3431530282513.14740917931.72406114431False30.01928611371.3581912401229.44693309320.833176380973False57.76174698112.5045747087651.91349928561.72322018747False73.0466513085.995250170460.59549508263.43575099763False
2105121358528623398135.85285349-2.397555421.9076995850.097857996821421.91230010990.13844299316420.43169975280.051238998770720.26160049440.045496001839619.93440055850.026334000751419.81819915770.034138999879419.7546997070.051458001136819.51569938660.041301999241119.60770034790.09436099976319.6436996460.07276900112636.264986882520.5646666876816.238496791420.795475148442False24.39608281121.15132096728.53381244381.19566279336False38.56912413610.93547524668542.92599166581.34972972061False45.51139181722.1569928695456.71791342462.15758045735False52.10985453594.5288514373650.4103997773.37864245668False
3105121358539081217135.85393531-2.3994853522.72850036620.24690799415122.44680023190.17488700151422.0524005890.28812798857721.85580062870.1774639934320.16080093380.038688000291620.25810050960.030364999547619.55229949950.06339900195619.65360069270.037034001201419.31749916080.052978999912719.47209930420.04187599942092.941709977540.6689762271393.81311503370.614204676744False5.483271679651.455126975556.571730551191.07415184485False31.30975191481.1156592972628.62594260230.800587408212False54.83782233573.2021251481649.95278690891.7038683635False68.07698849033.3218481169659.04189367172.27719983397False
4105121358668173100135.86678869-2.3977578316.82010078430.0036039999686216.87240028380.0047760000452416.03479957580.0046310001052916.08799934390.0029140000697215.73789978030.0030819999519715.80000019070.0044909999705915.60219955440.0033859999384715.68330001830.0050260000862215.52330017090.0039750002324615.62559986110.00546899996698679.1405879422.25434377789647.2020533512.84695032047False1399.845706755.970774104181332.908269733.57738350614False1840.09433335.223341196511737.800523467.1881752359False2085.067784456.502536582011934.995648418.95732154193False2242.228826528.209047526982040.6102112610.2788293594False
5105121358649185834135.86483305-2.3954646721.49589920040.11953199654821.62159919740.11305399984120.18650054930.057918999344120.18729972840.046654999256119.58679962160.031077999621619.62630081180.040024999529119.40690040590.038722999393919.40439987180.042245998978619.2959995270.086843997240119.37240028380.0923359990129.15461995751.007859916958.153805000950.849027844188False30.57734548661.6311598023730.55484666671.31296749824False53.12270135921.5205786502451.22472968541.88836825423False62.69600056112.2360654283162.84056067922.44512640422False69.43847737635.5541253125764.72020533515.50410384188False
6105121358481655136135.8482132-2.3960464721.9920997620.19212700426621.85689926150.18567000329520.92460060120.081913001835320.87980079650.075438998639620.44029998780.037030000239620.53829956050.034726999700120.01580047610.030407000333119.9967994690.052235998213320.08180046080.15058200061320.30470085140.206091001635.796423322561.02570904756.565084123471.12268448403False15.49386471231.1689293983716.14654775521.12189258201False24.20360211310.82548540623522.11465536870.707331695295False35.78325221781.0021415490636.41499145681.75196647246False33.67284534394.6701255756327.42329650985.20540313654False
7105121358569169406135.85681371-2.3924845120.70590019230.027760000899420.67020034790.043014999479120.06049919130.039163000881720.00300025940.035608999431119.82570075990.027401000261319.8710994720.034798998385719.82859992980.052730001509219.70890045170.047765001654619.70919990540.11975499987619.68059921260.11717599630418.95133999440.48454607388519.58483246660.775917349589False34.34000258261.2386595800436.20761312511.18750472677False42.63042830981.0758749428640.88464312111.31039623044False42.51674692862.0648736957347.47225035642.08845583935False47.4591589795.2346707724548.72594996835.25865464222False
8105121358581688567135.8580989-2.3933063122.8351001740.26487299799922.66029930110.1935089975621.73250007630.12509700655921.80380058290.10810399800521.46820068360.093285001814421.41760063170.074282996356520.99130058290.1587429940721.16600036620.18628400564220.62199974060.19527700543420.86440086360.4883590042592.666612621840.6505389398963.132422101310.558286495469False7.362070457620.8482474585376.894134736420.686431496462False9.391170525410.806876804579.839199066880.673170135833False14.57067820462.1303453580112.40508811632.1283894693False20.47387765493.6823654775116.37720006927.36638704992False
9105121358794713499135.87934719-2.3974301822.24500083920.32732498645822.29640007020.27464899420721.93379974370.20401200652122.35040092470.22328500449723.58289909360.92783099412922.54689979550.15213200449922.44039916990.39018899202321.98579978940.22771500051nannannannan4.591976578941.384377406714.379655714931.10788240441False6.116177806791.14924205454.167154764990.856988250333False1.339184341151.144418628693.477283355850.487232612139False3.835662018041.378450023135.830154774471.2227774036FalsenannannannanFalse

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 1493855 sources.
The cleaned catalogue has 1493365 sources (490 removed).
The cleaned catalogue has 490 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-09.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.001187848795325408 arcsec
Dec correction: 3.903602401322814e-05 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)))
287193 sources flagged.

V - Flagging objects near bright stars

VI - Saving to disk

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