HATLAS-NGP 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.

We take the 'F' photometry from the chi-squared image priors.

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_HATLAS-NGP_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
0134401930513647968193.0512400822.0062368522.52079963680.40596699714722.10499954220.31716400384921.47290039060.094558998942421.56710052490.10325899720221.34709930420.083608999848421.37919998170.10428299754920.88269996640.10100899636720.95199966430.14243100583621.16760063170.42330500483520.97349929810.4398210048683.561887064011.331823134585.22396409251.52601834615False9.350607850190.8143636676598.57353233320.815386230398False10.49929838460.80851668499210.19342207690.979059742869False16.1034902041.4981515550415.10776199031.98189369276False12.3868177374.8293516593414.81154221686.00000935116False
1134401930474188089193.0474688922.0063981821.89310073850.38648900389721.91500091550.32586801052121.67630004880.15131999552222.10569953920.21552500128721.99889945980.17358499765422.06509971620.14540199935421.30900001530.16103799641121.48340034480.20740999281421.08550071720.34046098589921.11890029910.8390790224086.34979500082.260333526746.222997604261.86774267993False7.753182029451.080567696685.220597178541.03631914336False5.760235190870.9209331030065.419511142410.72578196451False10.87426704261.612887337939.26061569951.76907081782False13.35979250824.1893123843512.955073472910.0119442801False
2134401930485253929193.0485294422.0028491723.60400009160.343982994556nannan21.5991992950.2361399978421.83900070190.33493301272422.45770072940.26262798905422.15150070190.12778300046921.66110038760.22580699622621.97949981690.1924719959521.09860038760.35600098967621.5014991760.3915480077271.313408925780.41611427655nannanFalse8.323774035951.810362382926.674207723862.05889100013False3.775023923660.9131379587025.0049497240.589045009393False7.862485272661.635207681685.864082521721.03954502247False13.19957186824.32799489.107524109653.28443769751False
3134401930567563684193.0567469622.0026140923.80089950561.4673399925223.413400650.45441800355922.69339942930.27453100681322.53969955440.64111799001721.95170021060.057999998331122.21349906920.27233600616522.91629981990.54549002647423.54310035711.3317600488720.90419960020.31264799833320.69599914550.3793259859091.095570167251.480630298571.565451943050.655195565472False3.038366984380.7682583887643.500420174592.06696832685False6.016167452160.3213835005744.727160764261.18571719115False2.474457916081.243204480281.389184270351.7039683338False15.78774706324.5462309314819.12495147016.68172530312False
4134401930438914631193.0438748522.0034205122.84110069270.26126301288623.00020027160.20008400082621.37310028080.14333400130321.50090026860.18321800231921.05820083620.071157000958921.26280021670.095202997326920.73590087890.11083400249520.87509918210.11514499783520.65500068660.14007699489620.63660049440.1504209935672.651915751590.6381361293332.290445125240.422092790424False10.25085021561.353271053979.112549334831.53774284936False13.69997155780.89786900814511.34697017470.994961360299False18.43485170781.8818644816416.21661951581.71981242853False19.8609366132.562372245120.2003922322.79862001162False
5134401930589721835193.0589653922.0010690222.7201995850.47110900282922.80150032040.27077901363421.50830078120.16309900581821.72750091550.16332900524121.54389953610.092422999441621.59070014950.082864999771121.3455009460.10588700324321.36680030820.14417099952721.54019927980.36941000819221.05680084230.3503679931162.964286430841.286225897612.750425411290.685946988485False9.050648270151.359585991897.3960465141.11259891174False8.758710774690.7455828750038.389188255540.640275307969False10.51476622811.0254581921610.31050356421.36909462718False8.788611927982.9902302143813.7176482714.42669671871False
6134411930372418027193.037235822.0145842221.63319969180.082167997956321.67989921570.10825499892220.91010093690.11040499806421.00399971010.14375099539820.40950012210.051463998854220.49670028690.050884999334820.22389984130.051993001252420.24279975890.062812998890920.07169914250.14839899539920.00250053410.1590819954878.067149833440.6105180504457.727523130970.770484584146False15.70216820281.5967026266914.40124755721.90671883487False24.90003463431.1802639980822.9784052931.07692470135False29.54201154161.4146878738629.03220998861.67959783032False33.98758783994.6454413782936.22428202355.30757935872False
7134411930551548243193.0550901522.0147341921.64030075070.1342210024621.54350090030.12142000347421.36409950260.084523998200921.2618007660.18626600503920.68350028990.059601999819320.62610054020.057257000356920.29249954220.064406998455520.12000083920.058111999183919.92779922490.11692000180520.07530021670.2025739997638.014560279860.990776866728.761927188840.979863455822False10.3361832180.80466648150411.35742018861.94844869022False19.3463875791.0620290489820.39669416281.07563284695False27.73321273931.6451629615332.50870461051.73996759758False38.80434079354.1787347384533.8750475376.32032333604False
8134411930323325204193.032308822.0121832525.523199081411.734999656722.52560043330.95338702201822.34860038760.70000100135821.99430084230.54726499319121.90880012510.15298800170422.05010032650.11565800011221.55979919430.11825899779821.67460060120.098640002310320.76659965520.15221999585620.83709907530.1636340022090.224243760312.423701483583.546172247383.11390058071False4.174071124252.691126955075.784684311152.9157683112False6.258639690280.8818871245215.494900963430.585344076633False8.631381694190.9401349464937.765327193370.70548618434False17.92091326642.5125084078316.79424056632.5311017408False
9134411930462693001193.0462198522.010356722.91609954830.26044699549723.44190025330.46372601389922.44529914860.22338099777722.37999916080.14948199689421.93289947510.1089410036821.98299980160.096978001296521.4389991760.156326994321.4507999420.17600500583620.91329956050.22896100580720.5790004730.2710399925712.474914389180.5936838192831.524894853480.65129394131False3.818390497570.7856013970164.055088488910.558296501717False6.121251309890.6141963937055.845209471510.522094344116False9.647178840291.389024760319.542892316191.54696583797False15.65597704143.3015462085321.30099109395.31751676194False

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 3268686 sources.
The cleaned catalogue has 3267763 sources (923 removed).
The cleaned catalogue has 923 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_NGP.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.0005492394507200515 arcsec
Dec correction: -0.00028873116377781116 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)))
427003 sources flagged.

V - Flagging objects near bright stars

VI - Saving to disk

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