{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ELAIS-S1 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_ELAIS-S1.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 | 1826888 | 8.3872733 | -44.6890863 | nan | nan | nan | nan | nan | 3.87648277985 | 0.911632304247 | 5.13522702552 | 1.48742162345 | 0.8 | nan | nan | nan | nan | False | 22.4289053523 | 0.255332540955 | 22.1236008793 | 0.314484150417 | False |
1 | 1674065 | 8.3768692 | -44.6885989 | 77.1399088057 | 8.24720410207 | 353.864436285 | 52.591511726 | 0.83 | nan | nan | nan | nan | nan | 19.1818021972 | 0.116078541189 | 17.5279077055 | 0.161362664594 | False | nan | nan | nan | nan | False |
2 | 1669737 | 8.3819033 | -44.6883113 | 11.8997392584 | 0.885469096234 | 12.7383353593 | 1.42743740491 | 0.39 | nan | nan | nan | nan | nan | 21.2111563864 | 0.0807904975985 | 21.1372183043 | 0.12166585561 | False | nan | nan | nan | nan | False |
3 | 1669532 | 8.3823787 | -44.6856094 | 3.18562380847 | 0.911128000028 | 2.3991297873 | 1.18586017735 | 0.5 | nan | nan | nan | nan | nan | 22.6420137788 | 0.310534048047 | 22.9498656427 | 0.536665975783 | False | nan | nan | nan | nan | False |
4 | 1669365 | 8.3853193 | -44.6862528 | -0.241510058184 | 0.721097545281 | 0.297756212592 | 0.324486535387 | 0.57 | nan | nan | nan | nan | nan | nan | -3.24177683514 | 25.2153479208 | 1.18320546987 | False | nan | nan | nan | nan | False |
5 | 1826799 | 8.3870609 | -44.6865231 | nan | nan | nan | nan | nan | 1.59701353461 | 0.840050850693 | 1.1149179937 | 0.881729790393 | 0.5 | nan | nan | nan | nan | False | 23.3917285081 | 0.571112017943 | 23.7818926885 | 0.85865145388 | False |
6 | 1669296 | 8.38806855 | -44.68507945 | 6.21254015018 | 0.670464050535 | 5.72182175778 | 0.764821511389 | 0.84 | 4.10292614474 | 0.865948169305 | 3.48186110252 | 1.11418098883 | 0.94 | 21.9168269788 | 0.117173825208 | 22.0061641879 | 0.145127625474 | False | 22.3672657513 | 0.229151402119 | 22.5454713941 | 0.347431044091 | False |
7 | 1669705 | 8.3776621 | -44.6844686 | 2.22796204348 | 1.60647885866 | 1.66437008245 | 1.00933108168 | 0.8 | nan | nan | nan | nan | nan | 23.0302305307 | 0.782873417493 | 23.3468752485 | 0.658427659523 | False | nan | nan | nan | nan | False |
8 | 1669679 | 8.3799682 | -44.6844834 | 3.71922430727 | 0.971540308058 | 4.49135352246 | 1.62779805156 | 0.08 | nan | nan | nan | nan | nan | 22.4738690711 | 0.283617335147 | 22.2690568987 | 0.393502597774 | False | nan | nan | nan | nan | False |
9 | 1669664 | 8.3804248 | -44.6833328 | 5.14929921665 | 0.846682598496 | 10.424385215 | 2.16255164036 | 0.02 | nan | nan | nan | nan | nan | 22.1206296784 | 0.1785240889 | 21.354873871 | 0.225237322123 | False | nan | nan | nan | nan | False |