{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# XMM-LSS master catalogue\n", "## Preparation of UKIRT Infrared Deep Sky Survey / Deep Extragalactic Survey (UKIDSS/DXS)\n", "\n", "The catalogue comes from `dmu0_UKIDSS-DXS_DR10plus`.\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.\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 = \"dxs_ra\"\n", "DEC_COL = \"dxs_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': 'dxs_id',\n", " 'RA': 'dxs_ra',\n", " 'Dec': 'dxs_dec',\n", " 'JAPERMAG3': 'm_ap_ukidss_j',\n", " 'JAPERMAG3ERR': 'merr_ap_ukidss_j',\n", " 'JKRONMAG': 'm_ukidss_j',\n", " 'JKRONMAGERR': 'merr_ukidss_j',\n", " 'KAPERMAG3': 'm_ap_ukidss_k',\n", " 'KAPERMAG3ERR': 'merr_ap_ukidss_k',\n", " 'KKRONMAG': 'm_ukidss_k',\n", " 'KKRONMAGERR': 'merr_ukidss_k',\n", " 'PSTAR': 'dxs_stellarity'\n", " })\n", "\n", "catalogue = Table.read(\n", " \"../../dmu0/dmu0_UKIDSS-DXS_DR10plus/data/UKIDSS-DR10plus_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('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 | dxs_id | dxs_ra | dxs_dec | m_ap_ukidss_j | merr_ap_ukidss_j | m_ukidss_j | merr_ukidss_j | m_ap_ukidss_k | merr_ap_ukidss_k | m_ukidss_k | merr_ukidss_k | dxs_stellarity | f_ap_ukidss_j | ferr_ap_ukidss_j | f_ukidss_j | ferr_ukidss_j | flag_ukidss_j | f_ap_ukidss_k | ferr_ap_ukidss_k | f_ukidss_k | ferr_ukidss_k | flag_ukidss_k |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
degrees | degrees | |||||||||||||||||||||
0 | 446679347818 | 34.91798053 | -2.55580229131 | nan | nan | nan | nan | 19.3136 | 0.0121872 | 19.3094 | 0.0128282 | 0.05 | nan | nan | nan | nan | False | 68.321 | 0.766893 | 68.5892 | 0.810394 | False |
1 | 446679347819 | 34.9572533827 | -2.55559991421 | nan | nan | nan | nan | 20.5912 | 0.0318615 | 20.5896 | 0.0431118 | 0.05 | nan | nan | nan | nan | False | 21.0625 | 0.618088 | 21.0937 | 0.837575 | False |
2 | 446679347820 | 34.9573000353 | -2.55565754591 | nan | nan | nan | nan | 21.0413 | 0.0462253 | 21.5479 | 0.14819 | 0.05 | nan | nan | nan | nan | False | 13.9151 | 0.592437 | 8.72648 | 1.19106 | False |
3 | 446679347822 | 34.8941725314 | -2.55479271224 | nan | nan | nan | nan | 21.5662 | 0.0725572 | 21.7644 | 0.075405 | 0.9 | nan | nan | nan | nan | False | 8.58042 | 0.573409 | 7.14912 | 0.496511 | False |
4 | 446679347824 | 34.799567038 | -2.5547325608 | nan | nan | nan | nan | 20.9516 | 0.0430978 | 21.0156 | 0.0504331 | 0.05 | nan | nan | nan | nan | False | 15.1132 | 0.599912 | 14.2479 | 0.661823 | False |
5 | 446679347825 | 34.7684661738 | -2.55457775799 | nan | nan | nan | nan | 21.6057 | 0.0754797 | 22.0474 | 0.0717686 | 0.05 | nan | nan | nan | nan | False | 8.27444 | 0.575233 | 5.50836 | 0.36411 | False |
6 | 446679347826 | 34.7971903201 | -2.55448072181 | nan | nan | nan | nan | 21.3026 | 0.0580236 | 21.3265 | 0.0887633 | 0.05 | nan | nan | nan | nan | False | 10.9387 | 0.584581 | 10.7007 | 0.874826 | False |
7 | 446679347827 | 34.8328363286 | -2.55434509318 | nan | nan | nan | nan | 21.6178 | 0.0760388 | 21.8534 | 0.0792593 | 0.9 | nan | nan | nan | nan | False | 8.1826 | 0.573063 | 6.58601 | 0.480782 | False |
8 | 446679347828 | 34.9599928558 | -2.55436551507 | nan | nan | nan | nan | 19.9997 | 0.0200162 | 20.1869 | 0.0204446 | 0.05 | nan | nan | nan | nan | False | 36.3177 | 0.669537 | 30.5648 | 0.575539 | False |
9 | 446679347829 | 34.835910565 | -2.55451541625 | nan | nan | nan | nan | 19.2271 | 0.0115101 | 19.234 | 0.0119382 | 0.05 | nan | nan | nan | nan | False | 73.9884 | 0.784366 | 73.5214 | 0.808402 | False |