{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# GAMA-15 master catalogue\n", "## Preparation of KIDS/VST data\n", "\n", "Kilo Degree Survey/VLT Survey Telescope catalogue: the catalogue comes from `dmu0_KIDS`.\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 corrected aperture magnitude in each band (10 pixels = 2\")\n", "- The Petrosian magnitude to be used as total magnitude (no “auto” magnitude is provided).\n", "\n", "We take 2014 as the observation year from a typical image header." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This notebook was run with herschelhelp_internal version: \n", "44f1ae0 (Thu Nov 30 18:27:54 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": { "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, mag_to_flux, 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 = \"kids_ra\"\n", "DEC_COL = \"kids_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': \"kids_id\",\n", " 'RAJ2000': \"kids_ra\",\n", " 'DECJ2000': \"kids_dec\",\n", " 'CLASS_STAR': \"kids_stellarity\",\n", " 'MAG_AUTO_U': \"m_kids_u\", \n", " 'MAGERR_AUTO_U': \"merr_kids_u\", \n", " 'MAG_AUTO_G': \"m_kids_g\", \n", " 'MAGERR_AUTO_G': \"merr_kids_g\", \n", " 'MAG_AUTO_R': \"m_kids_r\", \n", " 'MAGERR_AUTO_R': \"merr_kids_r\", \n", " 'MAG_AUTO_I': \"m_kids_i\", \n", " 'MAGERR_AUTO_I': \"merr_kids_i\", \n", " 'FLUX_APERCOR_10_U': \"f_ap_kids_u\",\n", " 'FLUXERR_APERCOR_10_U': \"ferr_ap_kids_u\",\n", " 'FLUX_APERCOR_10_G': \"f_ap_kids_g\",\n", " 'FLUXERR_APERCOR_10_G': \"ferr_ap_kids_g\",\n", " 'FLUX_APERCOR_10_R': \"f_ap_kids_r\",\n", " 'FLUXERR_APERCOR_10_R': \"ferr_ap_kids_r\",\n", " 'FLUX_APERCOR_10_I': \"f_ap_kids_i\",\n", " 'FLUXERR_APERCOR_10_I': \"ferr_ap_kids_i\"\n", "\n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_KIDS/data/KIDS-DR3_GAMA-15.fits\")[list(imported_columns)]\n", "for column in imported_columns:\n", " catalogue[column].name = imported_columns[column]\n", "\n", "epoch = 2014 #A range of observation dates from 2011 to 2015.\n", "\n", "# Clean table metadata\n", "catalogue.meta = None" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": true }, "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:76: RuntimeWarning: invalid value 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" ] } ], "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", " 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", " if col.startswith('f_'):\n", " \n", " errcol = \"ferr{}\".format(col[1:])\n", " \n", " #Convert fluxes in maggies to uJy\n", " catalogue[col] *= 3631. * 1.e6\n", " catalogue[col].unit = 'uJy'\n", " catalogue[errcol] *= 3631. * 1.e6\n", " catalogue[errcol].unit = 'uJy'\n", "\n", " mag, mag_error = flux_to_mag(np.array(catalogue[col]) * 1.e-6, \n", " np.array(catalogue[errcol]) * 1.e-6)\n", " \n", " # Magnitudes are added\n", " catalogue.add_column(Column(mag, name=\"m{}\".format(col[1:])))\n", " catalogue.add_column(Column(mag_error, name=\"m{}\".format(errcol[1:])))\n", " " ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": true }, "outputs": [ { "data": { "text/html": [ "<Table masked=True length=10>\n", "
idx | kids_id | kids_ra | kids_dec | kids_stellarity | m_kids_u | merr_kids_u | m_kids_g | merr_kids_g | m_kids_r | merr_kids_r | m_kids_i | merr_kids_i | f_ap_kids_u | ferr_ap_kids_u | f_ap_kids_g | ferr_ap_kids_g | f_ap_kids_r | ferr_ap_kids_r | f_ap_kids_i | ferr_ap_kids_i | f_kids_u | ferr_kids_u | flag_kids_u | f_kids_g | ferr_kids_g | flag_kids_g | f_kids_r | ferr_kids_r | flag_kids_r | f_kids_i | ferr_kids_i | flag_kids_i | m_ap_kids_u | merr_ap_kids_u | m_ap_kids_g | merr_ap_kids_g | m_ap_kids_r | merr_ap_kids_r | m_ap_kids_i | merr_ap_kids_i |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | mag | mag | mag | mag | mag | mag | mag | mag | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | |||||||||||||||||||||||
0 | KIDS J140359.64+015919.91 | 210.99847943 | 1.98886338333 | 0.981114 | 16.769 | 0.00275158 | nan | nan | nan | nan | nan | nan | 642.476 | 1.34263 | nan | nan | nan | nan | nan | nan | 711.842 | 1.80402 | False | nan | nan | False | nan | nan | False | nan | nan | False | 16.8804 | 0.00226894 | nan | nan | nan | nan | nan | nan |
1 | KIDS J140412.12+015919.40 | 211.050499476 | 1.98872230425 | 0.000443333 | 24.3694 | 1.05289 | 23.31 | 0.126845 | 21.8106 | 0.0487476 | 21.2606 | 0.089492 | 0.0306326 | 0.313297 | 1.03608 | 0.0932385 | 4.04274 | 0.128366 | 7.04238 | 0.385197 | 0.648973 | 0.62934 | False | 1.72181 | 0.201158 | False | 6.8512 | 0.307606 | False | 11.3704 | 0.937208 | False | 27.6845 | 11.1044 | 23.8615 | 0.0977069 | 22.3833 | 0.0344747 | 21.7807 | 0.0593864 |
2 | KIDS J140412.84+015919.93 | 211.053485639 | 1.98887072536 | 0.981845 | 23.7239 | 0.252736 | 22.0176 | 0.0183648 | 21.3225 | 0.0141337 | 21.0873 | 0.033662 | 1.73959 | 0.315403 | 6.73752 | 0.105041 | 12.216 | 0.134471 | 14.9205 | 0.389807 | 1.17608 | 0.273765 | False | 5.66164 | 0.0957645 | False | 10.7398 | 0.139807 | False | 13.3373 | 0.413508 | False | 23.2989 | 0.196853 | 21.8288 | 0.0169272 | 21.1827 | 0.0119516 | 20.9655 | 0.0283655 |
3 | KIDS J140415.59+015920.71 | 211.064955181 | 1.98908741726 | 0.909843 | 21.9301 | 0.0603713 | 20.717 | 0.00746359 | 20.187 | 0.0063222 | 20.0773 | 0.0163173 | 6.78835 | 0.331888 | 20.4694 | 0.13003 | 32.7089 | 0.150788 | 37.1463 | 0.401176 | 6.13718 | 0.341252 | False | 18.7592 | 0.128955 | False | 30.5627 | 0.177966 | False | 33.8123 | 0.508157 | False | 21.8206 | 0.0530825 | 20.6222 | 0.00689705 | 20.1133 | 0.00500523 | 19.9752 | 0.0117258 |
4 | KIDS J140410.58+015920.70 | 211.044073243 | 1.98908233649 | 0.616938 | nan | nan | 25.9789 | 0.328531 | 24.7045 | 0.155084 | 24.7157 | 0.475889 | nan | nan | 0.45615 | 0.0920767 | 0.594158 | 0.125214 | 0.914423 | 0.381771 | nan | nan | False | 0.147376 | 0.0445944 | False | 0.476633 | 0.068081 | False | 0.471751 | 0.206773 | False | nan | nan | 24.7522 | 0.219162 | 24.4652 | 0.22881 | 23.9971 | 0.453294 |
5 | KIDS J140410.34+015920.61 | 211.043080113 | 1.9890572003 | 0.561029 | nan | nan | 25.3622 | 0.321173 | 24.7737 | 0.285271 | 25.1272 | 1.20295 | nan | nan | 0.234848 | 0.0916795 | 0.447313 | 0.125314 | 0.237506 | 0.381711 | nan | nan | False | 0.260084 | 0.0769359 | False | 0.447209 | 0.117502 | False | 0.322947 | 0.357812 | False | nan | nan | 25.473 | 0.423848 | 24.7735 | 0.304167 | 25.4608 | 1.74495 |
6 | KIDS J140402.67+015934.83 | 211.01110751 | 1.9930094774 | 0.0286364 | 21.6357 | 0.130346 | 20.1622 | 0.0106663 | 18.9542 | 0.00549599 | 18.5297 | 0.0109418 | 2.29299 | 0.319669 | 13.8261 | 0.119214 | 47.9074 | 0.162793 | 73.2362 | 0.421445 | 8.04828 | 0.966222 | False | 31.2691 | 0.307188 | False | 95.128 | 0.481537 | False | 140.643 | 1.41737 | False | 22.999 | 0.151364 | 21.0483 | 0.00936162 | 19.699 | 0.0036894 | 19.2382 | 0.00624798 |
7 | KIDS J140419.14+015920.78 | 211.079757069 | 1.98910577496 | 0.724223 | nan | nan | 26.2688 | 1.01891 | 24.5769 | 0.229756 | nan | nan | nan | nan | 0.318493 | 0.162311 | 0.703465 | 0.155207 | nan | nan | nan | nan | False | 0.112839 | 0.105894 | False | 0.536117 | 0.113449 | False | nan | nan | False | nan | nan | 25.1423 | 0.553314 | 24.2819 | 0.239548 | nan | nan |
8 | KIDS J140407.81+015921.40 | 211.032555182 | 1.98927683536 | 0.980406 | 24.9083 | 0.651134 | 23.0939 | 0.0408647 | 21.6942 | 0.019155 | 21.0867 | 0.0291027 | 0.465615 | 0.312439 | 2.66643 | 0.09634 | 8.95205 | 0.149234 | 15.4011 | 0.387197 | 0.395088 | 0.236941 | False | 2.10115 | 0.0790828 | False | 7.62624 | 0.134545 | False | 13.345 | 0.357706 | False | 24.7299 | 0.728555 | 22.8352 | 0.0392284 | 21.5202 | 0.0180997 | 20.9311 | 0.0272964 |
9 | KIDS J140355.43+015921.65 | 210.980938185 | 1.9893459076 | 0.455706 | 25.7473 | 1.16787 | 24.8761 | 0.166662 | 24.4832 | 0.176115 | 24.2022 | 0.41056 | 0.353248 | 0.316523 | 0.561476 | 0.0918802 | 0.679135 | 0.124855 | 0.939536 | 0.377271 | 0.18242 | 0.19622 | False | 0.406957 | 0.0624683 | False | 0.584425 | 0.0947985 | False | 0.757007 | 0.286254 | False | 25.0298 | 0.972858 | 24.5267 | 0.17767 | 24.3201 | 0.199607 | 23.9677 | 0.435978 |