{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# SPIRE-NEP master catalogue\n", "\n", "This notebook presents the merge of the various pristine catalogues to produce HELP mater catalogue on SPIRE-NEP." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This notebook was run with herschelhelp_internal version: \n", "0246c5d (Thu Jan 25 17:01:47 2018 +0000) [with local modifications]\n", "This notebook was executed on: \n", "2018-02-20 16:17:05.784701\n" ] } ], "source": [ "from herschelhelp_internal import git_version\n", "print(\"This notebook was run with herschelhelp_internal version: \\n{}\".format(git_version()))\n", "import datetime\n", "print(\"This notebook was executed on: \\n{}\".format(datetime.datetime.now()))" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "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", "import os\n", "import time\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", "from pymoc import MOC\n", "\n", "from herschelhelp_internal.masterlist import merge_catalogues, nb_merge_dist_plot, specz_merge\n", "from herschelhelp_internal.utils import coords_to_hpidx, ebv, gen_help_id, inMoc" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "TMP_DIR = os.environ.get('TMP_DIR', \"./data_tmp\")\n", "OUT_DIR = os.environ.get('OUT_DIR', \"./data\")\n", "SUFFIX = os.environ.get('SUFFIX', time.strftime(\"_%Y%m%d\"))\n", "\n", "try:\n", " os.makedirs(OUT_DIR)\n", "except FileExistsError:\n", " pass" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I - Reading the prepared pristine catalogues" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "ps1 = Table.read(\"{}/PS1.fits\".format(TMP_DIR))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## II - Merging tables\n", "\n", "We first merge the optical catalogues and then add the infrared ones: DECaLS, HSC, KIDS, PanSTARRS, UKIDSS-LAS, and VISTA-VIKING.\n", "\n", "At every step, we look at the distribution of the distances separating the sources from one catalogue to the other (within a maximum radius) to determine the best cross-matching radius." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### DECaLS" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": true }, "outputs": [], "source": [ "master_catalogue = ps1\n", "master_catalogue['ps1_ra'].name = 'ra'\n", "master_catalogue['ps1_dec'].name = 'dec'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Cleaning\n", "\n", "When we merge the catalogues, astropy masks the non-existent values (e.g. when a row comes only from a catalogue and has no counterparts in the other, the columns from the latest are masked for that row). We indicate to use NaN for masked values for floats columns, False for flag columns and -1 for ID columns." ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": true }, "outputs": [], "source": [ "for col in master_catalogue.colnames:\n", " if \"m_\" in col or \"merr_\" in col or \"f_\" in col or \"ferr_\" in col or \"stellarity\" in col:\n", " master_catalogue[col].fill_value = np.nan\n", " elif \"flag\" in col:\n", " master_catalogue[col].fill_value = 0\n", " elif \"id\" in col:\n", " master_catalogue[col].fill_value = -1\n", " \n", "master_catalogue = master_catalogue.filled()" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<Table length=10>\n", "
idx | ps1_id | ra | dec | m_ap_gpc1_g | merr_ap_gpc1_g | m_gpc1_g | merr_gpc1_g | m_ap_gpc1_r | merr_ap_gpc1_r | m_gpc1_r | merr_gpc1_r | m_ap_gpc1_i | merr_ap_gpc1_i | m_gpc1_i | merr_gpc1_i | m_ap_gpc1_z | merr_ap_gpc1_z | m_gpc1_z | merr_gpc1_z | m_ap_gpc1_y | merr_ap_gpc1_y | m_gpc1_y | merr_gpc1_y | f_ap_gpc1_g | ferr_ap_gpc1_g | f_gpc1_g | ferr_gpc1_g | flag_gpc1_g | f_ap_gpc1_r | ferr_ap_gpc1_r | f_gpc1_r | ferr_gpc1_r | flag_gpc1_r | f_ap_gpc1_i | ferr_ap_gpc1_i | f_gpc1_i | ferr_gpc1_i | flag_gpc1_i | f_ap_gpc1_z | ferr_ap_gpc1_z | f_gpc1_z | ferr_gpc1_z | flag_gpc1_z | f_ap_gpc1_y | ferr_ap_gpc1_y | f_gpc1_y | ferr_gpc1_y | flag_gpc1_y | ps1_flag_cleaned | ps1_flag_gaia |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | |||||||||||||||||||||||||||||||||||||||||||||||||
0 | 190582648149477540 | 264.814910507 | 68.8223297362 | 14.2279996872 | 0.00633599981666 | 14.305100441 | 0.000615000026301 | 13.748000145 | 3.70000016119e-05 | 13.8243999481 | 0.00379400001839 | 13.5951004028 | 0.0022450000979 | 13.6630001068 | 0.00166599999648 | 13.5431003571 | 0.0016680000117 | 13.6027002335 | 0.00132399995346 | 13.5167999268 | 0.00312400003895 | 13.5798997879 | 0.00324900005944 | 7392.64965642 | 43.1410748416 | 6885.8859237 | 3.90041338367 | False | 11502.7039422 | 0.391992145547 | 10721.1166356 | 37.4639037866 | False | 13242.1907313 | 27.381162531 | 12439.4150118 | 19.0875695911 | False | 13891.8427035 | 21.3418265787 | 13149.8229838 | 16.0355387821 | False | 14232.4618806 | 40.9512101325 | 13428.8890239 | 40.1851398577 | False | False | 3 |
1 | 190632649450999463 | 264.945037767 | 68.8656346562 | 14.2491998672 | 0.000959999975748 | 14.3062000275 | 0.00042699999176 | 13.9289999008 | 0.00045299998601 | 14.0030002594 | 0.00479699997231 | 13.8473997116 | 0.00335499993525 | 13.899600029 | 0.00277099991217 | 13.795999527 | 0.00254400004633 | 13.8442001343 | 0.0031429999508 | 13.7894001007 | 0.00314199994318 | 13.8352003098 | 0.00204900000244 | 7249.70029559 | 6.41013174052 | 6878.91572756 | 2.70535047658 | False | 9736.43658741 | 4.06231791715 | 9094.94121263 | 40.1832715479 | False | 10496.3937834 | 32.4345824605 | 10003.6845478 | 25.5312560102 | False | 11005.2570089 | 25.7865347197 | 10527.3714341 | 30.4747394022 | False | 11072.3539319 | 32.0421620577 | 10614.9970082 | 20.0326090265 | False | False | 3 |
2 | 190692655307894027 | 265.530709447 | 68.9110899862 | 15.5255002975 | 0.00400999980047 | 15.5634002686 | 0.00243099988438 | 14.5818996429 | 0.000727000006009 | 14.6403999329 | 0.00201299996115 | 14.1426000595 | 0.00152100005653 | 14.1857995987 | 0.00115300004836 | 13.9314002991 | 0.000998000032268 | 13.9735002518 | 0.0016230000183 | 13.7867002487 | 0.00202600006014 | 13.8350000381 | 0.0015269999858 | 2237.6897935 | 8.26456333143 | 2160.92598842 | 4.83838597716 | False | 5336.29884185 | 3.57314168312 | 5056.38374901 | 9.37474521502 | False | 7997.60547107 | 11.2037881027 | 7685.64216844 | 8.16178529652 | False | 9714.93457884 | 8.92989013415 | 9345.44313605 | 13.9699259492 | False | 11099.9213236 | 20.7126198525 | 10616.955199 | 14.9318871076 | False | False | 3 |
3 | 190832651577179648 | 265.157657507 | 69.0324273262 | 15.2238998413 | 0.00406700000167 | 15.2693996429 | 0.00790099985898 | 14.6610002518 | 0.000783000024967 | 14.7079000473 | 0.00157099997159 | 14.4495000839 | 0.0011569999624 | 14.5092000961 | 0.0022150001023 | 14.3676996231 | 0.00196200003847 | 14.4252004623 | 0.00537100015208 | 14.317199707 | 0.00185899995267 | 14.3607997894 | 0.00362000009045 | 2954.20115416 | 11.065980895 | 2832.95804491 | 20.6156900868 | False | 4961.35038537 | 3.57797544062 | 4751.60117527 | 6.87530293145 | False | 6028.37092325 | 6.42405116547 | 5705.84489136 | 11.6404398809 | False | 6500.10168696 | 11.7461310621 | 6164.81168808 | 30.4965463702 | False | 6809.57671954 | 11.6593724552 | 6541.5412484 | 21.8104359117 | False | False | 3 |
4 | 190982647386142438 | 264.738555327 | 69.1513914262 | 14.8620996475 | 0.00308299995959 | 14.9170999527 | 0.00701199984178 | 14.4414997101 | 0.00082499999553 | 14.4989004135 | 0.00559099996462 | 14.2973003387 | 0.00254700006917 | 14.3661003113 | 0.00255699991249 | 14.2636003494 | 0.0020389999263 | 14.3268995285 | 0.00170999998227 | 14.2371997833 | 0.00266700005159 | 14.3076000214 | 0.00342199997976 | 4122.49503239 | 11.7060221097 | 3918.86243811 | 25.3091521454 | False | 6072.95573989 | 4.61455410283 | 5760.23013128 | 29.662312373 | False | 6935.5333515 | 16.2698856763 | 6509.68352624 | 15.3308512086 | False | 7154.17995683 | 13.435466498 | 6749.01181763 | 10.6294789083 | False | 7330.27194304 | 18.0060640555 | 6870.05148069 | 21.6528802529 | False | False | 3 |
5 | 191022651184291037 | 265.118397937 | 69.1835778862 | 14.2899999619 | 0.00245700008236 | 14.3538999557 | 0.00548799987882 | 13.9597997665 | 0.000900999992155 | 14.0179004669 | 0.00256099994294 | 13.8449001312 | 0.00201900000684 | 13.9139003754 | 0.00277699995786 | 13.8359003067 | 0.00089999998454 | 13.8867998123 | 0.00273699988611 | 13.8187999725 | 0.0032389999833 | 13.8866996765 | 0.00340100005269 | 6982.32428609 | 15.8008651372 | 6583.24499604 | 33.2758984938 | False | 9464.11684249 | 7.85381307491 | 8970.97844615 | 21.1604579345 | False | 10520.586404 | 19.5637429502 | 9872.78887331 | 25.2517454654 | False | 10608.1555022 | 8.79342490946 | 10122.320289 | 25.5170541028 | False | 10776.5565194 | 32.1489384192 | 10123.2538983 | 31.7104531382 | False | False | 3 |
6 | 190822654421335368 | 265.441837017 | 69.0204656262 | 15.1218996048 | 0.00309600005858 | 15.189499855 | 0.00392499985173 | 14.717499733 | 0.00105399999302 | 14.7691001892 | 0.00235199998133 | 14.5580997467 | 0.00131099997088 | 14.6118001938 | 0.00171600002795 | 14.5367002487 | 0.00341799994931 | 14.5911998749 | 0.00274699996226 | 14.5080003738 | 0.00274199992418 | 14.5721998215 | 0.00413300003856 | 3245.19021703 | 9.2537294584 | 3049.2993275 | 11.0233953293 | False | 4709.7744223 | 4.57210709791 | 4491.17444682 | 9.72910562323 | False | 5454.56474722 | 6.58625381879 | 5191.34536865 | 8.20489245794 | False | 5563.13886166 | 17.5132856985 | 5290.78422579 | 13.3861098164 | False | 5712.15324942 | 14.4259017137 | 5384.18621035 | 20.495624736 | False | False | 3 |
7 | 190952647902459389 | 264.790211417 | 69.1320948362 | 12.3435001373 | 0.00108600000385 | 12.8218002319 | 0.00108600000385 | 11.1414003372 | 0.00108600000385 | 13.3312997818 | 0.0824650004506 | 11.5027999878 | 0.00161899998784 | 11.8860998154 | 0.00169099995401 | 10.4279003143 | 0.00108600000385 | nan | nan | 10.0581998825 | 0.0 | 10.0796003342 | 0.0 | 41937.2496622 | 41.9474390695 | 26994.7871348 | 27.0013460027 | False | 126893.642811 | 126.924473899 | 16884.1844249 | 1282.40568023 | False | 90966.1899263 | 135.644606617 | 63908.7133063 | 99.5358087793 | False | 244816.043102 | 244.875525553 | nan | nan | False | 344128.028951 | 0.0 | 337411.48894 | 0.0 | False | False | 3 |
8 | 190762653395766088 | 265.339526907 | 68.9711315762 | 12.8346004486 | 0.00108600000385 | 12.8804998398 | 0.00108600000385 | 12.2329998016 | 0.00108600000385 | 12.5298995972 | 0.00108600000385 | 12.926199913 | 0.0191849991679 | 13.6634998322 | 0.0420270003378 | 11.8736000061 | 0.00909799989313 | 11.9169998169 | 0.0109440004453 | 11.7222003937 | 0.00293099996634 | 11.7566003799 | 0.00384699995629 | 26678.4025026 | 26.6848844992 | 25574.0826321 | 25.5802963144 | False | 46430.149211 | 46.4414302489 | 35321.5831713 | 35.3301651837 | False | 24519.9756628 | 433.268883019 | 12433.6909137 | 481.287010547 | False | 64648.7299718 | 541.728401242 | 62115.5125588 | 626.111751754 | False | 74322.4200552 | 200.637143466 | 72004.5346572 | 255.127756139 | False | False | 3 |
9 | 190722653912264533 | 265.391174837 | 68.9364848762 | 12.714099884 | 0.00119099998847 | 12.758099556 | 0.00108600000385 | 12.3028001785 | 0.00108600000385 | 12.3551998138 | 0.00108600000385 | 12.6942996979 | 0.21552400291 | 12.6447000504 | 0.160992994905 | 12.1927995682 | 0.00108600000385 | 12.2520999908 | 0.00108600000385 | 12.1868000031 | 0.000859999970999 | 12.2322998047 | 0.00065000000177 | 29809.8675493 | 32.6999797481 | 28625.9677464 | 28.6329229389 | False | 43539.148234 | 43.5497268513 | 41487.7683448 | 41.4978485426 | False | 30358.4868158 | 6026.30968016 | 31777.518473 | 4711.97133078 | False | 48181.4840553 | 48.1931906114 | 45620.4960959 | 45.6315804141 | False | 48448.4624333 | 38.3755060437 | 46460.0933557 | 27.8143628545 | False | False | 3 |