{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Bootes master catalogue\n", "## Preparation of NDWFS data\n", "\n", "The catalogue comes from `dmu0_NDWFS`.\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 2 arcsec aperture.\n", "- The kron magnitude to be used as total magnitude (no “auto” magnitude is provided).\n", "\n", "We don't know when the maps have been observed. We will use the year of the reference paper." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This notebook was run with herschelhelp_internal version: \n", "0246c5d (Thu Jan 25 17:01:47 2018 +0000) [with local modifications]\n", "This notebook was executed on: \n", "2018-02-16 14:55:54.137896\n" ] } ], "source": [ "from herschelhelp_internal import git_version\n", "print(\"This notebook was run with herschelhelp_internal version: \\n{}\".format(git_version()))\n", "import datetime\n", "print(\"This notebook was executed on: \\n{}\".format(datetime.datetime.now()))" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/Users/rs548/anaconda/envs/herschelhelp_internal/lib/python3.6/site-packages/seaborn/apionly.py:6: UserWarning: As seaborn no longer sets a default style on import, the seaborn.apionly module is deprecated. It will be removed in a future version.\n", " warnings.warn(msg, UserWarning)\n" ] } ], "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 = \"ndwfs_ra\"\n", "DEC_COL = \"ndwfs_dec\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I - Column selection" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## 1.i - Aperture correction\n", "TODO" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "imported_columns = OrderedDict({\n", " 'ndwfs_name': \"ndwfs_id\",\n", " 'ra': \"ndwfs_ra\",\n", " 'dec': \"ndwfs_dec\",\n", " 'k_class_star': \"ndwfs_stellarity\",\n", " 'r_mag_aper_02': \"m_ap_mosaic_r\", \n", " 'r_magerr_aper_02': \"merr_ap_mosaic_r\", \n", " 'r_mag_auto': \"m_mosaic_r\", \n", " 'r_magerr_auto': \"merr_mosaic_r\",\n", " 'i_mag_aper_02': \"m_ap_mosaic_i\", \n", " 'i_magerr_aper_02': \"merr_ap_mosaic_i\", \n", " 'i_mag_auto': \"m_mosaic_i\", \n", " 'i_magerr_auto': \"merr_mosaic_i\",\n", " 'b_mag_aper_02': \"m_ap_mosaic_b\", \n", " 'b_magerr_aper_02': \"merr_ap_mosaic_b\", \n", " 'b_mag_auto': \"m_mosaic_b\", \n", " 'b_magerr_auto': \"merr_mosaic_b\",\n", " 'k_mag_aper_02': \"m_ap_tifkam_ks\", \n", " 'k_magerr_aper_02': \"merr_ap_tifkam_ks\", \n", " 'k_mag_auto': \"m_tifkam_ks\", \n", " 'k_magerr_auto': \"merr_tifkam_ks\"\n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_NDWFS/data/NDWFS_MLselected_20160801.fits\")[list(imported_columns)]\n", "for column in imported_columns:\n", " catalogue[column].name = imported_columns[column]\n", "\n", "epoch = 2011\n", "\n", "# Clean table metadata\n", "catalogue.meta = None" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# http://svo2.cab.inta-csic.es/svo/theory/fps3/index.php?mode=browse&gname=KPNO&gname2=TIFKAM\n", "# ZP 688.5 taken from above\n", "ks_to_AB = 2.5 * np.log10(3631/688.5)" ] }, { "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", " # Some object have a magnitude to 0, we suppose this means missing value\n", " mask = (catalogue[col] <= 0) | (catalogue[col] > 90.)\n", " catalogue[col][mask] = np.nan\n", " catalogue[errcol][mask] = np.nan \n", " \n", " if col.endswith('tifkam_ks'):\n", " catalogue[col] += ks_to_AB\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.\n", "\n", "catalogue[\"ndwfs_stellarity\"][catalogue[\"ndwfs_stellarity\"] < 0.] = np.nan" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<Table masked=True length=10>\n", "
idx | ndwfs_id | ndwfs_ra | ndwfs_dec | ndwfs_stellarity | m_ap_mosaic_r | merr_ap_mosaic_r | m_mosaic_r | merr_mosaic_r | m_ap_mosaic_i | merr_ap_mosaic_i | m_mosaic_i | merr_mosaic_i | m_ap_mosaic_b | merr_ap_mosaic_b | m_mosaic_b | merr_mosaic_b | m_ap_mosaic_ks | merr_ap_mosaic_ks | m_mosaic_ks | merr_mosaic_ks | f_ap_mosaic_r | ferr_ap_mosaic_r | f_mosaic_r | ferr_mosaic_r | flag_mosaic_r | f_ap_mosaic_i | ferr_ap_mosaic_i | f_mosaic_i | ferr_mosaic_i | flag_mosaic_i | f_ap_mosaic_b | ferr_ap_mosaic_b | f_mosaic_b | ferr_mosaic_b | flag_mosaic_b | f_ap_mosaic_ks | ferr_ap_mosaic_ks | f_mosaic_ks | ferr_mosaic_ks | flag_mosaic_ks |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | |||||||||||||||||||||||
0 | NDWFS_J142539.6+322451 | 216.415294 | 32.4143894 | nan | 22.3396 | 0.0097 | 21.3357 | 0.015 | 21.8976 | 0.0109 | 20.8977 | 0.0171 | 23.6295 | 0.0128 | 22.529 | 0.0186 | nan | nan | nan | nan | 4.20881658358 | 0.0376016942991 | 10.6101127739 | 0.146584125049 | False | 6.32353606774 | 0.0634836922969 | 15.8825415442 | 0.250144979246 | False | 1.28292125371 | 0.0151246610139 | 3.53508613362 | 0.0605603845549 | False | nan | nan | nan | nan | False |
1 | NDWFS_J142540.4+322444 | 216.41843 | 32.4122584 | nan | nan | nan | nan | nan | nan | nan | nan | nan | 26.7348 | 0.2166 | 26.5861 | 0.2988 | nan | nan | nan | nan | nan | nan | nan | nan | False | nan | nan | nan | nan | False | 0.0734649183074 | 0.0146559553192 | 0.0842480776419 | 0.0231854897065 | False | nan | nan | nan | nan | False |
2 | NDWFS_J142543.3+322356 | 216.4306632 | 32.3991127 | nan | nan | nan | nan | nan | nan | nan | nan | nan | 27.1726 | 0.3243 | 26.7844 | 0.3222 | nan | nan | nan | nan | nan | nan | nan | nan | False | nan | nan | nan | nan | False | 0.0490862663948 | 0.0146616425998 | 0.0701843044071 | 0.0208276953286 | False | nan | nan | nan | nan | False |
3 | NDWFS_J142543.4+322400 | 216.4309365 | 32.400052 | nan | 24.5978 | 0.0758 | 23.3095 | 0.1095 | nan | nan | nan | nan | 25.8591 | 0.0971 | 25.037 | 0.1229 | nan | nan | nan | nan | 0.525871942527 | 0.0367134236372 | 1.72266170738 | 0.173735992345 | False | nan | nan | nan | nan | False | 0.164573535841 | 0.0147182071116 | 0.350913438359 | 0.039721675841 | False | nan | nan | nan | nan | False |
4 | NDWFS_J142543.6+322400 | 216.4319508 | 32.4000057 | nan | nan | nan | nan | nan | nan | nan | nan | nan | 27.0972 | 0.3018 | 26.8503 | 0.2817 | nan | nan | nan | nan | nan | nan | nan | nan | False | nan | nan | nan | nan | False | 0.0526162630415 | 0.0146256412159 | 0.066051091688 | 0.017137305035 | False | nan | nan | nan | nan | False |
5 | NDWFS_J142543.6+322404 | 216.431911 | 32.4011937 | nan | 18.5533 | 0.0005 | 18.2702 | 0.0008 | 17.8866 | 0.0012 | 17.4367 | 0.001 | 21.1505 | 0.0017 | 20.8216 | 0.0029 | nan | nan | nan | nan | 137.619507722 | 0.0633761253971 | 178.615852199 | 0.131609023566 | False | 254.307986889 | 0.281071574227 | 384.875264169 | 0.354483218375 | False | 12.5834578869 | 0.0197026481331 | 17.0357006469 | 0.0455023344155 | False | nan | nan | nan | nan | False |
6 | NDWFS_J142542.3+322417 | 216.4264442 | 32.4048224 | nan | 25.5278 | 0.1778 | 25.2629 | 0.1886 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 0.223295514927 | 0.0365668404352 | 0.284996810702 | 0.0495059465299 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
7 | NDWFS_J142540.8+322442 | 216.4203557 | 32.4118799 | nan | 24.3822 | 0.0621 | 23.969 | 0.0972 | 24.0534 | 0.0788 | 23.2765 | 0.1153 | 25.5978 | 0.076 | 25.1596 | 0.1155 | nan | nan | nan | nan | 0.641386773818 | 0.0366848949861 | 0.938425931237 | 0.0840121201785 | False | 0.868240419827 | 0.0630147035556 | 1.77582432255 | 0.188584062586 | False | 0.209353391113 | 0.0146544415253 | 0.31344402821 | 0.0333439974642 | False | nan | nan | nan | nan | False |
8 | NDWFS_J142541.1+322444 | 216.4213122 | 32.4124599 | nan | 25.1522 | 0.1261 | 24.7566 | 0.1979 | 24.4948 | 0.1184 | 23.8696 | 0.1698 | 27.0091 | 0.2781 | 26.7996 | 0.415 | nan | nan | nan | nan | 0.315587650382 | 0.0366531046296 | 0.454318058763 | 0.0828097501355 | False | 0.578202546442 | 0.063053236319 | 1.0283951031 | 0.160832334541 | False | 0.0570637094854 | 0.0146162737674 | 0.0692085897824 | 0.0264535387453 | False | nan | nan | nan | nan | False |
9 | NDWFS_J142543.0+322415 | 216.4292291 | 32.4043039 | nan | 25.7661 | 0.2229 | 25.555 | 0.2165 | 25.1463 | 0.2153 | 24.3406 | 0.278 | nan | nan | nan | nan | nan | nan | nan | nan | 0.179291623579 | 0.036808299033 | 0.217770977235 | 0.0434243754282 | False | 0.317307253508 | 0.0629215930913 | 0.666438379974 | 0.170639855999 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |