{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Herschel Stripe 82 master catalogue\n", "## Preparation of Spitzer SpIES data\n", "\n", "The Spitzer catalogues are available in `dmu0_SpIES`.\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", "TODO: 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 = \"spies_ra\"\n", "DEC_COL = \"spies_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': \"spies_intid\",\n", " 'ra': \"spies_ra\",\n", " 'dec': \"spies_dec\",\n", " 'FLUX_APER_2_ch1': \"f_ap_spies_irac1\",\n", " 'FLUXERR_APER_2_ch1': \"ferr_ap_spies_irac1\",\n", " 'FLUX_AUTO_ch1': \"f_spies_irac1\",\n", " 'FLUXERR_AUTO_ch1': \"ferr_spies_irac1\",\n", " 'CLASS_STAR_ch1': \"spies_stellarity_irac1\",\n", " 'FLUX_APER_2_ch2': \"f_ap_spies_irac2\",\n", " 'FLUXERR_APER_2_ch2': \"ferr_ap_spies_irac2\",\n", " 'FLUX_AUTO_ch2': \"f_spies_irac2\",\n", " 'FLUXERR_AUTO_ch2': \"ferr_spies_irac2\",\n", " 'CLASS_STAR_ch2': \"spies_stellarity_irac2\",\n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_SpIES/data/SpIES_ch1andch2_HELP-coverage.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 | spies_intid | spies_ra | spies_dec | f_ap_spies_irac1 | ferr_ap_spies_irac1 | f_spies_irac1 | ferr_spies_irac1 | spies_stellarity_irac1 | f_ap_spies_irac2 | ferr_ap_spies_irac2 | f_spies_irac2 | ferr_spies_irac2 | spies_stellarity_irac2 | m_ap_spies_irac1 | merr_ap_spies_irac1 | m_spies_irac1 | merr_spies_irac1 | flag_spies_irac1 | m_ap_spies_irac2 | merr_ap_spies_irac2 | m_spies_irac2 | merr_spies_irac2 | flag_spies_irac2 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | ch1ch2_1 | 6.49499250309e-05 | -0.586661502297 | 28.1600277481 | 1.76514876063 | 32.3940909992 | 3.08827320031 | 0.0099258814007 | 20.5422355911 | 1.81543919766 | 22.7407806522 | 2.77992120528 | 0.000489094178192 | 20.275917304 | 0.0680569612127 | 20.1238355054 | 0.103508075712 | False | 20.6183807358 | 0.0959529480465 | 20.507986577 | 0.132724603659 | False |
1 | ch1ch2_2 | 7.35155179947e-05 | -0.621352860834 | 16.2951537443 | 2.1889706663 | 14.8108001939 | 2.17028392034 | 0.179417416453 | 13.0123044649 | 2.04872493763 | 13.9009813898 | 2.45477232573 | 0.650836110115 | 20.8698538441 | 0.145849787051 | 20.9735536923 | 0.159097131557 | False | 21.1141144589 | 0.170943958802 | 21.0423863452 | 0.191730001914 | False |
2 | ch1ch2_3 | 7.37219688014e-05 | 0.293285515401 | 7.0001246741 | 2.15890359888 | 10.4747891588 | 3.63345551745 | 0.0198522917926 | 6.61420554483 | 2.41235729514 | 6.51274977382 | 3.3687713748 | 0.00777206901694 | 21.7872355625 | 0.334851150375 | 21.3496367749 | 0.376616096408 | False | 21.8488057824 | 0.395993689098 | 21.8655890188 | 0.561605646494 | False |
3 | ch1ch2_4 | 8.01140426867e-05 | -0.169356166906 | 6.42110289626 | 2.061583443 | 6.36495000949 | 3.05670263276 | 0.0542560815811 | 10.6825530995 | 1.77254961054 | 12.3489914241 | 2.29488468643 | 0.0006239580689 | 21.8809759265 | 0.348590548906 | 21.8905125074 | 0.52141379125 | False | 21.3283123494 | 0.180155555415 | 21.1709212774 | 0.201768654964 | False |
4 | ch1ch2_5 | 8.64262992602e-05 | -0.68114787198 | 37.7459808528 | 1.45767555752 | 47.6379778592 | 4.68851461755 | 0.00292181945406 | 34.8836751542 | 1.71372859989 | 41.8607493461 | 2.8472819877 | 0.00780582940206 | 19.9578232118 | 0.0419289972558 | 19.7051167044 | 0.106857811678 | False | 20.0434444161 | 0.0533389093268 | 19.8454825041 | 0.0738495413362 | False |
5 | ch1ch2_6 | 8.72926807298e-05 | -0.299507455382 | 11.2900282746 | 1.42803110746 | 10.4316429938 | 1.86083988068 | 0.000178854505066 | 7.71437269086 | 1.39224627003 | 6.15622208965 | 1.17327642973 | 0.391774982214 | 21.2682624261 | 0.137330486442 | 21.354118211 | 0.19367814168 | False | 21.6817484592 | 0.19594751795 | 21.9267143028 | 0.206923772306 | False |
6 | ch1ch2_7 | 9.41826855459e-05 | 0.47543699741 | 32.6314409813 | 1.98557777426 | 34.8593575951 | 2.89193212541 | 0.0134478537366 | 29.8451400387 | 2.05610893112 | 33.5779324342 | 3.08024595992 | 0.00498862424865 | 20.1159093691 | 0.0660655371645 | 20.0442015513 | 0.0900726699193 | False | 20.2128159475 | 0.0747991768357 | 20.0848651228 | 0.0995991806461 | False |
7 | ch1ch2_8 | 0.000105106695157 | -0.693443372615 | 10.700383445 | 1.69784813095 | 9.15667250893 | 2.08971521059 | 0.036885406822 | 11.5905167389 | 1.97005494607 | 16.5476456637 | 4.00929564336 | 0.000355674885213 | 21.3265016481 | 0.172275619414 | 21.4956557955 | 0.247784275299 | False | 21.2397430037 | 0.184543970602 | 20.8531594682 | 0.263060831978 | False |
8 | ch1ch2_9 | 0.000134234627159 | 0.556654630566 | 8.62730363857 | 1.37379768239 | 9.23241080307 | 2.21604842018 | 0.000674822484143 | 9.35250338003 | 1.83240301861 | 8.87736932963 | 1.99063747292 | 0.0078861201182 | 21.5603122917 | 0.172890852609 | 21.4867121987 | 0.260608420987 | False | 21.4726803154 | 0.212724467254 | 21.5292892789 | 0.243462572599 | False |
9 | ch1ch2_10 | 0.000163163807299 | -0.570124095906 | 12.8864522019 | 1.6709444496 | 11.8040701082 | 1.92303598929 | 0.00542557518929 | 15.0995835572 | 1.70928847754 | 13.701257637 | 2.04128635386 | 0.00902775861323 | 21.1246665819 | 0.140783891225 | 21.2199205494 | 0.176880497784 | False | 20.9525875757 | 0.122906461454 | 21.0580989179 | 0.161758763858 | False |