{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lockman SWIRE master catalogue\n", "## Preparation of Spitzer datafusion SERVS 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", "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, 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 = \"servs_ra\"\n", "DEC_COL = \"servs_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': \"servs_intid\",\n", " 'ra_12': \"servs_ra\",\n", " 'dec_12': \"servs_dec\",\n", " 'flux_aper_2_1': \"f_ap_servs_irac1\",\n", " 'fluxerr_aper_2_1': \"ferr_ap_servs_irac1\",\n", " 'flux_auto_1': \"f_servs_irac1\",\n", " 'fluxerr_auto_1': \"ferr_servs_irac1\",\n", " 'class_star_1': \"servs_stellarity_irac1\",\n", " 'flux_aper_2_2': \"f_ap_servs_irac2\",\n", " 'fluxerr_aper_2_2': \"ferr_ap_servs_irac2\",\n", " 'flux_auto_2': \"f_servs_irac2\",\n", " 'fluxerr_auto_2': \"ferr_servs_irac2\",\n", " 'class_star_2': \"servs_stellarity_irac2\",\n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_DataFusion-Spitzer/data/DF-SERVS_Lockman-SWIRE.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 | servs_intid | servs_ra | servs_dec | f_ap_servs_irac1 | ferr_ap_servs_irac1 | f_servs_irac1 | ferr_servs_irac1 | servs_stellarity_irac1 | f_ap_servs_irac2 | ferr_ap_servs_irac2 | f_servs_irac2 | ferr_servs_irac2 | servs_stellarity_irac2 | m_ap_servs_irac1 | merr_ap_servs_irac1 | m_servs_irac1 | merr_servs_irac1 | flag_servs_irac1 | m_ap_servs_irac2 | merr_ap_servs_irac2 | m_servs_irac2 | merr_servs_irac2 | flag_servs_irac2 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | ||||||||||||||
0 | 2445195 | 161.9661305 | 59.8683213 | 0.484680135832 | 1.14484468772 | 0.699442381801 | 0.464881520935 | 0.58 | nan | nan | nan | nan | nan | 24.6863619477 | 2.56457658235 | 24.2881201393 | 0.721630131851 | False | nan | nan | nan | nan | False |
1 | 2444777 | 161.9699458 | 59.8675804 | 2.45021253918 | 5.91387439354 | 1.87869663987 | 4.42445496895 | 0.52 | nan | nan | nan | nan | nan | 22.9269906048 | 2.62055125292 | 23.2153583535 | 2.55698064507 | False | nan | nan | nan | nan | False |
2 | 2444665 | 161.9733568 | 59.8661043 | 12.7554689484 | 1.18908169449 | 12.1144593468 | 22.9413556748 | 0.22 | nan | nan | nan | nan | nan | 21.1357589254 | 0.101213765746 | 21.1917399078 | 2.05607693496 | False | nan | nan | nan | nan | False |
3 | 2441508 | 161.99893 | 59.861387 | 4.06447865244 | 4.92117056288 | 3.38592397894 | 4.38116510606 | 0.73 | nan | nan | nan | nan | nan | 22.3774878828 | 1.3145826333 | 22.5758069923 | 1.40487193577 | False | nan | nan | nan | nan | False |
4 | 2441122 | 162.0053458 | 59.8592787 | 7.43878531084 | 6.59759420025 | 8.43802993713 | 7.55310478174 | 0.57 | nan | nan | nan | nan | nan | 21.721244938 | 0.962959218231 | 21.5843973453 | 0.97187132316 | False | nan | nan | nan | nan | False |
5 | 2441299 | 161.9990273 | 59.859486 | 1.71927289964 | 1.0259748285 | 1.33510574132 | 0.679967319182 | 0.17 | nan | nan | nan | nan | nan | 23.311637956 | 0.647912275422 | 23.5862108413 | 0.552963794284 | False | nan | nan | nan | nan | False |
6 | 2440958 | 162.0015612 | 59.8588589 | 2.53103864326 | 1.12378607715 | 1.6377394087 | 0.762176093667 | 0.52 | nan | nan | nan | nan | nan | 22.8917530602 | 0.482068985242 | 23.3643880012 | 0.505283181744 | False | nan | nan | nan | nan | False |
7 | 2441119 | 162.0002662 | 59.8589965 | 2.77922814852 | 0.972779212332 | 2.29797224516 | 1.17125038484 | 0.59 | nan | nan | nan | nan | nan | 22.7901895007 | 0.380026954833 | 22.9966380525 | 0.553387426825 | False | nan | nan | nan | nan | False |
8 | 2442120 | 161.9943565 | 59.8627668 | 5.47713894553 | 25.5203858687 | 6.50381028512 | 26.0408710144 | 0.63 | nan | nan | nan | nan | nan | 22.0536156041 | 5.05891984349 | 21.8670803388 | 4.34722343124 | False | nan | nan | nan | nan | False |
9 | 2444458 | 161.9763113 | 59.8638902 | 26.3025884134 | 1.05721887117 | 31.1004474393 | 1.93723350323 | 0.47 | nan | nan | nan | nan | nan | 20.3500037772 | 0.0436406024662 | 20.1680834069 | 0.0676300415173 | False | nan | nan | nan | nan | False |