{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# GAMA-12 master catalogue\n", "## Preparation of UKIRT Infrared Deep Sky Survey / Large Area Survey (UKIDSS/LAS)\n", "\n", "Information about UKIDSS can be found at http://www.ukidss.org/surveys/surveys.html\n", "\n", "The catalogue comes from `dmu0_UKIDSS-LAS`.\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 magnitude for each band in aperture 3 (2 arcsec).\n", "- The hall magnitude is described as the total magnitude.\n", "\n", "J band magnitudes are available in two eopchs. We take the first arbitrarily.\n", "\n", "The magnitudes are “*Vega like*”. The AB offsets are given by Hewett *et al.* (2016):\n", "\n", "| Band | AB offset |\n", "|------|-----------|\n", "| Y | 0.634 |\n", "| J | 0.938 |\n", "| H | 1.379 |\n", "| K | 1.900 |\n", "\n", "Each source is associated with an epoch. These range between 2005 and 2007. We take 2006 for the epoch." ] }, { "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" ] }, { "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 = \"las_ra\"\n", "DEC_COL = \"las_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: 'RADIANS' did not parse as fits unit: At col 0, Unit 'RADIANS' not supported by the FITS standard. [astropy.units.core]\n" ] } ], "source": [ "#Is the following standard (different names for radec vs mag)?\n", "imported_columns = OrderedDict({\n", " 'SOURCEID': 'las_id',\n", " 'RA': 'las_ra',\n", " 'Dec': 'las_dec',\n", " 'YHALLMAG': 'm_ukidss_y',\n", " 'YHALLMAGERR': 'merr_ukidss_y',\n", " 'YAPERMAG3': 'm_ap_ukidss_y',\n", " 'YAPERMAG3ERR': 'merr_ap_ukidss_y',\n", " 'J_1HALLMAG': 'm_ukidss_j',\n", " 'J_1HALLMAGERR': 'merr_ukidss_j',\n", " 'J_1APERMAG3': 'm_ap_ukidss_j',\n", " 'J_1APERMAG3ERR': 'merr_ap_ukidss_j',\n", " 'HAPERMAG3': 'm_ap_ukidss_h',\n", " 'HAPERMAG3ERR': 'merr_ap_ukidss_h',\n", " 'HHALLMAG': 'm_ukidss_h',\n", " 'HHALLMAGERR': 'merr_ukidss_h',\n", " 'KAPERMAG3': 'm_ap_ukidss_k',\n", " 'KAPERMAG3ERR': 'merr_ap_ukidss_k',\n", " 'KHALLMAG': 'm_ukidss_k',\n", " 'KHALLMAGERR': 'merr_ukidss_k',\n", " 'PSTAR': 'las_stellarity'\n", " })\n", "\n", "catalogue = Table.read(\n", " \"../../dmu0/dmu0_UKIDSS-LAS/data/UKIDSS-LAS_GAMA-12.fits\")[list(imported_columns)]\n", "for column in imported_columns:\n", " catalogue[column].name = imported_columns[column]\n", "\n", "#Epochs between 2005 and 2007. Rough average:\n", "epoch = 2006\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/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/astropy/table/column.py:1096: MaskedArrayFutureWarning: setting an item on a masked array which has a shared mask will not copy the mask and also change the original mask array in the future.\n", "Check the NumPy 1.11 release notes for more information.\n", " ma.MaskedArray.__setitem__(self, index, value)\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", " # LAS uses a huge negative number for missing values\n", " catalogue[col][catalogue[col] < -100] = np.nan\n", " catalogue[errcol][catalogue[errcol] < -100] = np.nan \n", "\n", " # Vega to AB correction\n", " if col.endswith('y'):\n", " catalogue[col] += 0.634\n", " elif col.endswith('j'):\n", " catalogue[col] += 0.938\n", " elif col.endswith('h'):\n", " catalogue[col] += 1.379\n", " elif col.endswith('k'):\n", " catalogue[col] += 1.900\n", " else:\n", " print(\"{} column has wrong band...\".format(col))\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", " \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 | las_id | las_ra | las_dec | m_ukidss_y | merr_ukidss_y | m_ap_ukidss_y | merr_ap_ukidss_y | m_ukidss_j | merr_ukidss_j | m_ap_ukidss_j | merr_ap_ukidss_j | m_ap_ukidss_h | merr_ap_ukidss_h | m_ukidss_h | merr_ukidss_h | m_ap_ukidss_k | merr_ap_ukidss_k | m_ukidss_k | merr_ukidss_k | las_stellarity | f_ukidss_y | ferr_ukidss_y | flag_ukidss_y | f_ap_ukidss_y | ferr_ap_ukidss_y | f_ukidss_j | ferr_ukidss_j | flag_ukidss_j | f_ap_ukidss_j | ferr_ap_ukidss_j | f_ap_ukidss_h | ferr_ap_ukidss_h | f_ukidss_h | ferr_ukidss_h | flag_ukidss_h | f_ap_ukidss_k | ferr_ap_ukidss_k | f_ukidss_k | ferr_ukidss_k | flag_ukidss_k |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 433868214611 | 177.621028054 | -0.657633289682 | nan | nan | nan | nan | 20.2822 | 0.27995 | 20.0034 | 0.203765 | 19.4475 | 0.0946257 | 19.5657 | 0.143791 | 19.7498 | 0.159388 | 19.3611 | 0.215073 | 0.944606 | nan | nan | False | nan | nan | 27.9973 | 7.21892 | False | 36.1951 | 6.79288 | 60.3962 | 5.26374 | 54.1666 | 7.17365 | False | 45.7171 | 6.71136 | 65.4001 | 12.9551 | False |
1 | 433868214612 | 177.643909694 | -0.658838966029 | nan | nan | nan | nan | 17.4834 | 0.0496665 | 18.051 | 0.0350612 | 17.8427 | 0.0228604 | 17.2059 | 0.0348909 | 17.9218 | 0.0308449 | 17.1929 | 0.0455842 | 0.000171409 | nan | nan | False | nan | nan | 368.681 | 16.8651 | False | 218.571 | 7.05822 | 264.806 | 5.57556 | 476.024 | 15.2974 | False | 246.196 | 6.99423 | 481.759 | 20.2265 | False |
2 | 433868214613 | 177.661135574 | -0.659288988821 | nan | nan | nan | nan | 18.035 | 0.0692809 | 18.4166 | 0.048594 | 18.1919 | 0.0310468 | 17.9663 | 0.0493417 | 18.2736 | 0.0422516 | 17.9482 | 0.0635772 | 0.000171409 | nan | nan | False | nan | nan | 221.822 | 14.1545 | False | 156.082 | 6.98571 | 191.97 | 5.48943 | 236.314 | 10.7394 | False | 178.064 | 6.9294 | 240.29 | 14.0706 | False |
3 | 433868214618 | 177.702763524 | -0.666044924906 | nan | nan | nan | nan | 14.8129 | 0.00333679 | 14.776 | 0.00278882 | 14.6527 | 0.00223917 | 14.6883 | 0.00287698 | 14.9235 | 0.00299324 | 14.9757 | 0.00407833 | 0.999657 | nan | nan | False | nan | nan | 4313.65 | 13.2571 | False | 4462.74 | 11.463 | 4999.6 | 10.3109 | 4838.0 | 12.8197 | False | 3895.9 | 10.7405 | 3712.82 | 13.9464 | False |
4 | 433868214621 | 177.630615438 | -0.672197056659 | nan | nan | nan | nan | 14.4072 | 0.00249801 | 14.365 | 0.00216103 | 14.2008 | 0.00172394 | 14.2287 | 0.00219662 | 14.6307 | 0.0024697 | 14.6666 | 0.00325565 | 0.999657 | nan | nan | False | nan | nan | 6268.09 | 14.4213 | False | 6516.29 | 12.9699 | 7580.36 | 12.0362 | 7388.03 | 14.9472 | False | 5101.8 | 11.6049 | 4935.69 | 14.8 | False |
5 | 433868214623 | 177.696541646 | -0.672701277414 | nan | nan | nan | nan | 14.7201 | 0.00308774 | 14.6818 | 0.00262395 | 14.8112 | 0.00245156 | 14.8424 | 0.00315697 | 15.3165 | 0.0038714 | 15.3739 | 0.00528467 | 0.999657 | nan | nan | False | nan | nan | 4698.52 | 13.3622 | False | 4867.13 | 11.7626 | 4320.4 | 9.75533 | 4198.08 | 12.2067 | False | 2712.73 | 9.67277 | 2573.09 | 12.5242 | False |
6 | 433868214626 | 177.715707747 | -0.674883265918 | nan | nan | nan | nan | 17.6191 | 0.0393838 | 17.5465 | 0.0226987 | 17.4223 | 0.0160639 | 17.4874 | 0.0230781 | 17.6824 | 0.0251259 | 17.7471 | 0.0406563 | 0.999657 | nan | nan | False | nan | nan | 325.363 | 11.8022 | False | 347.866 | 7.27259 | 390.03 | 5.77066 | 367.319 | 7.80764 | False | 306.919 | 7.10265 | 289.165 | 10.828 | False |
7 | 433868214627 | 177.624008287 | -0.675781383366 | nan | nan | nan | nan | 18.2605 | 0.0928487 | 19.0189 | 0.082927 | 18.7652 | 0.0509661 | 17.9901 | 0.0755759 | 18.545 | 0.0532378 | 18.002 | 0.0976286 | 0.000171409 | nan | nan | False | nan | nan | 180.214 | 15.4114 | False | 89.625 | 6.84544 | 113.222 | 5.31481 | 231.179 | 16.0919 | False | 138.669 | 6.7995 | 228.664 | 20.5613 | False |
8 | 433868214628 | 177.687379304 | -0.676687549685 | nan | nan | nan | nan | 19.0823 | 0.14972 | 19.3963 | 0.117401 | 19.2353 | 0.0783825 | 19.0204 | 0.144317 | 19.1873 | 0.0958965 | 19.5192 | 0.351418 | 0.000171409 | nan | nan | False | nan | nan | 84.5452 | 11.6586 | False | 63.3087 | 6.84561 | 73.4317 | 5.30125 | 89.5044 | 11.897 | False | 76.7509 | 6.77894 | 56.5334 | 18.2981 | False |
9 | 433868214629 | 177.637922593 | -0.676547415089 | nan | nan | nan | nan | 18.0436 | 0.0716036 | 18.5712 | 0.0554558 | 18.2701 | 0.032927 | 17.597 | 0.0544942 | 18.169 | 0.0381226 | 17.7159 | 0.0621853 | 0.000171409 | nan | nan | False | nan | nan | 220.066 | 14.5132 | False | 135.375 | 6.91451 | 178.636 | 5.41749 | 332.032 | 16.665 | False | 196.073 | 6.88457 | 297.618 | 17.046 | False |