{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# GAMA-12 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": {}, "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": {}, "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-12.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": {}, "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": {}, "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 J113219.46-005835.36 | 173.081088813 | -0.976489335514 | 0.845405 | 14.3515 | 0.00054718 | nan | nan | nan | nan | nan | nan | 2865.8 | 2.37214 | nan | nan | nan | nan | nan | nan | 6597.89 | 3.32515 | False | nan | nan | False | nan | nan | False | nan | nan | False | 15.2569 | 0.000898708 | nan | nan | nan | nan | nan | nan |
1 | KIDS J113215.90-005840.82 | 173.066239115 | -0.978005028994 | 0.0286267 | 19.1019 | 0.0206341 | 17.5989 | 0.00285831 | 16.6465 | 0.001227 | 16.2415 | 0.00272289 | 8.44303 | 0.234402 | 50.8214 | 0.163794 | 143.319 | 0.183881 | 211.238 | 0.456848 | 83.0284 | 1.57793 | False | 331.472 | 0.872633 | False | 796.869 | 0.900547 | False | 1157.18 | 2.90207 | False | 21.5838 | 0.030143 | 19.6349 | 0.00349925 | 18.5092 | 0.00139302 | 18.0881 | 0.00234815 |
2 | KIDS J113340.65-005842.45 | 173.419366806 | -0.97845750339 | 0.941812 | nan | nan | nan | nan | 22.5797 | 0.0541316 | 24.6938 | 1.10083 | nan | nan | nan | nan | 2.6137 | 0.106617 | 0.851441 | 0.326595 | nan | nan | False | nan | nan | False | 3.37391 | 0.168213 | False | 0.481376 | 0.488067 | False | nan | nan | nan | nan | 22.8569 | 0.044289 | 24.0746 | 0.416466 |
3 | KIDS J113219.26-005836.01 | 173.080233339 | -0.976668253909 | 0.992197 | 17.6924 | 0.00275188 | nan | nan | nan | nan | nan | nan | 146.475 | 0.539883 | nan | nan | nan | nan | nan | nan | 304.128 | 0.770835 | False | nan | nan | False | nan | nan | False | nan | nan | False | 18.4856 | 0.00400183 | nan | nan | nan | nan | nan | nan |
4 | KIDS J113213.85-005807.68 | 173.057689629 | -0.968799320973 | 0.870375 | 15.1315 | 0.000776921 | nan | nan | nan | nan | nan | nan | 2987.24 | 2.16713 | nan | nan | nan | nan | nan | nan | 3216.6 | 2.30171 | False | nan | nan | False | nan | nan | False | nan | nan | False | 15.2118 | 0.000787659 | nan | nan | nan | nan | nan | nan |
5 | KIDS J113209.24-005633.18 | 173.038519648 | -0.942550533585 | 0.0286296 | 17.2637 | 0.0054599 | 15.4545 | 0.000622265 | nan | nan | 14.1012 | 0.000577777 | 98.8374 | 0.39739 | 518.016 | 0.373521 | nan | nan | 1857.47 | 0.857652 | 451.364 | 2.2698 | False | 2388.88 | 1.36913 | False | nan | nan | False | 8308.11 | 4.42118 | False | 18.9127 | 0.00436536 | 17.1141 | 0.000782881 | nan | nan | 15.7277 | 0.000501319 |
6 | KIDS J113344.94-005845.68 | 173.437247571 | -0.979354489103 | 0.898581 | 16.8635 | 0.00211798 | nan | nan | nan | nan | nan | nan | 609.817 | 0.957935 | nan | nan | nan | nan | nan | nan | 652.52 | 1.27289 | False | nan | nan | False | nan | nan | False | nan | nan | False | 16.937 | 0.00170554 | nan | nan | nan | nan | nan | nan |
7 | KIDS J113322.42-005849.09 | 173.343410757 | -0.980303965074 | 0.0286452 | 23.7685 | 0.618419 | 21.5296 | 0.039135 | 19.9638 | 0.00967272 | 19.4614 | 0.0212139 | 0.667789 | 0.221617 | 4.92933 | 0.110483 | 21.8807 | 0.119015 | 34.8954 | 0.357608 | 1.12872 | 0.642904 | False | 8.87509 | 0.319899 | False | 37.5394 | 0.334435 | False | 59.6242 | 1.16498 | False | 24.3384 | 0.360321 | 22.168 | 0.024335 | 20.5499 | 0.0059056 | 20.0431 | 0.0111266 |
8 | KIDS J113332.33-005848.01 | 173.384717638 | -0.980002883981 | 0.907495 | 21.7005 | 0.0639779 | 18.8266 | 0.00277012 | 17.3589 | 0.000905858 | 16.4541 | 0.000997943 | 6.7548 | 0.272323 | 106.711 | 0.227502 | 423.098 | 0.317784 | 962.924 | 0.72423 | 7.58202 | 0.446777 | False | 106.993 | 0.27298 | False | 413.477 | 0.344975 | False | 951.378 | 0.874449 | False | 21.826 | 0.043772 | 18.8295 | 0.00231473 | 17.3339 | 0.000815484 | 16.441 | 0.000816598 |
9 | KIDS J113356.28-005843.52 | 173.484480809 | -0.978755993356 | 0.946369 | 20.8897 | 0.029001 | 18.0669 | 0.00155863 | nan | nan | nan | nan | 16.6438 | 0.244979 | 213.287 | 0.264376 | nan | nan | nan | nan | 15.9994 | 0.427359 | False | 215.389 | 0.309203 | False | nan | nan | False | nan | nan | False | 20.8469 | 0.0159809 | 18.0776 | 0.00134581 | nan | nan | nan | nan |