SPIRE-NEP 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: 
04829ed (Thu Nov 2 16:57:19 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_SPIRE-NEP_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
0190652646414518463264.6413490268.8814661122.05299949650.31444400548922.26239967350.2790560126321.09580039980.12238799780620.98410034180.089162997901419.49550056460.031477000564319.63769912720.02768299914919.05349922180.040991000831119.14410018920.039912998676318.69910049440.048124000430118.93869972230.07912100106485.480247863381.587154487144.518976996711.16146785595False13.23365596431.4917441732414.66762720361.20453716827False57.78295851611.6752082226350.68977332211.29243636308False86.81610778643.2776646213279.86563045672.93595883487False120.3260893715.3333146221496.4983996757.03214091045False
1190652647080590904264.7083008668.8751421.59970092770.14650399982921.62039947510.13722400367321.23250007630.0801120027921.3530998230.062968000769621.65629959110.17958299815721.38629913330.090963996946821.16939926150.087444998323921.26639938350.16868500411521.56489944461.0613700151422.99519920356.889039993298.319929167631.122651060198.162819813391.03168229183False11.66809535070.86094069921610.44143215210.605557873917False7.897327774851.3062342335310.12698919670.848448647404False12.36631473160.99598076055511.30941775371.75708350883False8.590930826968.398132384242.3010196032614.6000621539False
2190652648134289545264.8136116568.88225324nannannannan20.81040000920.084954001009520.8092994690.086439996957820.29330062870.039576001465320.29330062870.054301001131519.96459960940.10122899711120.08349990840.14417299628319.68029975890.11949899792719.46389961240.118602000177nannannannanFalse17.21234317491.3467888544617.22979905291.37173631236False27.71275794911.0101534280627.71275794911.38600011141False37.51113078123.4973634782133.62018018044.46436444776False48.73939078395.3643862410759.48947757196.49842107004False
3190652649235243252264.9233420168.8770934322.54470062260.064453996717922.64080047610.19054700434222.62789916990.31824299693122.32390022280.13802699744722.01749992370.14852400124122.24090003970.1644050031921.42119979860.21484200656421.85370063780.42788699269320.35000038150.55002498626720.63459968570.8549299836163.484333777010.2068451220873.189185710860.559702974656False3.227307386970.9459645633494.270118338710.542849736845False5.662393288280.7745908297874.609353158960.697960257273False9.806636564281.940505868636.584453649882.59492320365False26.302670677613.324715538520.237652096915.9355242091False
4190652651323768747265.1323402768.8816690219.67020034790.013106999918819.75189971920.021460000425618.77230072020.013357999734618.84309959410.011074000038218.4335994720.0095539996400518.51609992980.0088229998946218.31349945070.029139000922418.40469932560.021168999373918.34860038760.048794001340918.47750091550.044394001364749.19487493630.59388018836545.62891189040.901873276672False112.481140681.38387486829105.3804775581.07483144376False153.6597814591.35213829134142.4164080651.15731606613False171.6327731854.60628236789157.8048220283.07677883825False166.1727644977.46795958183147.5705288916.03392079244False
5190652651676001023265.1672435768.8752238324.93479919433.16834998131nannan21.46689987180.095072001218821.59539985660.1271219998620.82990074160.099811002612120.94729995730.092242002487220.63649940490.11472599953420.79120063780.18085099756721.36759948730.49904501438120.74799919130.4157440066340.3855496580391.1250948863nannanFalse9.402428753730.8233194343318.352953377510.977994593375False16.90595479471.55415310915.17329903911.28909350317False20.20227311452.1347045127217.51942083132.91820860376False10.30291709264.7356064816718.23057318596.98074864441False
6190652645689133416264.5687339368.8770966621.71240043640.32094600796721.74010086060.51876997947722.38599967960.50054001808222.35149955750.37688899040221.94050025940.21653699874921.97960090640.25102400779725.53089904796.72490978241nannan20.62039947510.21232199668920.1795997620.5256630182277.499629788822.216907045567.310711667113.49309318865False4.032739119951.859150780064.162940244521.44507140776False6.07854864011.212293256425.863536560891.35565935899False0.2226590649141.37912148201nannanFalse20.50407633214.0096907591530.772309741214.8985224454False
7190652646850983471264.684868168.8772910822.51670074460.8912609815621.73220062260.39589199423822.74959945680.39526799321222.71170043950.67638802528421.94820022580.29638600349422.00869941710.18103100359421.36560058590.22938600182521.46689987180.35496601462420.03730010990.22858999669619.85729980470.3648410141473.575359383072.934947088647.364101248842.68517225123False2.885095658811.050334295092.98758193151.86119301739False6.035592492611.647605679695.708476705230.951806951278False10.32190281342.180732306099.402428753733.07399039275False35.08164552887.3860604448541.40760178913.9142375136False
8190652654718150071265.4717424668.8743988821.77239990230.10310599952922.02700042720.17251199483921.13999938960.067998997867121.33099937440.087021000683320.13479995730.035110000520920.15780067440.040116000920519.47220039370.067555002868219.60079956050.059220999479320.0671997070.22058999538419.85370063780.1322049945597.096431893290.6739065163745.613061867970.891856139412False12.70574819470.79575327837810.65614816170.854082854013False32.06860121741.0370185690731.39639108851.16004020893False59.03639672293.6732715851852.44211225112.86043174088False34.12872918246.9339644195641.54509389785.05875081687False
9190652647959247381264.7958443168.880526516.00410079960.0070699998177616.04750061040.0024339999072315.51970005040.0022950000129615.57170009610.002461999887615.34459972380.0018250000430315.40830039980.0025059999898115.28479957580.002964999992415.34210014340.0030129998922315.24009990690.0059259999543415.31459999080.004935000091791439.990676499.376802372171383.565601193.10167288351False2249.676024124.755304724932144.469933244.86276934624False2643.383108444.443228719372492.756400775.75355918643False2793.059385457.627470669512649.475711867.35249501614False2910.4492929715.885370962717.4402493412.3515894755False

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 2675 sources.
The cleaned catalogue has 2674 sources (1 removed).
The cleaned catalogue has 1 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_SPIRE-NEP.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.00015501241250603925 arcsec
Dec correction: -0.0003735176392183348 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)))
730 sources flagged.

V - Flagging objects near bright stars

VI - Saving to disk

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