{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# HATLAS-SGP 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", "0246c5d (Thu Jan 25 17:01:47 2018 +0000) [with local modifications]\n", "This notebook was executed on: \n", "2018-02-19 22:56:56.995874\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, 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_HATLAS-SGP.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 J000026.12-313822.17 | 0.108820584302 | -31.6394914214 | 0.0140228 | 16.9387 | 0.0205972 | 17.7337 | 0.0157068 | 17.7246 | 0.0149373 | 16.7901 | 0.0148586 | 4.1135 | 0.274993 | 12.0903 | 0.122722 | 24.4822 | 0.105138 | 36.1372 | 0.220867 | 608.862 | 11.5506 | False | 292.765 | 4.23528 | False | 295.241 | 4.06186 | False | 698.168 | 9.5546 | False | 22.3645 | 0.072583 | 21.1939 | 0.0110208 | 20.4279 | 0.00466266 | 20.0051 | 0.00663591 |
1 | KIDS J235812.48-313717.43 | 359.552019286 | -31.6215071606 | 0.844716 | 15.3714 | 0.00122288 | nan | nan | nan | nan | nan | nan | 221.265 | 0.832352 | nan | nan | nan | nan | nan | nan | 2578.92 | 2.90468 | False | nan | nan | False | nan | nan | False | nan | nan | False | 18.0377 | 0.0040843 | nan | nan | nan | nan | nan | nan |
2 | KIDS J235812.76-313720.51 | 359.553169232 | -31.6223641219 | 0.983999 | 15.4255 | 0.00107514 | nan | nan | nan | nan | nan | nan | 116.152 | 0.6041 | nan | nan | nan | nan | nan | nan | 2453.67 | 2.42973 | False | nan | nan | False | nan | nan | False | nan | nan | False | 18.7374 | 0.00564687 | nan | nan | nan | nan | nan | nan |
3 | KIDS J235805.17-313749.95 | 359.521537496 | -31.6305409142 | 0.028628 | 18.5481 | 0.0156956 | 16.7969 | 0.00136235 | 16.0232 | 0.000697552 | 15.6931 | 0.00111182 | 31.2195 | 0.321258 | 177.795 | 0.247222 | 373.895 | 0.268671 | 517.69 | 0.471311 | 138.282 | 1.99902 | False | 693.809 | 0.87057 | False | 1414.88 | 0.909016 | False | 1917.67 | 1.96373 | False | 20.1639 | 0.0111725 | 18.2752 | 0.0015097 | 17.4681 | 0.000780182 | 17.1148 | 0.000988467 |
4 | KIDS J235957.31-313822.63 | 359.988804035 | -31.6396190349 | 0.979243 | 15.7623 | 0.00154891 | nan | nan | nan | nan | nan | nan | 1686.59 | 2.03184 | nan | nan | nan | nan | nan | nan | 1799.22 | 2.56676 | False | nan | nan | False | nan | nan | False | nan | nan | False | 15.8325 | 0.00130799 | nan | nan | nan | nan | nan | nan |
5 | KIDS J000053.94-313756.93 | 0.22475244384 | -31.632479929 | 0.0287444 | 20.4422 | 0.0440523 | 19.1467 | 0.00507098 | 18.4962 | 0.00280053 | 18.1304 | 0.00458438 | 10.3638 | 0.298121 | 30.163 | 0.12846 | 54.4599 | 0.127948 | 79.8037 | 0.259005 | 24.1621 | 0.980344 | False | 79.6714 | 0.372109 | False | 145.057 | 0.374158 | False | 203.169 | 0.857856 | False | 21.3612 | 0.0312318 | 20.2013 | 0.00462402 | 19.5598 | 0.00255082 | 19.1449 | 0.00352378 |
6 | KIDS J235907.14-313821.45 | 359.779740448 | -31.6392917852 | 0.977403 | 16.7923 | 0.00249413 | nan | nan | nan | nan | nan | nan | 624.759 | 1.06752 | nan | nan | nan | nan | nan | nan | 696.735 | 1.60053 | False | nan | nan | False | nan | nan | False | nan | nan | False | 16.9107 | 0.00185519 | nan | nan | nan | nan | nan | nan |
7 | KIDS J000212.69-313817.32 | 0.552891244908 | -31.6381438236 | 0.944895 | 18.2788 | 0.00403404 | 17.1881 | 0.000936475 | nan | nan | 16.5985 | 0.000837783 | 170.799 | 0.573301 | 481.732 | 0.41674 | nan | nan | 828.486 | 0.545636 | 177.206 | 0.658408 | False | 483.895 | 0.417372 | False | nan | nan | False | 832.921 | 0.642704 | False | 18.3188 | 0.00364436 | 17.193 | 0.000939258 | nan | nan | 16.6043 | 0.00071506 |
8 | KIDS J235934.61-313806.83 | 359.894189366 | -31.635230618 | 0.000323485 | nan | nan | 22.3488 | 0.151167 | 20.6892 | 0.0328453 | 19.4591 | 0.0245017 | nan | nan | 0.654772 | 0.100004 | 2.96284 | 0.120184 | 6.45809 | 0.258299 | nan | nan | False | 4.1734 | 0.581063 | False | 19.2457 | 0.582216 | False | 59.7517 | 1.34841 | False | nan | nan | 24.3598 | 0.165825 | 22.7207 | 0.0440418 | 21.8747 | 0.0434252 |
9 | KIDS J235757.92-313819.86 | 359.491339438 | -31.6388489954 | 0.028623 | 20.5057 | 0.0472263 | 18.9295 | 0.00529972 | 18.2112 | 0.00247531 | 17.8393 | 0.00388807 | 6.976 | 0.258388 | 27.5669 | 0.144333 | 51.8936 | 0.129535 | 71.9018 | 0.249482 | 22.7892 | 0.991261 | False | 97.3166 | 0.475024 | False | 188.588 | 0.429951 | False | 265.64 | 0.951266 | False | 21.791 | 0.0402153 | 20.299 | 0.00568462 | 19.6122 | 0.00271017 | 19.2582 | 0.00376725 |