GAMA-15 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' means we take the forced photometry from chi-squared image priors. We also use an updated catalogue with significatnly fewer duplicates. See DMU_0 for details of how we reduced the duplicate sources.

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-15_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
0105082185240529323218.52402319-2.4259220721.78120040890.090591996908222.16939926150.1164589971320.70899963380.048948999494320.79290008540.055668998509620.11199951170.024847999215120.10860061650.029579000547519.89139938350.035555999726119.97260093690.036646999418719.7169990540.092211998999119.80890083310.09325399994857.039143785320.5873342799494.923118567970.528066991473False18.89731691820.85196086509917.49202002350.896869085099False32.74916228360.7494925149932.85184411690.894991537412False40.12732843451.3141012269637.23570879811.25682186216False47.11946799914.0018747803843.2951916823.71862869194False
1105082217622341208221.76228289-2.4327169822.65060043330.3016059994722.81979942320.28267100453421.788400650.10466399788921.92659950260.087260000407721.59140014650.078625999391121.76969909670.14826199412321.93140029910.53939497470921.93440055850.24564400315320.89590072630.20040600001821.41780090330.4369809925563.160529342260.8779615222832.704457934230.704104586029False6.992616972620.6740820144446.156873051560.494824380577False8.383781312740.6071301495727.114106482470.97146213682False6.129709323663.045246525926.112794228251.38299822563False15.90888379092.936473658449.837384325453.95929503672False
2105082217244896007221.72450612-2.428693923.10470008850.45595198869722.98629951480.35313600301722.57139968870.18321099877422.7169990540.22101899981522.48100090030.13278800249122.46019935610.14816600084322.54570007320.75909698009522.0919990540.53853398561521.06690025330.41618800163320.97769927980.5878909826282.080271238360.8736042917282.319958381940.754567109926False3.399696315010.5736768790352.97303744020.605209404058False3.694874058830.4518914848543.766346373420.513977960295False3.481127825672.433844987595.286891265182.62234105492False13.59063968725.20960906314.75435701847.98900636046False
3105082217220117288221.72205065-2.42763778nannannannan22.34309959410.22461099922722.35470008850.32017299532921.99300003050.20177699625522.12999916080.13960500061522.84009933470.7313950061822.7420997620.68480199575422.54820060732.1212799549122.14290046691.96917998791nannannannanFalse4.19527237520.8678943523234.150686806821.22399697255False5.791619048041.076334647265.105053945770.656412723566False2.654362701481.788084081522.905093369971.8323177664False3.473119745476.785680780275.044751907669.14957469134False
4105082217350769348221.73506236-2.4259106821.79689979550.12648099660921.87000083920.086740002036120.47260093690.010923000052620.55419921880.03702199831619.44580078120.012063000351219.54640007020.011278999969419.05159950260.014564000070119.1515998840.014235000126118.69519996640.02919900044818.89259910580.02975399978466.93809243840.8082413042196.486339321780.518196854367False23.49414394310.23636177406721.79316527660.743114694559False60.48945721410.67206411688255.13659874440.572777892847False86.9681434281.1665854389279.31586161771.0399038875False120.759140543.24760856577100.6839760482.75918863948False
5105082217294138282221.72941079-2.426803118.71820068360.010788000188818.79960060120.012347999960217.50160026550.0043950001709217.55590057370.0034670000895916.8563003540.0025299999397216.92180061340.0046080001629916.55470085140.0038880000356616.61440086360.0043350001797116.39999961850.0065999999642416.50830078120.00908000022173118.2278322091.17472538044109.6881620691.2474755976False362.5433085671.46755528289344.8575754321.10120786216False656.8706515861.53065054075618.4146291262.62462898384False867.2007792113.10542896674820.8043597253.27721138092False1000.000351356.07882674834905.0648270157.56904742972False
6105082217574685621221.7575098-2.4290117821.90220069890.17101599276121.84370040890.15253600478220.41069984440.038309998810320.48539924620.020276000723219.54750061040.017575999721919.6016006470.02666500024519.19659996030.028766000643419.27249908450.032620001584318.99449920650.038143999874619.12360000610.05403599888096.296797405720.9918183209086.645380250280.933615135233False24.87253566380.8776227664823.2188283810.433608991745False55.08073867660.89165217427552.40343327031.28699545513False76.0956823782.0161144471870.95783663022.1318665926False91.66431923033.2203437316681.38792900174.0505953667False
7105082217119592209221.71199673-2.4318837723.10050010680.42354100942623.07010078430.2491219937823.29570007320.99321001768122.65819931030.30533599853521.92379951480.11020699888521.98800086980.12790900468825.4022998813.5518200397522.48189926150.62213802337621.17880058290.56070399284420.71839904790.5020480155942.08833399050.8146500802652.147631109360.492773605157False1.744696824851.596014166853.138486579340.882620409443False6.172771404530.6265634399165.818347449570.68545105887False0.2506571212710.8199864594493.691818105982.11544978334False12.25969785186.3312446489718.73442554628.66286039606False
8105082217150679343221.71506117-2.42588373nannannannan22.71599960330.25499901175522.68110084530.29208898544321.2446002960.090481996536321.41990089420.053295001387620.48810005190.10656800121120.68390083310.10948500037220.07550048830.15228499472120.30439949040.154862001538nannannannanFalse2.975775464720.6988988663953.07297949150.826704919692False11.53877969390.9616072667789.818375609120.481949795373False23.16114253482.2733299809619.33925174341.95015877249False33.86879962474.7504264382727.43090928113.91255766978False
9105082217457776936221.7457281-2.4278889122.11940002440.1133389994522.42830085750.15038299560521.76250076290.14515000581721.81990051270.10772299766522.20879936220.18697699904422.01269912720.10932400077621.89459991460.51580101251621.64069938660.21317000687121.63520050050.23643800616321.06139945980.7869939804085.155134375480.5381397153273.878641652260.53722234553False7.161429069840.9573978159646.792658717080.673944145839False4.747667055390.8176060949135.687486111180.572679379491False6.341033304163.012436524048.011618216481.57297574012False8.052297274871.7535282551613.65967027019.90118799556False

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 1401806 sources.
The cleaned catalogue has 1401443 sources (363 removed).
The cleaned catalogue has 363 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-15.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.0005758271811373561 arcsec
Dec correction: -0.0002114812548081879 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)))
239049 sources flagged.

V - Flagging objects near bright stars

VI - Saving to disk

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