{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# EGS 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", "0246c5d (Thu Jan 25 17:01:47 2018 +0000) [with local modifications]\n", "This notebook was executed on: \n", "2018-02-07 19:28:11.002418\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", "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": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING: UnitsWarning: '0.3631uJy' did not parse as fits unit: Numeric factor not supported by FITS [astropy.units.core]\n", "WARNING: UnitsWarning: '[Msun]' did not parse as fits unit: Invalid character at col 0 [astropy.units.core]\n" ] } ], "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_EGS.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:76: 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:80: 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:76: 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", " #Calculate mags, errors including the fact that fluxes are in units of 0.3631 uJy\n", " mag, error = flux_to_mag(np.array(catalogue[col]) * 0.3631e-6, np.array(catalogue[errcol] * 0.3631e-6))\n", " \n", " \n", " # magnitudes are added\n", " catalogue.add_column(Column(mag, name=\"m{}\".format(col[1:])))\n", " catalogue.add_column(Column(error, name=\"m{}\".format(errcol[1:])))\n", " \n", " \n", " #Correct flux units to uJy\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", " if ('125' in col) or ('814' in col) or ('606' in col) :\n", " # We add nan filled aperture photometry for consistency\n", " catalogue.add_column(Column(np.full(len(catalogue), np.nan), name=\"m_ap{}\".format(col[1:])))\n", " catalogue.add_column(Column(np.full(len(catalogue), np.nan), name=\"merr_ap{}\".format(col[1:])))\n", " catalogue.add_column(Column(np.full(len(catalogue), np.nan), name=\"f_ap{}\".format(col[1:])))\n", " catalogue.add_column(Column(np.full(len(catalogue), np.nan), name=\"ferr_ap{}\".format(col[1:])))\n", "\n", " \n", "\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 | 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 | m_ap_candels_f606w | merr_ap_candels_f606w | f_ap_candels_f606w | ferr_ap_candels_f606w | flag_candels_f606w | m_candels_f814w | merr_candels_f814w | m_ap_candels_f814w | merr_ap_candels_f814w | f_ap_candels_f814w | ferr_ap_candels_f814w | flag_candels_f814w | m_candels_f125w | merr_candels_f125w | m_ap_candels_f125w | merr_ap_candels_f125w | f_ap_candels_f125w | ferr_ap_candels_f125w | flag_candels_f125w |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | ||||||||||||||||||||||||||||||||||
0 | 1 | 215.22238159 | 53.00418472 | 1 | nan | nan | nan | nan | 8181.01 | 0.0142633 | 9871.96 | 0.119445 | 650.167 | 0.0137945 | 1018.46 | 0.0208539 | 9100.38 | 0.0221371 | nan | nan | nan | nan | False | 14.118 | 1.89294e-06 | 13.914 | 1.31368e-05 | False | 16.8674 | 2.3036e-05 | nan | nan | nan | nan | False | 16.3801 | 2.22315e-05 | nan | nan | nan | nan | False | 14.0024 | 2.64111e-06 | nan | nan | nan | nan | False |
1 | 2 | 215.09658813 | 52.91805267 | 0 | 1.27368 | 0.026954 | 94.2571 | 1.99465 | 1.44895 | 0.0135948 | 107.227 | 0.590618 | 33.016 | 0.646136 | 53.0308 | 0.983674 | 91.661 | 1.09769 | 23.6374 | 0.0229766 | 18.9642 | 0.0229762 | False | 23.4974 | 0.010187 | 18.8242 | 0.00598035 | False | 20.1032 | 0.0212483 | nan | nan | nan | nan | False | 19.5887 | 0.0201395 | nan | nan | nan | nan | False | 18.9945 | 0.0130023 | nan | nan | nan | nan | False |
2 | 3 | 215.16146851 | 52.95946121 | 0 | nan | nan | nan | nan | 0.501477 | 0.0196452 | 26.0713 | 0.540293 | 9.57604 | 0.46386 | 13.7909 | 0.688946 | 24.01 | 1.17067 | nan | nan | nan | nan | False | 24.6494 | 0.0425332 | 20.3596 | 0.0225004 | False | 21.447 | 0.0525927 | nan | nan | nan | nan | False | 21.051 | 0.0542396 | nan | nan | nan | nan | False | 20.449 | 0.0529379 | nan | nan | nan | nan | False |
3 | 4 | 215.30529785 | 53.0529213 | 0 | nan | nan | nan | nan | 0.299735 | 0.0272783 | 0.410267 | 0.0348703 | 0.161358 | 0.01191 | 0.166961 | 0.0186666 | 0.40787 | 0.0460701 | nan | nan | nan | nan | False | 25.2082 | 0.0988104 | 24.8673 | 0.0922813 | False | 25.8805 | 0.0801396 | nan | nan | nan | nan | False | 25.8435 | 0.121388 | nan | nan | nan | nan | False | 24.8737 | 0.122637 | nan | nan | nan | nan | False |
4 | 5 | 215.0418396 | 52.87127304 | 2 | 686.441 | 0.0484012 | 825.29 | 0.0581904 | nan | nan | nan | nan | 77.0135 | 0.0104097 | 256.265 | 0.0160425 | nan | nan | 16.8085 | 7.65557e-05 | 16.6085 | 7.65542e-05 | False | nan | nan | nan | nan | False | 19.1836 | 0.000146756 | nan | nan | nan | nan | False | 17.8783 | 6.79683e-05 | nan | nan | nan | nan | False | nan | nan | nan | nan | nan | nan | False |
5 | 6 | 215.30380249 | 53.05212021 | 0 | nan | nan | nan | nan | 0.614547 | 0.0301939 | 0.982875 | 0.0523772 | 0.662803 | 0.0140367 | 0.952157 | 0.021835 | 1.01254 | 0.0746969 | nan | nan | nan | nan | False | 24.4286 | 0.0533444 | 23.9188 | 0.0578586 | False | 24.3465 | 0.0229935 | nan | nan | nan | nan | False | 23.9532 | 0.0248983 | nan | nan | nan | nan | False | 23.8865 | 0.0800967 | nan | nan | nan | nan | False |
6 | 7 | 215.26712036 | 53.02758408 | 2 | nan | nan | nan | nan | 0.156994 | 0.0271098 | 0.217729 | 0.0420288 | 0.0891047 | 0.0130001 | 0.154561 | 0.0201441 | 0.242536 | 0.0484702 | nan | nan | nan | nan | False | 25.9103 | 0.187486 | 25.5552 | 0.209582 | False | 26.5252 | 0.158405 | nan | nan | nan | nan | False | 25.9273 | 0.141505 | nan | nan | nan | nan | False | 25.4381 | 0.216981 | nan | nan | nan | nan | False |
7 | 8 | 215.3032074 | 53.05295563 | 2 | nan | nan | nan | nan | 0.134234 | 0.0190722 | 0.20843 | 0.0333133 | 0.0766141 | 0.0135208 | 0.122259 | 0.0213884 | 0.207802 | 0.0320127 | nan | nan | nan | nan | False | 26.0803 | 0.154263 | 25.6026 | 0.173533 | False | 26.6892 | 0.191609 | nan | nan | nan | nan | False | 26.1818 | 0.189942 | nan | nan | nan | nan | False | 25.6059 | 0.167262 | nan | nan | nan | nan | False |
8 | 9 | 215.30378723 | 53.05344391 | 2 | nan | nan | nan | nan | 0.175435 | 0.0192356 | 0.203365 | 0.0247638 | 0.0824963 | 0.0101552 | 0.109899 | 0.0157996 | 0.158192 | 0.0235928 | nan | nan | nan | nan | False | 25.7897 | 0.119045 | 25.6293 | 0.13221 | False | 26.6089 | 0.133653 | nan | nan | nan | nan | False | 26.2975 | 0.15609 | nan | nan | nan | nan | False | 25.902 | 0.161927 | nan | nan | nan | nan | False |
9 | 10 | 215.27868652 | 53.03592682 | 2 | nan | nan | nan | nan | 0.125879 | 0.0176125 | 0.252413 | 0.0423629 | 0.0961598 | 0.0190417 | 0.206353 | 0.0290712 | 0.235794 | 0.0426751 | nan | nan | nan | nan | False | 26.1501 | 0.151912 | 25.3947 | 0.182221 | False | 26.4425 | 0.214999 | nan | nan | nan | nan | False | 25.6135 | 0.152959 | nan | nan | nan | nan | False | 25.4687 | 0.196502 | nan | nan | nan | nan | False |