{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# COSMOS master catalogue\n", "## Preparation of HST CANDELS-3D data\n", "\n", "The catalogue comes from `dmu0_CANDELS-3D-HST`.\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 kron magnitude, there doesn't appear to be aperture magnitudes. This may mean the survey is unusable.\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", "017bb1e (Mon Jun 18 14:58:59 2018 +0100)\n", "This notebook was executed on: \n", "2018-11-06 12:05:33.270406\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": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/seaborn/apionly.py:6: UserWarning: As seaborn no longer sets a default style on import, the seaborn.apionly module is deprecated. It will be removed in a future version.\n", " warnings.warn(msg, UserWarning)\n" ] } ], "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, flux_to_mag" ] }, { "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 = \"candels_ra\"\n", "DEC_COL = \"candels_dec\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I - Column selection" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "imported_columns = OrderedDict({\n", " 'ID': \"candels_id\",\n", " 'RAJ2000': \"candels_ra\",\n", " 'DEJ2000': \"candels_dec\",\n", " 'S/G': \"candels_stellarity\",\n", " 'F140Wap': \"f_ap_candels_f140w\",\n", " 'e_F140Wap': \"ferr_ap_candels_f140w\",\n", " 'F140W': \"f_candels_f140w\",\n", " 'e_F140W': \"ferr_candels_f140w\",\n", " 'F160Wap': \"f_ap_candels_f160w\",\n", " 'e_F160Wap': \"ferr_ap_candels_f160w\",\n", " 'F160W': \"f_candels_f160w\",\n", " 'e_F160W': \"ferr_candels_f160w\",\n", " 'F606W': \"f_candels_f606w\",\n", " 'e_F606W': \"ferr_candels_f606w\",\n", " 'F814W': \"f_candels_f814w\",\n", " 'e_F814W': \"ferr_candels_f814w\",\n", " 'F125W': \"f_candels_f125w\",\n", " 'e_F125W': \"ferr_candels_f125w\"\n", "\n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_CANDELS-3D-HST/data/CANDELS-3D-HST_COSMOS.fits\")[list(imported_columns)]\n", "for column in imported_columns:\n", " catalogue[column].name = imported_columns[column]\n", "\n", "epoch = 2012 #Year of publication\n", "\n", "# Clean table metadata\n", "catalogue.meta = None" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/herschelhelp_internal/herschelhelp_internal/utils.py:77: RuntimeWarning: divide by zero encountered in log10\n", " magnitudes = 2.5 * (23 - np.log10(fluxes)) - 48.6\n", "/opt/herschelhelp_internal/herschelhelp_internal/utils.py:81: RuntimeWarning: divide by zero encountered in true_divide\n", " errors = 2.5 / np.log(10) * errors_on_fluxes / fluxes\n", "/opt/herschelhelp_internal/herschelhelp_internal/utils.py:81: RuntimeWarning: invalid value encountered in true_divide\n", " errors = 2.5 / np.log(10) * errors_on_fluxes / fluxes\n", "/opt/herschelhelp_internal/herschelhelp_internal/utils.py:77: RuntimeWarning: invalid value encountered in log10\n", " magnitudes = 2.5 * (23 - np.log10(fluxes)) - 48.6\n" ] } ], "source": [ "# Adding flux and band-flag columns\n", "for col in catalogue.colnames:\n", " if col.startswith('f_'):\n", " \n", " errcol = \"ferr{}\".format(col[1:])\n", " \n", " catalogue[col] = catalogue[col] * 0.3631\n", " catalogue[col].unit = u.microjansky\n", " catalogue[errcol] = catalogue[errcol] * 0.3631\n", " catalogue[errcol].unit = u.microjansky\n", " \n", "\n", " mag, error = flux_to_mag(np.array(catalogue[col]) * 1.e-6 , np.array(catalogue[errcol] ) * 1.e-6)\n", " \n", " # Fluxes are added in µJy\n", " catalogue.add_column(Column(mag, name=\"m{}\".format(col[1:])))\n", " catalogue.add_column(Column(error, name=\"m{}\".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": { "collapsed": true }, "outputs": [], "source": [ "catalogue['candels_stellarity'] = catalogue['candels_stellarity'].astype(float)\n", "catalogue['candels_stellarity'][np.isclose(catalogue['candels_stellarity'], 1.)] = 0.9\n", "catalogue['candels_stellarity'][np.isclose(catalogue['candels_stellarity'], 0.)] = 0.05\n", "catalogue['candels_stellarity'][np.isclose(catalogue['candels_stellarity'], 2.)] = np.nan" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Table masked=True length=10\n", "
idx | candels_id | candels_ra | candels_dec | candels_stellarity | f_ap_candels_f140w | ferr_ap_candels_f140w | f_candels_f140w | ferr_candels_f140w | f_ap_candels_f160w | ferr_ap_candels_f160w | f_candels_f160w | ferr_candels_f160w | f_candels_f606w | ferr_candels_f606w | f_candels_f814w | ferr_candels_f814w | f_candels_f125w | ferr_candels_f125w | m_ap_candels_f140w | merr_ap_candels_f140w | m_candels_f140w | merr_candels_f140w | flag_candels_f140w | m_ap_candels_f160w | merr_ap_candels_f160w | m_candels_f160w | merr_candels_f160w | flag_candels_f160w | m_candels_f606w | merr_candels_f606w | flag_candels_f606w | m_candels_f814w | merr_candels_f814w | flag_candels_f814w | m_candels_f125w | merr_candels_f125w | flag_candels_f125w |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | ||||||||||||||||||||||
0 | 1 | 150.07144165 | 2.16901445 | 0.05 | nan | nan | nan | nan | 1.8110702 | 0.065597646 | 2.5702033 | 0.11964508 | 1.4882016 | 0.01217329 | 3.0544333 | 0.014993488 | 2.5597098 | 0.058371954 | nan | nan | nan | nan | False | 23.255165 | 0.039325774 | 22.875084 | 0.050541908 | False | 23.468346 | 0.008881177 | False | 22.687675 | 0.0053296206 | False | 22.879524 | 0.024759267 | False |
1 | 2 | 150.07157898 | 2.16905951 | 0.05 | nan | nan | nan | nan | 0.7838602 | 0.06010394 | 1.2548009 | 0.09189697 | 0.8072076 | 0.013738251 | 1.5397619 | 0.016951323 | 1.2588676 | 0.06900352 | nan | nan | nan | nan | False | 24.164406 | 0.08325084 | 23.653564 | 0.07951529 | False | 24.132538 | 0.018478662 | False | 23.431366 | 0.011952927 | False | 23.650055 | 0.059513498 | False |
2 | 3 | 150.07551575 | 2.17311358 | 0.05 | nan | nan | nan | nan | 6.585544 | 0.01669897 | 21.239897 | 0.1982998 | 1.7054081 | 0.028027687 | 7.052854 | 0.034523547 | 16.211687 | 0.037493706 | nan | nan | nan | nan | False | 21.853523 | 0.002753102 | 20.582123 | 0.010136643 | False | 23.320427 | 0.017843632 | False | 21.77909 | 0.0053146514 | False | 20.875435 | 0.002511045 | False |
3 | 4 | 150.06834412 | 2.16974521 | nan | nan | nan | nan | nan | 0.19595417 | 0.035028256 | 0.2369518 | 0.03287689 | 0.07290685 | 0.011539681 | 0.08186816 | 0.016118009 | 0.075666405 | 0.031453174 | nan | nan | nan | nan | False | 25.669617 | 0.19408336 | 25.463348 | 0.1506451 | False | 26.74308 | 0.17185009 | False | 26.617218 | 0.21375714 | False | 26.702744 | 0.4513211 | False |
4 | 5 | 150.07145691 | 2.17064571 | nan | nan | nan | nan | nan | 0.26412258 | 0.024869446 | 0.29932147 | 0.029539999 | 0.10092728 | 0.009796801 | 0.118642926 | 0.012246274 | 0.3497597 | 0.020667652 | nan | nan | nan | nan | False | 25.345482 | 0.10223153 | 25.209656 | 0.107151166 | False | 26.389977 | 0.10539014 | False | 26.214394 | 0.11206924 | False | 25.04058 | 0.06415725 | False |
5 | 6 | 150.06959534 | 2.17076755 | nan | nan | nan | nan | nan | 0.14297426 | 0.019896064 | 0.17788994 | 0.034232702 | 0.063669585 | 0.010683491 | 0.078560315 | 0.013464111 | 0.15688099 | 0.0174898 | nan | nan | nan | nan | False | 26.011856 | 0.15108927 | 25.77462 | 0.2089364 | False | 26.890175 | 0.182182 | False | 26.661995 | 0.1860796 | False | 25.91108 | 0.121042766 | False |
6 | 7 | 150.06835938 | 2.17106199 | 0.05 | nan | nan | nan | nan | 1.1017543 | 0.024495816 | 1.4720073 | 0.05348463 | 0.47264725 | 0.011264088 | 0.72147965 | 0.014405266 | 1.0877386 | 0.023628732 | nan | nan | nan | nan | False | 23.794792 | 0.024139678 | 23.480225 | 0.039449666 | False | 24.713661 | 0.025875168 | False | 24.254448 | 0.021678116 | False | 23.808685 | 0.023585234 | False |
7 | 8 | 150.06916809 | 2.17103839 | nan | nan | nan | nan | nan | 0.12354114 | 0.020280587 | 0.1725197 | 0.044588678 | 0.040282313 | 0.012203065 | 0.037588112 | 0.015245843 | 0.12505889 | 0.019706527 | nan | nan | nan | nan | False | 26.170471 | 0.17823508 | 25.8079 | 0.28061455 | False | 27.387215 | 0.3289113 | False | 27.46238 | 0.44037756 | False | 26.157219 | 0.1710881 | False |
8 | 9 | 150.07997131 | 2.17103219 | 0.05 | nan | nan | nan | nan | 0.2481389 | 0.04266788 | 0.46883473 | 0.0999106 | 0.11358857 | 0.016694974 | 0.21560514 | 0.02044616 | 0.44359925 | 0.06018745 | nan | nan | nan | nan | False | 25.413261 | 0.18669406 | 24.72245 | 0.23137483 | False | 26.261665 | 0.15957889 | False | 25.56585 | 0.102961995 | False | 24.782524 | 0.14731245 | False |
9 | 10 | 150.068573 | 2.17154479 | 0.05 | nan | nan | nan | nan | 1.6297743 | 0.020914923 | 2.3944266 | 0.05305254 | 0.8183185 | 0.012704506 | 1.2700512 | 0.015673574 | 2.0973744 | 0.021401476 | nan | nan | nan | nan | False | 23.369682 | 0.013933271 | 22.951996 | 0.02405631 | False | 24.117699 | 0.016856201 | False | 23.64045 | 0.013398961 | False | 23.09581 | 0.011078783 | False |