{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# ELAIS-S1 master catalogue\n", "## Preparation of Spitzer datafusion SWIRE 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", "We keep:\n", "- The internal identifier (this one is only in HeDaM data);\n", "- The position;\n", "- The fluxes in aperture 2 (1.9 arcsec) for IRAC bands.\n", "- The Kron flux;\n", "- The stellarity in each band\n", "\n", "A query of the position in the Spitzer heritage archive show that the ELAIS-N1 images were observed in 2004. Let's take this as epoch.\n", "\n", "We do not use the MIPS fluxes as they will be extracted on MIPS maps using XID+." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This notebook was run with herschelhelp_internal version: \n", "0246c5d (Thu Jan 25 17:01:47 2018 +0000) [with local modifications]\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": { "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 = \"swire_ra\"\n", "DEC_COL = \"swire_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': \"swire_intid\",\n", " 'ra_spitzer': \"swire_ra\",\n", " 'dec_spitzer': \"swire_dec\",\n", " 'flux_ap2_36': \"f_ap_swire_irac1\",\n", " 'uncf_ap2_36': \"ferr_ap_swire_irac1\",\n", " 'flux_kr_36': \"f_swire_irac1\",\n", " 'uncf_kr_36': \"ferr_swire_irac1\",\n", " 'stell_36': \"swire_stellarity_irac_i1\",\n", " 'flux_ap2_45': \"f_ap_swire_irac2\",\n", " 'uncf_ap2_45': \"ferr_ap_swire_irac2\",\n", " 'flux_kr_45': \"f_swire_irac2\",\n", " 'uncf_kr_45': \"ferr_swire_irac2\",\n", " 'stell_45': \"swire_stellarity_irac_i2\",\n", " 'flux_ap2_58': \"f_ap_irac_i3\",\n", " 'uncf_ap2_58': \"ferr_ap_irac_i3\",\n", " 'flux_kr_58': \"f_irac_i3\",\n", " 'uncf_kr_58': \"ferr_irac_i3\",\n", " 'stell_58': \"swire_stellarity_irac_i3\",\n", " 'flux_ap2_80': \"f_ap_irac_i4\",\n", " 'uncf_ap2_80': \"ferr_ap_irac_i4\",\n", " 'flux_kr_80': \"f_irac_i4\",\n", " 'uncf_kr_80': \"ferr_irac_i4\",\n", " 'stell_80': \"swire_stellarity_irac_i4\",\n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_DataFusion-Spitzer/data/DF-SWIRE_ELAIS-S1.fits\")[list(imported_columns)]\n", "for column in imported_columns:\n", " catalogue[column].name = imported_columns[column]\n", "\n", "epoch = 2004\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: divide by zero encountered in log10\n", " magnitudes = 2.5 * (23 - np.log10(fluxes)) - 48.6\n", "/opt/herschelhelp_internal/herschelhelp_internal/utils.py:80: RuntimeWarning: divide by zero encountered in true_divide\n", " errors = 2.5 / np.log(10) * errors_on_fluxes / fluxes\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 | swire_intid | swire_ra | swire_dec | f_ap_swire_irac1 | ferr_ap_swire_irac1 | f_swire_irac1 | ferr_swire_irac1 | swire_stellarity_irac_i1 | f_ap_swire_irac2 | ferr_ap_swire_irac2 | f_swire_irac2 | ferr_swire_irac2 | swire_stellarity_irac_i2 | f_ap_irac_i3 | ferr_ap_irac_i3 | f_irac_i3 | ferr_irac_i3 | swire_stellarity_irac_i3 | f_ap_irac_i4 | ferr_ap_irac_i4 | f_irac_i4 | ferr_irac_i4 | swire_stellarity_irac_i4 | m_ap_swire_irac1 | merr_ap_swire_irac1 | m_swire_irac1 | merr_swire_irac1 | flag_swire_irac1 | m_ap_swire_irac2 | merr_ap_swire_irac2 | m_swire_irac2 | merr_swire_irac2 | flag_swire_irac2 | 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 | 1650517 | 7.122051 | -43.939174 | 30.17 | 0.92 | 29.41 | 0.96 | 0.22 | 20.69 | 1.1 | 17.17 | 1.04 | 0.31 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 20.2010617246 | 0.0331082965985 | 20.2287624387 | 0.0354405561567 | False | 20.6105987733 | 0.0577240128194 | 20.8130742621 | 0.065763870294 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
1 | 1650480 | 7.124631 | -43.939234 | 6.66 | 0.61 | 5.84 | 0.61 | 0.55 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 21.8413144271 | 0.0994443070424 | 21.9839678822 | 0.113407377552 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
2 | 1650509 | 7.123371 | -43.938944 | 14.11 | 0.72 | 14.26 | 0.77 | 0.64 | 19.81 | 1.1 | 21.92 | 1.18 | 0.53 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 21.0261824656 | 0.0554025561606 | 21.0147011862 | 0.0586267095136 | False | 20.6577888112 | 0.0602882294414 | 20.5478986255 | 0.0584474781758 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
3 | 1650685 | 7.119691 | -43.934444 | 25.35 | 0.85 | 20.94 | 0.75 | 0.96 | 22.56 | 1.14 | 27.37 | 1.86 | 0.43 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 20.3900550908 | 0.0364053559781 | 20.5975583066 | 0.0388873998839 | False | 20.5166522617 | 0.0548643294958 | 20.3068130065 | 0.0737840460669 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
4 | 1650637 | 7.122621 | -43.935184 | 27.87 | 0.94 | 31.54 | 1.1 | 0.17 | 23.32 | 1.14 | 21.96 | 1.4 | 0.09 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 20.2871575782 | 0.0366197356467 | 20.1528457775 | 0.0378665131653 | False | 20.4806786348 | 0.0530762981743 | 20.5459191606 | 0.0692181551303 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
5 | 1650616 | 7.123811 | -43.935354 | 12.17 | 0.7 | 10.94 | 0.79 | 0.76 | 16.38 | 1.07 | 15.62 | 1.3 | 0.09 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 21.1867735544 | 0.0624499049573 | 21.302456695 | 0.0784032542741 | False | 20.8642152564 | 0.0709241598957 | 20.9157974261 | 0.0903621681297 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
6 | 1650962 | 7.117501 | -43.925104 | 52.7 | 1.02 | 50.23 | 0.99 | 0.17 | 50.34 | 1.13 | 47.9 | 1.29 | 0.41 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 19.595473462 | 0.0210142491244 | 19.6475920546 | 0.0213991408065 | False | 19.645216972 | 0.0243719092447 | 19.6991612165 | 0.0292400773306 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
7 | 1650924 | 7.120101 | -43.925844 | 6.62 | 0.65 | 5.03 | 0.5 | 0.0 | 8.57 | 0.82 | 6.29 | 0.7 | 0.47 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 21.8478550264 | 0.106605518594 | 22.1460800374 | 0.107926064091 | False | 21.5675479452 | 0.103886077935 | 21.9033733864 | 0.120829148383 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
8 | 1651013 | 7.119051 | -43.923004 | 44.03 | 0.87 | 47.53 | 0.97 | 0.56 | 34.56 | 1.01 | 31.7 | 1.16 | 0.77 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 19.7906282864 | 0.0214533385905 | 19.7075804643 | 0.0221578817298 | False | 20.0535656655 | 0.0317301379284 | 20.1473518445 | 0.0397304100164 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |
9 | 1651022 | 7.122591 | -43.921324 | 5.42 | 0.51 | 4.19 | 0.45 | 0.47 | 8.42 | 0.75 | 14.36 | 1.31 | 0.14 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | 22.0650017837 | 0.10216336982 | 22.3444649426 | 0.116606513638 | False | 21.5867197713 | 0.096710469545 | 21.0071139002 | 0.0990469657544 | False | nan | nan | nan | nan | False | nan | nan | nan | nan | False |