{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# XMM-LSS master catalogue\n", "## Preparation of UKIRT Infrared Deep Sky Survey / Ultra Deep Survey (UKIDSS/DXS)\n", "\n", "The catalogue comes from `dmu0_UKIDSS-UDS`.\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 apertude 3 (2 arcsec).\n", "- The kron magnitude to be used as total magnitude (no “auto” magnitude is provided).\n", "\n", "The magnitudes are “*Vega like*”. The AB offsets are given by Hewett *et al.*\n", "(2016):\n", "\n", "| Band | AB offset |\n", "|------|-----------|\n", "| J | 0.938 |\n", "| H | 1.379 |\n", "| K | 1.900 |\n", "\n", "A query to the UKIDSS database with 242.9+55.071 position returns a list of images taken between 2007 and 2009. Let's take 2008 for the epoch. TODO: Update for UDS.\n" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This notebook was run with herschelhelp_internal version: \n", "33f5ec7 (Wed Dec 6 16:56:17 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 = \"uds_ra\"\n", "DEC_COL = \"uds_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: 'degrees' did not parse as fits unit: At col 0, Unit 'degrees' not supported by the FITS standard. [astropy.units.core]\n" ] } ], "source": [ "imported_columns = OrderedDict({\n", " 'sourceid': 'uds_id',\n", " 'RA': 'uds_ra',\n", " 'Dec': 'uds_dec',\n", " 'JAPERMAG3': 'm_ap_uds_j',\n", " 'JAPERMAG3ERR': 'merr_ap_uds_j',\n", " 'JKRONMAG': 'm_uds_j',\n", " 'JKRONMAGERR': 'merr_uds_j',\n", " 'HAPERMAG3': 'm_ap_uds_h',\n", " 'HAPERMAG3ERR': 'merr_ap_uds_h',\n", " 'HKRONMAG': 'm_uds_h',\n", " 'HKRONMAGERR': 'merr_uds_h',\n", " 'KAPERMAG3': 'm_ap_uds_k',\n", " 'KAPERMAG3ERR': 'merr_ap_uds_k',\n", " 'KKRONMAG': 'm_uds_k',\n", " 'KKRONMAGERR': 'merr_uds_k',\n", " 'PSTAR': 'uds_stellarity'\n", " })\n", "\n", "catalogue = Table.read(\n", " \"../../dmu0/dmu0_UKIDSS-UDS/data/UKIDSS-UDS_XMM-LSS.fits\")[list(imported_columns)]\n", "for column in imported_columns:\n", " catalogue[column].name = imported_columns[column]\n", "\n", "epoch = 2008\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", " # DXS 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('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 | uds_id | uds_ra | uds_dec | m_ap_uds_j | merr_ap_uds_j | m_uds_j | merr_uds_j | m_ap_uds_h | merr_ap_uds_h | m_uds_h | merr_uds_h | m_ap_uds_k | merr_ap_uds_k | m_uds_k | merr_uds_k | uds_stellarity | f_ap_uds_j | ferr_ap_uds_j | f_uds_j | ferr_uds_j | flag_uds_j | f_ap_uds_h | ferr_ap_uds_h | f_uds_h | ferr_uds_h | flag_uds_h | f_ap_uds_k | ferr_ap_uds_k | f_uds_k | ferr_uds_k | flag_uds_k |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
degrees | degrees | ||||||||||||||||||||||||||||||
0 | 450971566081 | 34.367870813 | -5.56541071827 | nan | nan | nan | nan | nan | nan | nan | nan | 20.0644 | 0.0475614 | 18.1974 | 0.025559 | 0.00703433 | nan | nan | nan | nan | False | nan | nan | nan | nan | False | 34.2181 | 1.49895 | 191.005 | 4.4964 | False |
1 | 450971566082 | 34.7445474465 | -5.56147712705 | nan | nan | nan | nan | nan | nan | nan | nan | 13.8005 | 0.00276986 | 13.6802 | 0.00259286 | 0.695518 | nan | nan | nan | nan | False | nan | nan | nan | nan | False | 10960.1 | 27.9606 | 12243.6 | 29.2391 | False |
2 | 450971566083 | 34.3047073198 | -5.56223642153 | 19.0275 | 0.0897175 | 17.2939 | 0.0397843 | nan | nan | nan | nan | 18.6303 | 0.0214489 | 16.977 | 0.0112291 | 0.00110084 | 88.9229 | 7.34795 | 438.99 | 16.0858 | False | nan | nan | nan | nan | False | 128.195 | 2.53251 | 587.744 | 6.07865 | False |
3 | 450971566084 | 34.3003289695 | -5.56557280323 | nan | nan | nan | nan | nan | nan | nan | nan | 21.7937 | 0.137446 | 21.5441 | 0.134229 | 0.00703433 | nan | nan | nan | nan | False | nan | nan | nan | nan | False | 6.95874 | 0.880926 | 8.75681 | 1.0826 | False |
4 | 450971566085 | 34.3562070077 | -5.56551766795 | nan | nan | nan | nan | nan | nan | nan | nan | 22.8524 | 0.329595 | 22.8094 | 0.310351 | 0.00703433 | nan | nan | nan | nan | False | nan | nan | nan | nan | False | 2.62447 | 0.796705 | 2.73054 | 0.780508 | False |
5 | 450971566086 | 34.2901770877 | -5.56547068484 | nan | nan | nan | nan | nan | nan | nan | nan | 24.7111 | 1.74357 | 24.3629 | 1.22133 | 0.26296 | nan | nan | nan | nan | False | nan | nan | nan | nan | False | 0.473751 | 0.760789 | 0.652908 | 0.734446 | False |
6 | 450971566087 | 34.3925766316 | -5.56549696485 | nan | nan | nan | nan | nan | nan | nan | nan | 23.3221 | 0.493141 | 23.391 | 0.521536 | 0.00703433 | nan | nan | nan | nan | False | nan | nan | nan | nan | False | 1.70273 | 0.773379 | 1.59808 | 0.767642 | False |
7 | 450971566088 | 34.367499354 | -5.56542091583 | nan | nan | nan | nan | nan | nan | nan | nan | 20.3923 | 0.0569566 | 19.0428 | 0.0331051 | 0.00703433 | nan | nan | nan | nan | False | nan | nan | nan | nan | False | 25.298 | 1.32711 | 87.672 | 2.6732 | False |
8 | 450971566089 | 34.0377303354 | -5.56527529519 | nan | nan | nan | nan | nan | nan | nan | nan | 21.1706 | 0.216454 | 21.0224 | 0.201029 | 0.00703433 | nan | nan | nan | nan | False | nan | nan | nan | nan | False | 12.3522 | 2.46256 | 14.1595 | 2.62169 | False |
9 | 450971566090 | 34.3685481147 | -5.565392882 | nan | nan | nan | nan | nan | nan | nan | nan | 20.4193 | 0.0580855 | 18.7035 | 0.0276927 | 0.00703433 | nan | nan | nan | nan | False | nan | nan | nan | nan | False | 24.6753 | 1.3201 | 119.841 | 3.05666 | False |