{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# XMM-LSS 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", "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()))" ] }, { "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_irac_i1\",\n", " 'fluxerr_aper_2_1': \"ferr_ap_servs_irac_i1\",\n", " 'flux_auto_1': \"f_servs_irac_i1\",\n", " 'fluxerr_auto_1': \"ferr_servs_irac_i1\",\n", " 'class_star_1': \"servs_stellarity_irac_i1\",\n", " 'flux_aper_2_2': \"f_ap_servs_irac_i2\",\n", " 'fluxerr_aper_2_2': \"ferr_ap_servs_irac_i2\",\n", " 'flux_auto_2': \"f_servs_irac_i2\",\n", " 'fluxerr_auto_2': \"ferr_servs_irac_i2\",\n", " 'class_star_2': \"servs_stellarity_irac_i2\",\n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_DataFusion-Spitzer/data/DF-SERVS_XMM-LSS.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_irac_i1 | ferr_ap_servs_irac_i1 | f_servs_irac_i1 | ferr_servs_irac_i1 | servs_stellarity_irac_i1 | f_ap_servs_irac_i2 | ferr_ap_servs_irac_i2 | f_servs_irac_i2 | ferr_servs_irac_i2 | servs_stellarity_irac_i2 | m_ap_servs_irac_i1 | merr_ap_servs_irac_i1 | m_servs_irac_i1 | merr_servs_irac_i1 | flag_servs_irac_i1 | m_ap_servs_irac_i2 | merr_ap_servs_irac_i2 | m_servs_irac_i2 | merr_servs_irac_i2 | flag_servs_irac_i2 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | uJy | uJy | uJy | uJy | uJy | uJy | uJy | uJy | ||||||||||||||
0 | 2780967 | 36.8696323 | -5.7556182 | 7.49747151023 | 6.84389125991 | 9.48517372291 | 6.42930265198 | 0.97 | nan | nan | nan | nan | nan | 21.7127129396 | 0.991088864048 | 21.4573867763 | 0.735940834035 | False | nan | nan | nan | nan | False |
1 | 2781011 | 36.8640942 | -5.7461179 | 2.41274385567 | 4.33562242856 | 9.85549407247 | 3.35817597394 | 0.9 | nan | nan | nan | nan | nan | 22.9437219542 | 1.95103273387 | 21.4158039973 | 0.369955398486 | False | nan | nan | nan | nan | False |
2 | 2781002 | 36.8689484 | -5.7474833 | 1.30993007279 | 0.955964651916 | 0.964902447823 | 0.701955973375 | 0.5 | nan | nan | nan | nan | nan | 23.6068797185 | 0.792351786261 | 23.9387914796 | 0.789861209451 | False | nan | nan | nan | nan | False |
3 | 2781021 | 36.8672617 | -5.7441306 | 2.18303387324 | 0.806183793124 | 1.12312229283 | 1.20033780448 | 0.03 | nan | nan | nan | nan | nan | 23.0523488137 | 0.400957100398 | 23.7739323809 | 1.16038139443 | False | nan | nan | nan | nan | False |
4 | 2781004 | 36.8694334 | -5.7464403 | 1.45730256711 | 0.810906283773 | 1.43590893949 | 0.553742561284 | 0.58 | nan | nan | nan | nan | nan | 23.4911256752 | 0.60415066221 | 23.5071827518 | 0.418702280044 | False | nan | nan | nan | nan | False |
5 | 2781088 | 36.8608685 | -5.7399565 | 14.516576691 | 6.81442827645 | 46.1162041481 | 20.2561771883 | 0.02 | nan | nan | nan | nan | nan | 20.995339468 | 0.509670540923 | 19.7403661174 | 0.476901023178 | False | nan | nan | nan | nan | False |
6 | 2781157 | 36.8574418 | -5.7345751 | 3.51327923362 | 3.9543145036 | 6.78730522307 | 4.2362693472 | 0.89 | nan | nan | nan | nan | nan | 22.5357183283 | 1.22203278933 | 21.8207565507 | 0.677657899888 | False | nan | nan | nan | nan | False |
7 | 2781037 | 36.8630737 | -5.7441866 | 12.8111806217 | 2.8868083592 | 37.7816352964 | 52.7211469225 | 0.03 | nan | nan | nan | nan | nan | 21.1310271144 | 0.244654450229 | 19.9567981213 | 1.51505506633 | False | nan | nan | nan | nan | False |
8 | 2781047 | 36.8656367 | -5.7414174 | 0.901233347132 | 0.827506796061 | 0.765568309234 | 0.463219732298 | 0.52 | nan | nan | nan | nan | nan | 24.0129068676 | 0.996916160533 | 24.1900401313 | 0.656942598129 | False | nan | nan | nan | nan | False |
9 | 2781035 | 36.8683861 | -5.7435976 | 5.63019001249 | 0.716167645671 | 7.11083219767 | 1.4087525751 | 0.02 | nan | nan | nan | nan | nan | 22.0236923699 | 0.138107086947 | 21.7701989244 | 0.215099109614 | False | nan | nan | nan | nan | False |