{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# CDFS SWIRE master catalogue\n", "## Preparation of PanSTARRS data\n", "\n", "The catalogue comes from `dmu0_PanSTARRS1-3SS`.\n", "\n", "In the catalogue, we keep:\n", "\n", "- The identifier (it's unique in the catalogue);\n", "- The position;\n", "- The stellarity;\n", "- The aperture magnitude\n", "- The kron magnitude to be used as total magnitude (no “auto” magnitude is provided).\n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This notebook was run with herschelhelp_internal version: \n", "04829ed (Thu Nov 2 16:57:19 2017 +0000)\n" ] } ], "source": [ "from herschelhelp_internal import git_version\n", "print(\"This notebook was run with herschelhelp_internal version: \\n{}\".format(git_version()))" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "#%config InlineBackend.figure_format = 'svg'\n", "\n", "import matplotlib.pyplot as plt\n", "plt.rc('figure', figsize=(10, 6))\n", "\n", "from collections import OrderedDict\n", "import os\n", "\n", "from astropy import units as u\n", "from astropy.coordinates import SkyCoord\n", "from astropy.table import Column, Table\n", "import numpy as np\n", "\n", "from herschelhelp_internal.flagging import gaia_flag_column\n", "from herschelhelp_internal.masterlist import nb_astcor_diag_plot, remove_duplicates\n", "from herschelhelp_internal.utils import astrometric_correction, mag_to_flux" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "OUT_DIR = os.environ.get('TMP_DIR', \"./data_tmp\")\n", "try:\n", " os.makedirs(OUT_DIR)\n", "except FileExistsError:\n", " pass\n", "\n", "RA_COL = \"ps1_ra\"\n", "DEC_COL = \"ps1_dec\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I - Column selection" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "imported_columns = OrderedDict({\n", " 'uniquePspsSTid':'ps1_id', \n", " 'raMean':'ps1_ra', \n", " 'decMean':'ps1_dec', \n", " 'gApMag':'m_ap_ps1_g', \n", " 'gApMagErr':'merr_ap_ps1_g', \n", " 'gKronMag':'m_ps1_g', \n", " 'gKronMagErr':'merr_ps1_g', \n", " 'rApMag':'m_ap_ps1_r', \n", " 'rApMagErr':'merr_ap_ps1_r', \n", " 'rKronMag':'m_ps1_r', \n", " 'rKronMagErr':'merr_ps1_r',\n", " 'iApMag':'m_ap_ps1_i', \n", " 'iApMagErr':'merr_ap_ps1_i', \n", " 'iKronMag':'m_ps1_i', \n", " 'iKronMagErr':'merr_ps1_i',\n", " 'zApMag':'m_ap_ps1_z', \n", " 'zApMagErr':'merr_ap_ps1_z', \n", " 'zKronMag':'m_ps1_z', \n", " 'zKronMagErr':'merr_ps1_z',\n", " 'yApMag':'m_ap_ps1_y', \n", " 'yApMagErr':'merr_ap_ps1_y', \n", " 'yKronMag':'m_ps1_y', \n", " 'yKronMagErr':'merr_ps1_y'\n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_PanSTARRS1-3SS/data/PanSTARRS1-3SS_CDFS-SWIRE.fits\")[list(imported_columns)]\n", "for column in imported_columns:\n", " catalogue[column].name = imported_columns[column]\n", "\n", "epoch = 2009\n", "\n", "# Clean table metadata\n", "catalogue.meta = None" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/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.\n", "Check the NumPy 1.11 release notes for more information.\n", " ma.MaskedArray.__setitem__(self, index, value)\n" ] } ], "source": [ "# Adding flux and band-flag columns\n", "for col in catalogue.colnames:\n", " if col.startswith('m_'):\n", " \n", " errcol = \"merr{}\".format(col[1:])\n", " \n", " # -999 is used for missing values\n", " catalogue[col][catalogue[col] < -900] = np.nan\n", " catalogue[errcol][catalogue[errcol] < -900] = np.nan \n", " \n", " flux, error = mag_to_flux(np.array(catalogue[col]), np.array(catalogue[errcol]))\n", " \n", " # Fluxes are added in µJy\n", " catalogue.add_column(Column(flux * 1.e6, name=\"f{}\".format(col[1:])))\n", " catalogue.add_column(Column(error * 1.e6, name=\"f{}\".format(errcol[1:])))\n", " \n", " # Band-flag column\n", " if \"ap\" not in col:\n", " catalogue.add_column(Column(np.zeros(len(catalogue), dtype=bool), name=\"flag{}\".format(col[1:])))\n", " \n", "# TODO: Set to True the flag columns for fluxes that should not be used for SED fitting." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<Table masked=True length=10>\n", "
idx | ps1_id | ps1_ra | ps1_dec | m_ap_ps1_g | merr_ap_ps1_g | m_ps1_g | merr_ps1_g | m_ap_ps1_r | merr_ap_ps1_r | m_ps1_r | merr_ps1_r | m_ap_ps1_i | merr_ap_ps1_i | m_ps1_i | merr_ps1_i | m_ap_ps1_z | merr_ap_ps1_z | m_ps1_z | merr_ps1_z | m_ap_ps1_y | merr_ap_ps1_y | m_ps1_y | merr_ps1_y | f_ap_ps1_g | ferr_ap_ps1_g | f_ps1_g | ferr_ps1_g | flag_ps1_g | f_ap_ps1_r | ferr_ap_ps1_r | f_ps1_r | ferr_ps1_r | flag_ps1_r | f_ap_ps1_i | ferr_ap_ps1_i | f_ps1_i | ferr_ps1_i | flag_ps1_i | f_ap_ps1_z | ferr_ap_ps1_z | f_ps1_z | ferr_ps1_z | flag_ps1_z | f_ap_ps1_y | ferr_ap_ps1_y | f_ps1_y | ferr_ps1_y | flag_ps1_y |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1046450000001079 | 54.05465606 | -30.42713339 | 22.1590995789 | 0.0301580000669 | nan | nan | 22.2444000244 | 0.0264989994466 | nan | nan | 21.0310001373 | 0.00628999993205 | 21.2486000061 | 0.0990689992905 | 19.5762004852 | 0.0120050003752 | 19.7898006439 | 0.105898998678 | 20.3708000183 | 0.0105200000107 | nan | nan | 4.97004325477 | 0.138050627908 | nan | nan | False | 4.59451834835 | 0.11213602221 | nan | nan | False | 14.0475292502 | 0.0813816078361 | 11.4963505394 | 1.04899508595 | False | 53.643833504 | 0.593140616036 | 44.0635762857 | 4.29781063427 | False | 25.803581683 | 0.250018078417 | nan | nan | False |
1 | 1046450000001149 | 54.07805742 | -30.42892981 | 22.7385997772 | 0.0393819995224 | nan | nan | 20.4309997559 | 0.0114959999919 | 20.3773994446 | 0.103018000722 | 20.0034008026 | 0.00391899980605 | nan | nan | 18.5713996887 | 0.00755799980834 | 18.658000946 | 0.0488420017064 | 19.6877994537 | 0.00768100004643 | 19.7733001709 | 0.148917004466 | 2.91447335426 | 0.105714249688 | nan | nan | False | 24.4118165498 | 0.258477373812 | 25.6472155711 | 2.43348693784 | False | 36.1942580957 | 0.130644340527 | nan | nan | False | 135.344348071 | 0.942155702554 | 124.968230831 | 5.62171411136 | False | 48.403884783 | 0.342431466903 | 44.7383467908 | 6.13620560838 | False |
2 | 1046450000001152 | 54.08000797 | -30.4306695 | 18.0242996216 | 0.00449200021103 | 17.9810009003 | 0.0177950002253 | 17.5765991211 | 0.00308799999766 | 17.4195995331 | 0.0121109997854 | 17.3561992645 | 0.00115799997002 | 17.0153007507 | 0.00570000009611 | 16.2189006805 | 0.0025579999201 | 15.8955001831 | 0.00962799973786 | 17.2120990753 | 0.00245600007474 | 16.8269996643 | 0.0173359997571 | 224.016574159 | 0.926820432058 | 233.130792435 | 3.82096727154 | False | 338.345458575 | 0.962306286471 | 390.985081569 | 4.36129901372 | False | 414.495952607 | 0.442083720326 | 567.387416382 | 2.97872384999 | False | 1181.51632808 | 2.78365836892 | 1591.47538825 | 14.1127509184 | False | 473.326009556 | 1.07069167423 | 674.838939521 | 10.7751842854 | False |
3 | 1046450000001041 | 54.04404335 | -30.42104699 | 22.1615009308 | 0.030191000551 | nan | nan | 20.7297000885 | 0.0131909996271 | 20.638999939 | 0.11007399857 | 20.125 | 0.00414399988949 | 20.1692008972 | 0.0431739985943 | 19.0300006866 | 0.00933500006795 | 19.053899765 | 0.06603500247 | 19.5473003387 | 0.00719900010154 | 19.8073997498 | 0.147862002254 | 4.95906302371 | 0.137896363615 | nan | nan | False | 18.5404369276 | 0.225254436139 | 20.1557992613 | 2.0434332109 | False | 32.359365693 | 0.123508092728 | 31.0684538774 | 1.23542843846 | False | 88.7155450979 | 0.762763197808 | 86.7840860216 | 5.27825019529 | False | 55.0908996397 | 0.365281539256 | 43.355090798 | 5.904353659 | False |
4 | 1046450000001021 | 54.03739504 | -30.42387156 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 19.4244003296 | 0.0111940000206 | 19.1714000702 | 0.0929569974542 | nan | nan | nan | nan | nan | nan | nan | nan | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False | 61.6935651741 | 0.636064052027 | 77.8825158092 | 6.66803298267 | False | nan | nan | nan | nan | False |
5 | 1046450000001120 | 54.06711346 | -30.42416006 | 23.7001991272 | 0.0613240003586 | nan | nan | 21.9192008972 | 0.0228140000254 | nan | nan | 21.4762992859 | 0.0077220001258 | 21.7397994995 | 0.165432006121 | 20.5324001312 | 0.0186470001936 | 21.1284008026 | 0.420482993126 | 22.9029006958 | 0.0337609983981 | nan | nan | 1.20204395602 | 0.0678932356377 | nan | nan | False | 6.19897152058 | 0.130255706504 | nan | nan | False | 9.32138155919 | 0.066295762504 | 7.31274113778 | 1.11423146006 | False | 22.2351440575 | 0.381877967896 | 12.8422073857 | 4.97351914419 | False | 2.50518453285 | 0.0778987848336 | nan | nan | False |
6 | 1046450000001130 | 54.0699512 | -30.42341408 | nan | 0.129620999098 | nan | nan | 21.8952999115 | 0.0225639995188 | nan | nan | 20.1690006256 | 0.00422899983823 | 20.242099762 | 0.0504840016365 | 18.9230003357 | 0.0088860001415 | 18.964799881 | 0.071994997561 | 19.9060001373 | 0.00849299971014 | 20.1284008026 | 0.202264994383 | nan | nan | nan | nan | False | 6.33694642432 | 0.131695761311 | nan | nan | False | 31.0741851987 | 0.121035591889 | 29.0509336997 | 1.35079532027 | False | 97.9038714744 | 0.801275495799 | 94.2063218249 | 6.24680643446 | False | 39.5913166651 | 0.3096968117 | 32.2581664829 | 6.00946881376 | False |
7 | 1046450000001263 | 54.10597218 | -30.41976053 | 21.2220993042 | 0.0195889994502 | 21.2371006012 | 0.178812995553 | nan | 0.0335969999433 | nan | nan | 21.3563995361 | 0.00730699999258 | nan | nan | 18.6639003754 | 0.00788700021803 | nan | nan | nan | nan | nan | nan | 11.7804065448 | 0.21254368816 | 11.618759428 | 1.91352666405 | False | nan | nan | nan | nan | False | 10.4097472652 | 0.0700575543638 | nan | nan | False | 124.291047979 | 0.902874490335 | nan | nan | False | nan | nan | nan | nan | False |
8 | 1046450000001264 | 54.10597218 | -30.41976053 | nan | 0.0774419978261 | nan | nan | 19.904499054 | 0.0090210000053 | 20.0118999481 | 0.083400003612 | 19.2250003815 | 0.00273799989372 | 19.3160991669 | 0.0333469994366 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | False | 39.6460914513 | 0.329405420603 | 35.9120354212 | 2.7585557806 | False | 74.1309980844 | 0.186942890904 | 68.1648264394 | 2.09359549669 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
9 | 1046450000000997 | 54.03174085 | -30.42000016 | 18.572599411 | 0.00578199978918 | 18.5193996429 | 0.026651000604 | 18.0767993927 | 0.00388800003566 | 17.8616008759 | 0.0173179991543 | 17.6497993469 | 0.00132599996869 | 17.1662998199 | 0.00696399994195 | 16.551700592 | 0.00298199988902 | 16.1082000732 | 0.0139720002189 | 17.602399826 | 0.00294000003487 | 17.1359996796 | 0.0226499997079 | 135.194877185 | 0.719969314788 | 141.984240551 | 3.48521313382 | False | 213.442177531 | 0.764332247757 | 260.231370938 | 4.15081181053 | False | 316.286212937 | 0.386277538331 | 493.719262994 | 3.16675533501 | False | 869.600464751 | 2.38837802222 | 1308.338046 | 16.8365938107 | False | 330.400023532 | 0.894670433249 | 507.691775724 | 10.5911717059 | False |