{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Bootes master catalogue\n", "## Preparation of SDWFS data\n", "\n", "The catalogue comes from `dmu0_SDWFS`.\n", "\n", "In the catalogue, we keep:\n", "\n", "- The identifier (it's unique in the catalogue);\n", "- The position;\n", "- There is no stellarity;\n", "- The magnitude for each band in 2 arcsec aperture.\n", "- The auto magnitude.\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", "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()))\n", "import datetime\n", "print(\"This notebook was executed on: \\n{}\".format(datetime.datetime.now()))" ] }, { "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 = \"sdwfs_ra\"\n", "DEC_COL = \"sdwfs_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: 'vega' did not parse as fits unit: At col 0, Unit 'vega' not supported by the FITS standard. [astropy.units.core]\n" ] } ], "source": [ "imported_columns = OrderedDict({\n", " 'internal_id': \"sdwfs_id\",\n", " 'ra': \"sdwfs_ra\",\n", " 'dec': \"sdwfs_dec\",\n", " #'pstar': \"sdwfs_stellarity\", #No stellarity\n", " 'ch1_4': \"m_ap_sdwfs-irac_i1\", \n", " 'err1_4': \"merr_ap_sdwfs-irac_i1\", \n", " 'ch1_ma': \"m_sdwfs-irac_i1\", \n", " 'err1_ma': \"merr_sdwfs-irac_i1\",\n", " 'ch2_4': \"m_ap_sdwfs-irac_i2\", \n", " 'err2_4': \"merr_ap_sdwfs-irac_i2\", \n", " 'ch2_ma': \"m_sdwfs-irac_i2\", \n", " 'err2_ma': \"merr_sdwfs-irac_i2\",\n", " 'ch3_4': \"m_ap_sdwfs-irac_i3\", \n", " 'err3_4': \"merr_ap_sdwfs-irac_i3\", \n", " 'ch3_ma': \"m_sdwfs-irac_i3\", \n", " 'err3_ma': \"merr_sdwfs-irac_i3\",\n", " 'ch4_4': \"m_ap_sdwfs-irac_i4\", \n", " 'err4_4': \"merr_ap_sdwfs-irac_i4\", \n", " 'ch4_ma': \"m_sdwfs-irac_i4\", \n", " 'err4_ma': \"merr_sdwfs-irac_i4\",\n", "\n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_SDWFS/data/SDWFS_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": 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", "/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/ipykernel/__main__.py:8: RuntimeWarning: invalid value encountered in less_equal\n", "/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/ipykernel/__main__.py:9: RuntimeWarning: invalid value encountered in less_equal\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", " catalogue[col][catalogue[col] <= 0] = np.nan\n", " catalogue[errcol][catalogue[errcol] <= 0] = np.nan \n", " \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 | sdwfs_id | sdwfs_ra | sdwfs_dec | m_ap_sdwfs-irac_i1 | merr_ap_sdwfs-irac_i1 | m_sdwfs-irac_i1 | merr_sdwfs-irac_i1 | m_ap_sdwfs-irac_i2 | merr_ap_sdwfs-irac_i2 | m_sdwfs-irac_i2 | merr_sdwfs-irac_i2 | m_ap_sdwfs-irac_i3 | merr_ap_sdwfs-irac_i3 | m_sdwfs-irac_i3 | merr_sdwfs-irac_i3 | m_ap_sdwfs-irac_i4 | merr_ap_sdwfs-irac_i4 | m_sdwfs-irac_i4 | merr_sdwfs-irac_i4 | f_ap_sdwfs-irac_i1 | ferr_ap_sdwfs-irac_i1 | f_sdwfs-irac_i1 | ferr_sdwfs-irac_i1 | flag_sdwfs-irac_i1 | f_ap_sdwfs-irac_i2 | ferr_ap_sdwfs-irac_i2 | f_sdwfs-irac_i2 | ferr_sdwfs-irac_i2 | flag_sdwfs-irac_i2 | f_ap_sdwfs-irac_i3 | ferr_ap_sdwfs-irac_i3 | f_sdwfs-irac_i3 | ferr_sdwfs-irac_i3 | flag_sdwfs-irac_i3 | f_ap_sdwfs-irac_i4 | ferr_ap_sdwfs-irac_i4 | f_sdwfs-irac_i4 | ferr_sdwfs-irac_i4 | flag_sdwfs-irac_i4 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | vega | vega | vega | vega | vega | vega | vega | vega | vega | vega | vega | vega | vega | vega | vega | vega | ||||||||||||||||||||||
0 | SDWFS1_J142539.66+322451.39 | 216.4152499 | 32.4142753 | 19.2812 | 0.1515 | 19.5155 | 0.2026 | 19.134 | 0.3282 | 19.2422 | 0.3724 | nan | nan | nan | nan | nan | nan | 17.3342 | 0.9904 | 70.3914643657 | 9.82218959327 | 56.7283301631 | 10.5855912704 | False | 80.6120563864 | 24.3676841484 | 72.9659094662 | 25.026801691 | False | nan | nan | nan | nan | False | nan | nan | 422.980162774 | 385.839167356 | False |
1 | SDWFS1_J142543.62+322403.85 | 216.4317382 | 32.4010685 | 15.0799 | 0.003 | 15.1069 | 0.0066 | 15.0165 | 0.0068 | 15.0645 | 0.0144 | 14.9936 | 0.0534 | 15.235 | 0.1139 | 14.8096 | 0.0935 | 15.0087 | 0.173 | 3373.18375399 | 9.32045115343 | 3290.33411226 | 20.0013640936 | False | 3576.02050181 | 22.3967288792 | 3421.36966135 | 45.377249932 | False | 3652.2458141 | 179.629200554 | 2924.15237784 | 306.760476787 | False | 4326.73204375 | 372.603809579 | 3601.8033693 | 573.907345227 | False |
2 | SDWFS1_J142543.48+322434.48 | 216.4311511 | 32.4095765 | 18.7088 | 0.092 | 18.8704 | 0.1331 | 18.4072 | 0.1572 | 18.6844 | 0.2615 | nan | nan | nan | nan | 17.2022 | 0.9279 | nan | nan | 119.25593452 | 10.1051672845 | 102.763763268 | 12.5977717525 | False | 157.441783209 | 22.7954527187 | 121.966342364 | 29.3756424336 | False | nan | nan | nan | nan | False | 477.661238103 | 408.222421702 | nan | nan | False |
3 | SDWFS1_J142544.71+322425.88 | 216.4362768 | 32.4071888 | 19.627 | 0.1931 | 19.8869 | 0.2369 | 19.3525 | 0.3293 | 19.9898 | 0.6671 | nan | nan | nan | nan | nan | nan | nan | nan | 51.1917528 | 9.10453885792 | 40.2939645487 | 8.79185953251 | False | 65.9173895244 | 19.9925140888 | 36.6505081161 | 22.5188713954 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
4 | SDWFS1_J142548.52+322321.00 | 216.4521556 | 32.3891677 | 18.8789 | 0.1033 | 18.9993 | 0.1542 | 18.86 | 0.2635 | 18.805 | 0.3018 | nan | nan | nan | nan | nan | nan | nan | nan | 101.962388407 | 9.70098876345 | 91.2599024062 | 12.9610460528 | False | 103.752841582 | 25.1800332687 | 109.144033645 | 30.3385566491 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
5 | SDWFS1_J142548.14+322334.53 | 216.4505634 | 32.3929256 | 18.7385 | 0.0868 | 18.9802 | 0.137 | 18.7159 | 0.2043 | 18.9426 | 0.3112 | 17.324 | 0.6845 | 17.1069 | 0.3911 | 16.7049 | 0.6122 | 17.1775 | 0.9336 | 116.037937261 | 9.27674043672 | 92.8795280608 | 11.7196933183 | False | 118.47862354 | 22.2937972255 | 96.1523714698 | 27.5597496614 | False | 426.972594048 | 269.183931921 | 521.482813545 | 187.846667988 | False | 755.161777433 | 425.803282711 | 488.652359343 | 420.181109079 | False |
6 | SDWFS1_J142547.25+322340.16 | 216.4468896 | 32.3944897 | 15.3197 | 0.0038 | 15.4246 | 0.0076 | 15.2685 | 0.0084 | 15.3828 | 0.0168 | 15.2319 | 0.0661 | 15.3251 | 0.1076 | 15.0596 | 0.1169 | 15.3485 | 0.2066 | 2704.70559864 | 9.46627848441 | 2455.61343048 | 17.1889469927 | False | 2835.30641176 | 21.9358751734 | 2551.99606266 | 39.4879839733 | False | 2932.51336433 | 178.532439586 | 2691.28691583 | 266.715313419 | False | 3436.84542644 | 370.041294183 | 2633.90435275 | 501.194154614 | False |
7 | SDWFS1_J142549.36+322324.66 | 216.4556545 | 32.3901842 | 17.1564 | 0.0212 | 17.1632 | 0.0356 | 16.9298 | 0.041 | 16.883 | 0.0633 | 16.6553 | 0.2382 | 16.3685 | 0.2694 | 15.445 | 0.1736 | 15.7861 | 0.2947 | 498.241616592 | 9.72862673775 | 495.130865212 | 16.2347527183 | False | 613.875074718 | 23.1813933745 | 640.914356645 | 37.3662392373 | False | 790.460185601 | 173.419303312 | 1029.43753666 | 255.43080461 | False | 2409.90542869 | 385.323415197 | 1760.19182649 | 477.766633363 | False |
8 | SDWFS1_J142546.77+322405.38 | 216.4448943 | 32.4014947 | 19.3974 | 0.1683 | 19.4542 | 0.1937 | 18.9078 | 0.2409 | 19.3702 | 0.4299 | nan | nan | nan | nan | nan | nan | 17.3053 | 0.966 | 63.2470101343 | 9.80392084095 | 60.023318151 | 10.7084176386 | False | 99.2841678223 | 22.0288831887 | 64.8514961674 | 25.6781141498 | False | nan | nan | nan | nan | False | nan | nan | 434.390181145 | 386.485145422 | False |
9 | SDWFS1_J142547.55+322347.96 | 216.4481124 | 32.3966543 | 19.3165 | 0.1454 | 19.4394 | 0.275 | 18.7772 | 0.2247 | 19.0355 | 0.4519 | nan | nan | 17.1228 | 0.5317 | nan | nan | nan | nan | 68.1396659283 | 9.12515156311 | 60.8471161976 | 15.4116228979 | False | 111.974723832 | 23.1738799303 | 88.2673320721 | 36.7382124577 | False | nan | nan | 513.901635694 | 251.664721597 | False | nan | nan | nan | nan | False |