{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lockman SWIRE 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", "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 = \"dxs_ra\"\n", "DEC_COL = \"dxs_dec\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I - Column selection" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "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_Lockman-SWIRE.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": {}, "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 | 446676598786 | 160.060324474 | 59.4917579339 | 21.7126 | 0.060491 | 21.6854 | 0.0540272 | nan | nan | nan | nan | 0.05 | 7.49856 | 0.417777 | 7.68832 | 0.382578 | False | nan | nan | nan | nan | False |
1 | 446676598788 | 160.051986788 | 59.4921331974 | 21.811 | 0.0654013 | 21.7814 | 0.0582999 | nan | nan | nan | nan | 0.05 | 6.8484 | 0.412526 | 7.0381 | 0.377919 | False | nan | nan | nan | nan | False |
2 | 446676598791 | 160.051277326 | 59.4923902932 | 22.0418 | 0.0787619 | 22.0475 | 0.0722757 | nan | nan | nan | nan | 0.05 | 5.53692 | 0.401661 | 5.50793 | 0.366654 | False | nan | nan | nan | nan | False |
3 | 446676598795 | 160.052260214 | 59.4931811266 | 22.3646 | 0.102819 | 22.4193 | 0.0984169 | nan | nan | nan | nan | 0.05 | 4.11317 | 0.389515 | 3.91094 | 0.354509 | False | nan | nan | nan | nan | False |
4 | 446676598821 | 160.131305879 | 59.4958610446 | 23.0189 | 0.17976 | 23.2399 | 0.199689 | 22.6595 | 0.200974 | 22.642 | 0.212253 | 0.486486 | 2.2513 | 0.372737 | 1.83672 | 0.33781 | False | 3.13481 | 0.580264 | 3.18566 | 0.622773 | False |
5 | 446676598825 | 160.247525395 | 59.4963718058 | 21.3719 | 0.046424 | 21.2722 | 0.0533483 | 20.8497 | 0.040713 | 20.6859 | 0.0554209 | 0.00306749 | 10.2621 | 0.438787 | 11.2494 | 0.552746 | False | 16.6007 | 0.622493 | 19.3029 | 0.985308 | False |
6 | 446676598826 | 160.32538114 | 59.4968446306 | 22.9469 | 0.168562 | 22.91 | 0.175624 | 22.4461 | 0.165549 | 22.3676 | 0.2077 | 0.486486 | 2.40578 | 0.3735 | 2.48892 | 0.402598 | False | 3.81542 | 0.58176 | 4.10168 | 0.784649 | False |
7 | 446676598827 | 160.217527948 | 59.4965364809 | 22.1532 | 0.0861728 | 22.1537 | 0.0872162 | 21.4451 | 0.0679995 | 21.2215 | 0.118569 | 0.00306749 | 4.99722 | 0.396619 | 4.99463 | 0.401214 | False | 9.59338 | 0.600832 | 11.787 | 1.28722 | False |
8 | 446676598828 | 160.233828551 | 59.4968124367 | 22.5131 | 0.116376 | 22.0895 | 0.132629 | 21.1642 | 0.0532933 | 21.12 | 0.0604209 | 0.00306749 | 3.58728 | 0.384507 | 5.29892 | 0.647293 | False | 12.4261 | 0.609935 | 12.942 | 0.720217 | False |
9 | 446676598830 | 160.243025929 | 59.4967746935 | 21.2885 | 0.0436053 | 21.4842 | 0.0441724 | 21.5352 | 0.0735355 | 21.6232 | 0.10509 | 0.993865 | 11.0812 | 0.445044 | 9.25407 | 0.376495 | False | 8.82944 | 0.598006 | 8.14143 | 0.788022 | False |