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

TODO: Check if the detection flag can be used to know in which bands an object was detected to construct the coverage maps.

TODO: Check for stellarity.

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: 
255270d (Fri Nov 24 10:35:51 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_xFLS_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
0177552612341048445261.2341137557.9647917522.03980064390.13769100606422.20140075680.19653999805520.84379959110.04255500063321.02169990540.073224999010620.30949974060.034687001258120.39039993290.037891998887119.84440040590.038633000105620.01630020140.029649000614919.46990013120.12248700112119.56150054930.1193500012165.547275592060.703494968524.780129883970.865299244861False16.69091569620.65419383170814.16837483240.955553686557False27.30235465240.87225313665225.34194983330.884429505684False41.90249063091.4909873299635.76678626290.976710054665False59.1616050026.6742985510254.37506389255.97720138027False
1177552612648369712261.2647541757.965804220.79610061650.051486000418720.93580055240.067335002124321.12260055540.064085997641121.14340019230.092320002615521.43910026550.079793997108921.52370071410.079028002917821.35869979860.15938299894321.61269950870.29500499367721.46969985960.26760300993921.81489944460.029433999210617.44053300590.82703633323715.33485871540.951034643269False12.91099692920.76207656622812.6660128151.07698935624False9.646280663670.7089339823218.92318124540.649495881603False10.38771631221.524887325998.220915732282.23370205672False9.378212219322.311461851176.824018918420.184997208878False
2177552612486770901261.2487046257.95851154nannan23.83720016481.0517599582722.5118007660.18335400521822.45520019530.16692200303121.42259979250.11452800035521.45980072020.095135003328320.68129920960.081458002328920.75620079040.089098997414120.14879989620.29781699180620.33900070190.304345995188nannan1.059546287421.02638960933False3.591531613960.6065209057223.783728113720.581713562556False9.793999623971.03311208339.464108529530.82926957074False19.38564771011.4544197102418.09337914311.48480075954False31.65774973318.6837076552626.57049952637.44805698247False
3177552612316205951261.2316110657.9627644222.27020072940.083530999720122.22360038760.1312689930221.72260093690.12505699694221.88710021970.19793500006221.28549957280.092711001634621.39179992680.097438000142621.48069953920.13759200274921.4235000610.18140700459521.48780059810.73706799745620.7866992950.6062470078474.48662434190.3451779677294.683384830980.566236262541False7.429500653590.8557428926496.384985452531.16401395698False11.11220311040.94887089167710.07581138980.904240742211False9.283680470711.176492211699.785882021061.63504499249False9.223160383496.2612781302517.5922051959.82303225607False
4177552612442940878261.2442687257.9584864621.69669914250.052900001406721.86459922790.063777998089820.24690055850.028863999992620.31229972840.019190000370119.83709907530.016324000433119.90530014040.027813000604519.66480064390.026706999167819.77029991150.05070599913619.31649971010.11133500188619.50279998780.1113729998477.60887313460.3707248572536.518689706210.38291896117False28.92276284870.76890373830527.23203575620.481316524172False42.1852250060.63425317148839.61685024911.01485376936False49.44014575511.2161314375944.86214506972.09514970503False68.13968412326.9872698608757.39578563345.88756347679False
5177552613129964798261.3129792557.9617219323.50130081180.88868397474323.2320003510.603830993176nannan23.16370010381.34449005127nannannannan21.6889991760.31855300068922.02179908750.51770102977821.46990013120.69336998462721.06749916080.7272080183031.443709038041.181687670241.850119836741.02894210732Falsenannan1.970243749932.43979440746FalsenannannannanFalse7.663026538272.24831785795.640016376192.68927412858False9.376482502285.9879844661813.58314496519.09776416143False
6177552612323813901261.2323899357.9609971324.79229927062.3805999755924.94560050963.6827099323323.0305004120.21980300545722.98430061340.33793801069320.93059921260.076141998171820.96059989930.056788999587320.02269935610.046528000384620.10079956050.085651002824319.32229995730.047460999339819.44029998780.06260500103240.4396228847810.9639231188840.3817330797611.2948008901False2.227408308020.4509300125922.324233489850.72342327584False15.40849830551.0805883092714.98856447010.783970892542False35.55660257691.523738096933.08873588492.61028728554False67.77663719582.9627334145360.79669974163.50561898314False
7177612606068780030260.6069154458.0078021724.2852001190.341645002365nannan22.57250022890.16328200697922.39159965520.21533299982522.28650093080.1905429959322.24049949650.15440699458121.54870033260.26615899801321.57659912110.24158099293721.48649978640.42138698697122.1544990541.392609953880.70132602060.220683927566nannanFalse3.396252009950.5107565189044.011992735180.795694596127False4.419769572150.7756544655194.611053927260.655756873208False8.720067906112.137650495888.498853665571.89103163214False9.234217199583.583908269544.991147200646.40185087541False
8177612606145048024260.6145173458.0144266821.09779930110.068980000913121.09140014650.080626003444219.5664005280.016638999804919.53470039370.032216999679818.99970054630.026760999113318.913400650.016666999086718.70919990540.033780001103918.55450057980.034196000546218.45800018310.043239001184718.55509948730.07274600118413.20931447380.83922643499813.28739792960.986712782115False54.13021958030.82955022507855.7339524231.65379096644False91.22624130962.2485253343398.773340091.51625704463False119.212017493.70898756509137.4674156314.3296297935False150.2449649625.98344440344137.3916075679.20544972431False
9177612605886391369260.5887052158.0089166922.65959930420.34488099813522.80229949950.46148398518623.211599350.4284340143223.10680007930.36498299241122.9734001160.5515429973621.8850994110.45537999272321.92880058290.41931098699621.57309913640.30865299701721.20389938350.49249500036221.3983993531.076230049133.134442290830.995646623112.748401647461.16818739174False1.885212279920.7439091202752.076251543240.697956370918False2.347685694491.192600559076.396762634512.68293321084False6.144404051462.372966947248.526294819352.42385437449False11.97954288525.4339764592310.01475337589.92706927384False

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 168951 sources.
The cleaned catalogue has 168911 sources (40 removed).
The cleaned catalogue has 40 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_xFLS.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.00047764447117515374 arcsec
Dec correction: -0.001210390917094628 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)))
39668 sources flagged.

V - Saving to disk

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