{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ELAIS-N1 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": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This notebook was run with herschelhelp_internal version: \n", "284b2ef (Mon Aug 14 20:02:12 2017 +0100)\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": { "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" ] }, { "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": false }, "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_ELAIS-N1.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": false }, "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": { "collapsed": false }, "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 | 446677390759 | 242.838870994 | 56.4868458056 | 22.7055 | 0.136046 | 22.7338 | 0.163164 | nan | nan | nan | nan | 0.05 | 3.00481 | 0.376513 | 2.92751 | 0.439945 | False | nan | nan | nan | nan | False |
1 | 446677390773 | 242.970853505 | 56.4879782693 | 19.4216 | 0.0127723 | 19.5628 | 0.0135608 | 20.0352 | 0.0199437 | 19.9826 | 0.0337254 | 0.993865 | 61.8509 | 0.727597 | 54.3098 | 0.678327 | False | 35.1499 | 0.645663 | 36.8928 | 1.14597 | False |
2 | 446677390774 | 242.977347852 | 56.4884122094 | 21.4002 | 0.0470147 | 21.3735 | 0.0510341 | 20.7277 | 0.0345851 | 20.6041 | 0.0488704 | 0.00306749 | 9.99789 | 0.43293 | 10.2472 | 0.481662 | False | 18.574 | 0.591657 | 20.8137 | 0.936853 | False |
3 | 446677390775 | 243.037125114 | 56.488405672 | 19.5736 | 0.0139261 | 19.6774 | 0.0153815 | 19.7516 | 0.0161079 | 19.6516 | 0.0290177 | 0.993865 | 53.7712 | 0.689693 | 48.8694 | 0.692328 | False | 45.6406 | 0.67712 | 50.0461 | 1.33755 | False |
4 | 446677390776 | 242.957527353 | 56.4885667371 | 22.5058 | 0.114633 | 22.8412 | 0.295541 | 21.8621 | 0.0911785 | 21.5646 | 0.150724 | 0.486486 | 3.61131 | 0.381284 | 2.65164 | 0.721783 | False | 6.53385 | 0.548702 | 8.5936 | 1.19298 | False |
5 | 446677390777 | 242.908962456 | 56.4885419471 | 22.081 | 0.0805846 | 22.285 | 0.0841347 | 21.3266 | 0.0575097 | 21.4967 | 0.0577902 | 0.486486 | 5.34057 | 0.396383 | 4.42585 | 0.342963 | False | 10.6994 | 0.56673 | 9.14779 | 0.486907 | False |
6 | 446677390778 | 242.812703145 | 56.4880902835 | 21.2351 | 0.0416058 | 21.1966 | 0.0424853 | 20.1194 | 0.0213113 | 20.0036 | 0.0240502 | 0.00306749 | 11.6407 | 0.446074 | 12.0599 | 0.47191 | False | 32.5279 | 0.638472 | 36.1873 | 0.801587 | False |
7 | 446677390779 | 243.033567366 | 56.4888738571 | 22.1253 | 0.0833997 | 21.6336 | 0.0888386 | 21.6022 | 0.0725171 | 21.2659 | 0.101236 | 0.00306749 | 5.1272 | 0.39384 | 8.0639 | 0.659815 | False | 8.30113 | 0.554438 | 11.3148 | 1.05501 | False |
8 | 446677390780 | 243.038661985 | 56.488773294 | 21.1119 | 0.0379071 | 20.9255 | 0.0501981 | 20.1197 | 0.0212588 | 19.8836 | 0.0292497 | 0.00306749 | 13.0388 | 0.455235 | 15.4817 | 0.715783 | False | 32.5172 | 0.636689 | 40.4174 | 1.08885 | False |
9 | 446677390781 | 242.838465115 | 56.4885370135 | 22.7662 | 0.143322 | 22.9512 | 0.159187 | 21.349 | 0.0584562 | 21.512 | 0.0594584 | 0.133333 | 2.84142 | 0.375079 | 2.39629 | 0.351335 | False | 10.4808 | 0.564288 | 9.01989 | 0.493958 | False |