{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Bootes master catalogue\n", "## Preparation of Spitzer datafusion data\n", "\n", "The Spitzer catalogues were produced by the datafusion team are available in `dmu0_DataFusion-Spitzer`.\n", "Lucia told that the magnitudes are aperture corrected.\n", "\n", "In the catalouge, we keep:\n", "\n", "- The internal identifier (this one is only in HeDaM data);\n", "- The position;\n", "- The fluxes in aperture 2 (1.9 arcsec);\n", "- The “auto” flux (which seems to be the Kron flux);\n", "- The stellarity in each band\n", "\n", "A query of the position in the Spitzer heritage archive show that the SERVS-ELAIS-N1 images were observed in 2009. Let's take this as epoch." ] }, { "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, flux_to_mag" ] }, { "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 = \"datafusion_ra\"\n", "DEC_COL = \"datafusion_dec\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I - Column selection" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "imported_columns = OrderedDict({\n", " 'internal_id': \"datafusion_intid\",\n", " 'ra_spitzer': \"datafusion_ra\",\n", " 'dec_spitzer': \"datafusion_dec\",\n", " 'class_star_1': \"datafusion_stellarity\",\n", " 'flux_aper_2_1': \"f_ap_irac_i1\",\n", " 'fluxerr_aper_2_1': \"ferr_ap_irac_i1\",\n", " 'flux_auto_1': \"f_irac_i1\",\n", " 'fluxerr_auto_1': \"ferr_irac_i1\",\n", " 'flux_aper_2_2': \"f_ap_irac_i2\",\n", " 'fluxerr_aper_2_2': \"ferr_ap_irac_i2\",\n", " 'flux_auto_2': \"f_irac_i2\",\n", " 'fluxerr_auto_2': \"ferr_irac_i2\",\n", " 'flux_aper_2_3': \"f_ap_irac_i3\",\n", " 'fluxerr_aper_2_3': \"ferr_ap_irac_i3\",\n", " 'flux_auto_3': \"f_irac_i3\",\n", " 'fluxerr_auto_3': \"ferr_irac_i3\",\n", " 'flux_aper_2_4': \"f_ap_irac_i4\",\n", " 'fluxerr_aper_2_4': \"ferr_ap_irac_i4\",\n", " 'flux_auto_4': \"f_irac_i4\",\n", " 'fluxerr_auto_4': \"ferr_irac_i4\"\n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_DataFusion-Spitzer/data/Datafusion-Bootes.fits\")[list(imported_columns)]\n", "for column in imported_columns:\n", " catalogue[column].name = imported_columns[column]\n", "\n", "epoch = 2009\n", "\n", "# Clean table metadata\n", "catalogue.meta = None" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/herschelhelp_internal/herschelhelp_internal/utils.py:76: RuntimeWarning: invalid value encountered in log10\n", " magnitudes = 2.5 * (23 - np.log10(fluxes)) - 48.6\n" ] } ], "source": [ "# Adding magnitude and band-flag columns\n", "for col in catalogue.colnames:\n", " if col.startswith('f_'):\n", " errcol = \"ferr{}\".format(col[1:])\n", " \n", " magnitude, error = flux_to_mag(\n", " np.array(catalogue[col])/1.e6, np.array(catalogue[errcol])/1.e6)\n", " # Note that some fluxes are 0.\n", " \n", " catalogue.add_column(Column(magnitude, name=\"m{}\".format(col[1:])))\n", " catalogue.add_column(Column(error, name=\"m{}\".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" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<Table masked=True length=10>\n", "
idx | datafusion_intid | datafusion_ra | datafusion_dec | datafusion_stellarity | f_ap_irac_i1 | ferr_ap_irac_i1 | f_irac_i1 | ferr_irac_i1 | f_ap_irac_i2 | ferr_ap_irac_i2 | f_irac_i2 | ferr_irac_i2 | f_ap_irac_i3 | ferr_ap_irac_i3 | f_irac_i3 | ferr_irac_i3 | f_ap_irac_i4 | ferr_ap_irac_i4 | f_irac_i4 | ferr_irac_i4 | m_ap_irac_i1 | merr_ap_irac_i1 | m_irac_i1 | merr_irac_i1 | flag_irac_i1 | m_ap_irac_i2 | merr_ap_irac_i2 | m_irac_i2 | merr_irac_i2 | flag_irac_i2 | m_ap_irac_i3 | merr_ap_irac_i3 | m_irac_i3 | merr_irac_i3 | flag_irac_i3 | m_ap_irac_i4 | merr_ap_irac_i4 | m_irac_i4 | merr_irac_i4 | flag_irac_i4 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | |||||||||||||||||||||||
0 | 9628 | 216.415287 | 32.414271 | 0.01 | 4.65085050555 | 0.742465546871 | 3.56478294261 | 0.931315447652 | 3.42755702386 | 1.12439983793 | 2.85705327949 | 1.61363990303 | nan | nan | nan | nan | nan | nan | nan | nan | 22.23116905 | 0.173327808335 | 22.5199172723 | 0.283653427388 | False | 22.5625382779 | 0.356172517092 | 22.7602041516 | 0.613214768078 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
1 | 9209 | 216.431747 | 32.401077 | 0.98 | 235.278919897 | 1.67713839944 | 250.170648907 | 1.9299961385 | 165.328257136 | 1.81758822614 | 168.856635241 | 2.55610698248 | 109.226806696 | 5.68480526773 | 100.634446075 | 7.78674901715 | 69.0469911415 | 6.36509362814 | 65.3002704168 | 7.39161793287 | 17.9710424556 | 0.00773945188741 | 17.9044091124 | 0.00837614920762 | False | 18.3541322812 | 0.0119363826647 | 18.3312046726 | 0.0164355868524 | False | 18.8041769075 | 0.0565080961615 | 18.8931333489 | 0.0840105516059 | False | 19.3021381048 | 0.100088540927 | 19.3627125506 | 0.122899141921 | False |
2 | 873519 | 216.426548 | 32.405033 | nan | nan | nan | nan | nan | 2.47228487006 | 1.10804218194 | 1.9990834092 | 1.12646709176 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | False | 22.9172537223 | 0.486611202416 | 23.1479227128 | 0.611803439197 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
3 | 8715 | 216.432692 | 32.405028 | 0.0 | 2.97314571931 | 0.767184858772 | 3.22199412382 | 1.22074992299 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 22.7169595118 | 0.280161302388 | 22.6296881399 | 0.411363999254 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
4 | 9156 | 216.431079 | 32.409614 | 0.03 | 8.23410676545 | 0.778054856022 | 7.60291136842 | 1.05040305426 | 7.83549785228 | 1.05773050527 | 7.05430671217 | 1.36356103997 | nan | nan | nan | nan | nan | nan | nan | nan | 21.6109587653 | 0.102593074214 | 21.6975501808 | 0.150003146207 | False | 21.6648335102 | 0.146565837436 | 21.7788641542 | 0.209867198705 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
5 | 8863 | 216.436274 | 32.407125 | 0.13 | 3.63269110463 | 0.758751883633 | 2.90856112827 | 0.872856907596 | 3.93509983131 | 1.10075754529 | 2.90118349377 | 1.00768335191 | nan | nan | nan | nan | nan | nan | nan | nan | 22.4994288239 | 0.22677523818 | 22.7408045109 | 0.325828581335 | False | 22.4126106134 | 0.303710800439 | 22.7435620053 | 0.377114477746 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
6 | 6590 | 216.453982 | 32.3865 | 0.13 | 1.85530861838 | 0.611971255856 | 1.73460147052 | 0.812366562827 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 23.228959595 | 0.358128745897 | 23.3020007244 | 0.508483247469 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
7 | 872933 | 216.455068 | 32.387238 | nan | nan | nan | nan | nan | 3.86782304095 | 1.06994715463 | 3.97170711653 | 1.32994412869 | 7.39664467399 | 4.96109620887 | 8.34441230991 | 5.09535874721 | nan | nan | nan | nan | nan | nan | nan | nan | False | 22.4313335095 | 0.30034475483 | 22.4025569624 | 0.363563688976 | False | 21.7274131095 | 0.728227731177 | 21.5965106123 | 0.662984433488 | False | nan | nan | nan | nan | False |
8 | 6843 | 216.455197 | 32.387517 | 0.09 | 1.97900414205 | 0.613551848216 | 1.89865440347 | 0.705613026038 | nan | nan | nan | nan | 7.39664467399 | 4.96109620887 | 8.34441230991 | 5.09535874721 | nan | nan | nan | nan | 23.158883242 | 0.336611450653 | 23.2038851979 | 0.403501346805 | False | nan | nan | nan | nan | False | 21.7274131095 | 0.728227731177 | 21.5965106123 | 0.662984433488 | False | nan | nan | nan | nan | False |
9 | 7134 | 216.452205 | 32.389113 | 0.04 | 7.26403119488 | 0.653240494038 | 7.18430188368 | 0.96744395326 | 5.6953165666 | 1.08953633021 | 6.7629092715 | 1.83077182191 | nan | nan | nan | nan | nan | nan | nan | nan | 21.7470557486 | 0.0976381895623 | 21.7590385674 | 0.146206123175 | False | 22.0112053281 | 0.207705581644 | 21.8246660971 | 0.293917184144 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |