{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# GAMA-09 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": {}, "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-09.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 J083701.35-005729.70 | 129.255631095 | -0.958249737971 | 0.923837 | 20.5073 | 0.106405 | 18.5165 | 0.00669415 | nan | nan | 17.5712 | 0.00674092 | 0.738152 | 0.202585 | 3.18799 | 0.0937371 | nan | nan | 25.4644 | 0.217592 | 22.7555 | 2.2301 | False | 142.365 | 0.877755 | False | nan | nan | False | 340.023 | 2.11107 | False | 24.2296 | 0.297979 | 22.6412 | 0.0319241 | nan | nan | 20.3852 | 0.00927753 |
1 | KIDS J083756.52-005753.00 | 129.485504309 | -0.964720938005 | 0.0362914 | 16.3644 | 0.00148657 | nan | nan | nan | nan | nan | nan | 223.857 | 0.763833 | nan | nan | nan | nan | nan | nan | 1033.31 | 1.41479 | False | nan | nan | False | nan | nan | False | nan | nan | False | 18.0251 | 0.00370469 | nan | nan | nan | nan | nan | nan |
2 | KIDS J083727.72-005850.71 | 129.365505624 | -0.98075382994 | 0.96692 | 16.1943 | 0.00174228 | nan | nan | nan | nan | nan | nan | 1100.14 | 1.3669 | nan | nan | nan | nan | nan | nan | 1208.63 | 1.93948 | False | nan | nan | False | nan | nan | False | nan | nan | False | 16.2964 | 0.001349 | nan | nan | nan | nan | nan | nan |
3 | KIDS J083446.46-005843.09 | 128.693563518 | -0.978635105781 | 0.958701 | 15.9047 | 0.00121472 | nan | nan | nan | nan | nan | nan | 1474.72 | 1.43213 | nan | nan | nan | nan | nan | nan | 1578.04 | 1.76551 | False | nan | nan | False | nan | nan | False | nan | nan | False | 15.9782 | 0.00105438 | nan | nan | nan | nan | nan | nan |
4 | KIDS J083646.89-005841.28 | 129.195390856 | -0.978134612471 | 0.973659 | 16.4266 | 0.0018003 | nan | nan | nan | nan | nan | nan | 913.774 | 1.21871 | nan | nan | nan | nan | nan | nan | 975.767 | 1.61796 | False | nan | nan | False | nan | nan | False | nan | nan | False | 16.4979 | 0.00144806 | nan | nan | nan | nan | nan | nan |
5 | KIDS J083738.56-005812.65 | 129.410663157 | -0.970181577073 | 0.979207 | 15.469 | 0.000879895 | nan | nan | nan | nan | nan | nan | 2151.48 | 1.70168 | nan | nan | nan | nan | nan | nan | 2357.13 | 1.91025 | False | nan | nan | False | nan | nan | False | nan | nan | False | 15.5682 | 0.000858743 | nan | nan | nan | nan | nan | nan |
6 | KIDS J083440.84-005838.44 | 128.670151767 | -0.977343685923 | 0.997976 | 16.1982 | 0.00144626 | nan | nan | nan | nan | nan | nan | 1101.2 | 1.29568 | nan | nan | nan | nan | nan | nan | 1204.29 | 1.60417 | False | nan | nan | False | nan | nan | False | nan | nan | False | 16.2953 | 0.00127748 | nan | nan | nan | nan | nan | nan |
7 | KIDS J083516.52-005757.12 | 128.818833104 | -0.965866765469 | 0.965219 | 15.9055 | 0.00127789 | nan | nan | nan | nan | nan | nan | 1464.31 | 1.47278 | nan | nan | nan | nan | nan | nan | 1576.94 | 1.85603 | False | nan | nan | False | nan | nan | False | nan | nan | False | 15.9859 | 0.00109202 | nan | nan | nan | nan | nan | nan |
8 | KIDS J083440.70-005833.32 | 128.669598302 | -0.975921804779 | 0.91333 | 19.2862 | 0.0116078 | 17.7636 | 0.0014776 | 17.1303 | 0.000862156 | 16.9006 | 0.00142596 | 48.3794 | 0.330695 | 225.348 | 0.267692 | 391.086 | 0.260295 | 483.48 | 0.460527 | 70.0666 | 0.749091 | False | 284.806 | 0.387598 | False | 510.347 | 0.405254 | False | 630.583 | 0.828183 | False | 19.6884 | 0.0074215 | 18.0179 | 0.00128975 | 17.4193 | 0.000722634 | 17.189 | 0.00103419 |
9 | KIDS J083431.07-005816.64 | 128.629439495 | -0.971287744949 | 0.970811 | 16.2179 | 0.0016896 | nan | nan | nan | nan | nan | nan | 1102.01 | 1.55786 | nan | nan | nan | nan | nan | nan | 1182.57 | 1.8403 | False | nan | nan | False | nan | nan | False | nan | nan | False | 16.2945 | 0.00153484 | nan | nan | nan | nan | nan | nan |