{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Herschel Stripe 82 master catalogue\n", "## Preparation of SDSS Stripe 82 - IAC Legacy Survey data\n", "\n", "This catalogue comes from `dmu0_IAC_Stripe82_Legacy_Project`.\n", "\n", "One must choose between this catalogue and the official SDSS catalogue in 'dmu0_SDSS-S82'. Currently we choose this one.\n", "\n", "In the catalogue, we keep:\n", "\n", "- We generate a unique object identifier;\n", "- The position;\n", "- The u, g, r, i, z, aperture magnitude (for now in 3”);\n", "- The u, g, r, i, z, auto fluxes and magnitudes.\n", "\n", "\n", "We don't know when the maps have been observed. We will use the year of the reference paper." ] }, { "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": { "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_tiled\n", "from herschelhelp_internal.utils import astrometric_correction, mag_to_flux" ] }, { "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 = \"sdss_ra\"\n", "DEC_COL = \"sdss_dec\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I - Column selection" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "imported_columns = OrderedDict({\n", " #\"objID\": \"sdss_id\",\n", " \"ALPHA_J2000\": \"sdss_ra\",\n", " \"DELTA_J2000\": \"sdss_dec\",\n", " #\"flags\": \"flags\",\n", " \"stellarity\": \"sdss_stellarity\",\n", " \"u_MAG_AUTO\": \"m_sdss_u\",\n", " \"g_MAG_AUTO\": \"m_sdss_g\",\n", " \"r_MAG_AUTO\": \"m_sdss_r\",\n", " \"i_MAG_AUTO\": \"m_sdss_i\",\n", " \"z_MAG_AUTO\": \"m_sdss_z\",\n", " \"u_MAGERR_AUTO\": \"merr_sdss_u\",\n", " \"g_MAGERR_AUTO\": \"merr_sdss_g\",\n", " \"r_MAGERR_AUTO\": \"merr_sdss_r\",\n", " \"i_MAGERR_AUTO\": \"merr_sdss_i\",\n", " \"z_MAGERR_AUTO\": \"merr_sdss_z\",\n", " \"u_MAG_APER_1\": \"m_ap_sdss_u\",\n", " \"g_MAG_APER_1\": \"m_ap_sdss_g\",\n", " \"r_MAG_APER_1\": \"m_ap_sdss_r\",\n", " \"i_MAG_APER_1\": \"m_ap_sdss_i\",\n", " \"z_MAG_APER_1\": \"m_ap_sdss_z\",\n", " \"u_MAGERR_APER_1\": \"merr_ap_sdss_u\",\n", " \"g_MAGERR_APER_1\": \"merr_ap_sdss_g\",\n", " \"r_MAGERR_APER_1\": \"merr_ap_sdss_r\",\n", " \"i_MAGERR_APER_1\": \"merr_ap_sdss_i\",\n", " \"z_MAGERR_APER_1\": \"merr_ap_sdss_z\" \n", " })\n", "\n", "\n", "catalogue = Table.read(\n", " \"../../dmu0/dmu0_IAC_Stripe82_Legacy_Project/data/iac_stripe82_concat_helpcoverage.fits\")[list(imported_columns)]\n", "for column in imported_columns:\n", " catalogue[column].name = imported_columns[column]\n", "\n", "catalogue.add_column(Column(data=np.arange(len(catalogue)), name='sdss_id', dtype=int))\n", " \n", "epoch = 2013\n", "\n", "# Clean table metadata\n", "catalogue.meta = None" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Adding flux and band-flag columns\n", "for col in catalogue.colnames:\n", " if col.startswith('m_'):\n", " \n", " errcol = \"merr{}\".format(col[1:])\n", " flux, error = mag_to_flux(np.array(catalogue[col]), np.array(catalogue[errcol]))\n", " \n", " mask = catalogue[col] > 90.\n", " catalogue[col][mask] = np.nan\n", " catalogue[errcol][mask] = np.nan\n", " \n", " # Fluxes are added in µJy\n", " catalogue.add_column(Column(flux * 1.e6, name=\"f{}\".format(col[1:])))\n", " catalogue.add_column(Column(error * 1.e6, name=\"f{}\".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", " \n" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<Table length=10>\n", "
idx | sdss_ra | sdss_dec | sdss_stellarity | m_sdss_u | m_sdss_g | m_sdss_r | m_sdss_i | m_sdss_z | merr_sdss_u | merr_sdss_g | merr_sdss_r | merr_sdss_i | merr_sdss_z | m_ap_sdss_u | m_ap_sdss_g | m_ap_sdss_r | m_ap_sdss_i | m_ap_sdss_z | merr_ap_sdss_u | merr_ap_sdss_g | merr_ap_sdss_r | merr_ap_sdss_i | merr_ap_sdss_z | sdss_id | f_sdss_u | ferr_sdss_u | flag_sdss_u | f_sdss_g | ferr_sdss_g | flag_sdss_g | f_sdss_r | ferr_sdss_r | flag_sdss_r | f_sdss_i | ferr_sdss_i | flag_sdss_i | f_sdss_z | ferr_sdss_z | flag_sdss_z | f_ap_sdss_u | ferr_ap_sdss_u | f_ap_sdss_g | ferr_ap_sdss_g | f_ap_sdss_r | ferr_ap_sdss_r | f_ap_sdss_i | ferr_ap_sdss_i | f_ap_sdss_z | ferr_ap_sdss_z |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | ||||||||||||||||||||||||||||
0 | 7.9e-06 | -0.6811598 | 0.0 | 22.7434 | 22.179 | 21.1283 | 20.7023 | 20.444 | 0.1829 | 0.0461 | 0.0295 | 0.0282 | 0.0741 | 24.1723 | 23.28 | 22.0792 | 21.6507 | 21.375 | 0.2664 | 0.0587 | 0.0346 | 0.0303 | 0.0739 | 0 | 2.90161641856 | 0.488797960895 | False | 4.87977727286 | 0.20719372836 | False | 12.8433997455 | 0.348961645409 | False | 19.0142850374 | 0.49386106469 | False | 24.1212605609 | 1.64624279796 | False | 0.77817988387 | 0.190936914652 | 1.77010895832 | 0.0957004062293 | 5.3495838612 | 0.170479349207 | 7.93816277439 | 0.221532938673 | 10.2329299228 | 0.696498392502 |
1 | 1.2e-05 | -0.441853 | 0.0 | 25.0592 | 23.9242 | 23.8076 | 23.4974 | 23.7606 | 0.983 | 0.1462 | 0.1898 | 0.2078 | 0.9601 | 25.0027 | 24.5206 | 24.3087 | 23.9264 | 24.0102 | 0.4803 | 0.1326 | 0.1499 | 0.1481 | 0.5567 | 1 | 0.343811184035 | 0.311278552217 | False | 0.977957541293 | 0.131687045076 | False | 1.08882980378 | 0.190340799038 | False | 1.44890529651 | 0.277307249491 | False | 1.13699878343 | 1.00543071806 | False | 0.362176276936 | 0.160216878695 | 0.56462486535 | 0.0689571341706 | 0.686309483403 | 0.0947539477005 | 0.975977936781 | 0.133128407991 | 0.903483030668 | 0.463251571578 |
2 | 1.63e-05 | -0.1693558 | 0.0 | 23.4305 | 22.7872 | 21.9994 | 21.5573 | 21.4121 | 0.2593 | 0.0585 | 0.0442 | 0.0417 | 0.1351 | 23.8616 | 23.3131 | 22.5056 | 22.025 | 21.9832 | 0.2215 | 0.0587 | 0.0435 | 0.0394 | 0.1217 | 2 | 1.54099063711 | 0.368025741843 | False | 2.78689110872 | 0.150159061792 | False | 5.75758025081 | 0.234389390324 | False | 8.65127266431 | 0.332270461757 | False | 9.88917358172 | 1.2305266648 | False | 1.03600058347 | 0.211353483684 | 1.71695929817 | 0.0928268859053 | 3.61210195344 | 0.144718794755 | 5.6234132519 | 0.204066587403 | 5.84413177557 | 0.655067809262 |
3 | 3.03e-05 | -0.1535 | 1.0 | 25.461 | 24.6486 | 23.762 | 23.8432 | 27.7665 | 1.1277 | 0.2041 | 0.1428 | 0.2138 | 31.4209 | 25.8624 | 25.1405 | 24.1513 | 23.9232 | 24.3767 | 1.0369 | 0.2095 | 0.1356 | 0.1529 | 0.8792 | 3 | 0.237465214365 | 0.246643264788 | False | 0.501833905164 | 0.0943362665766 | False | 1.13553362784 | 0.149349539368 | False | 1.05370732713 | 0.207492967033 | False | 0.0284053405254 | 0.822042555275 | False | 0.164074088406 | 0.156694067604 | 0.319006843598 | 0.0615544857405 | 0.793377719542 | 0.0990867010775 | 0.978858688406 | 0.137848855736 | 0.644644081878 | 0.52201545302 |
4 | 4.24e-05 | -0.1919793 | 0.0 | 23.6244 | 23.4632 | 22.7811 | 22.486 | 22.5915 | 0.2669 | 0.0879 | 0.0721 | 0.0771 | 0.3245 | 24.0888 | 23.9069 | 23.1105 | 22.8286 | 22.87 | 0.256 | 0.0854 | 0.0638 | 0.0668 | 0.2414 | 4 | 1.28896166145 | 0.316857691521 | False | 1.49527130822 | 0.121055508158 | False | 2.80259278742 | 0.186110529508 | False | 3.67790070422 | 0.261174070693 | False | 3.33733651305 | 0.997448269422 | False | 0.840388304897 | 0.198150715718 | 0.993665016302 | 0.0781580203555 | 2.06918823295 | 0.121589580124 | 2.68262520038 | 0.165048713122 | 2.58226019063 | 0.574133576174 |
5 | 4.79e-05 | 0.0104786 | 0.0 | 28.7271 | 24.7754 | 24.352 | 24.5675 | 22.1077 | 32.7486 | 0.3133 | 0.3487 | 0.6433 | 0.287 | nan | 25.7483 | 24.896 | 25.092 | 23.7945 | nan | 0.3349 | 0.254 | 0.444 | 0.5647 | 5 | 0.0117262729784 | 0.353694591354 | False | 0.446519058144 | 0.128847523278 | False | 0.659477525949 | 0.211800815236 | False | 0.540754322946 | 0.320397583157 | False | 5.21098712333 | 1.37745549779 | False | 9.12010839356e-31 | 8.31593095087e-29 | 0.182255230129 | 0.056217409259 | 0.399576556619 | 0.0934779967145 | 0.333579996662 | 0.136413907788 | 1.10204670396 | 0.573183219829 |
6 | 4.91e-05 | -0.6033114 | 0.0 | 24.3905 | 23.9676 | 24.0844 | 22.8704 | 22.5319 | 0.7538 | 0.2047 | 0.3356 | 0.1655 | 0.4444 | 26.2667 | 24.776 | 24.5654 | 23.9495 | 25.7836 | 1.3571 | 0.1599 | 0.1836 | 0.1509 | 2.726 | 6 | 0.636502333247 | 0.441907948449 | False | 0.939636762835 | 0.177155044208 | False | 0.843800930571 | 0.260818043148 | False | 2.58130902604 | 0.393471859866 | False | 3.52565652197 | 1.44307774899 | False | 0.113062868583 | 0.141321269644 | 0.446272370762 | 0.0657240237289 | 0.541801246672 | 0.0916195927271 | 0.955432477641 | 0.132789862072 | 0.176424948771 | 0.442956961593 |
7 | 5.4e-05 | -0.2995998 | 0.0 | 22.9902 | 22.1009 | 21.5013 | 21.2767 | 20.9323 | 0.2324 | 0.0454 | 0.0529 | 0.1303 | 0.1722 | 24.3231 | 23.3666 | 22.4058 | 22.2655 | 21.9159 | 0.2957 | 0.062 | 0.0485 | 0.1061 | 0.145 | 7 | 2.31163893133 | 0.494802407146 | False | 5.24372611524 | 0.219266120618 | False | 9.10919501907 | 0.443824581327 | False | 11.2026301974 | 1.34443588444 | False | 15.3843800496 | 2.43999438623 | False | 0.677267132528 | 0.18445354425 | 1.63440619589 | 0.0933313116954 | 3.95986153355 | 0.176887611867 | 4.50609143573 | 0.440342966584 | 6.2178465514 | 0.830393005227 |
8 | 6.2e-05 | -0.2836417 | 0.0 | 21.4839 | 22.593 | 21.8268 | 20.7278 | 20.434 | 0.0782 | 0.0708 | 0.0757 | 0.087 | 0.1211 | 24.2725 | 24.2242 | 23.3868 | 22.6755 | 22.6985 | 0.2849 | 0.108 | 0.0999 | 0.1522 | 0.2797 | 8 | 9.25635495017 | 0.666687685214 | False | 3.33272899576 | 0.217324624403 | False | 6.74963052209 | 0.470599606316 | False | 18.5729119566 | 1.48824671513 | False | 24.3444518369 | 2.71531252668 | False | 0.709577767963 | 0.186195049227 | 0.741856660156 | 0.0737937253503 | 1.60427937447 | 0.147611831316 | 3.08887262651 | 0.433002428854 | 3.02412682128 | 0.779055048737 |
9 | 6.2e-05 | 0.4754511 | 0.0 | 22.1491 | 21.5975 | 20.6098 | 20.3081 | 20.1578 | 0.1242 | 0.0319 | 0.0209 | 0.0234 | 0.0626 | 23.544 | 22.9666 | 21.8788 | 21.5136 | 21.2087 | 0.1791 | 0.0485 | 0.0304 | 0.031 | 0.0697 | 9 | 5.01602855315 | 0.573795682203 | False | 8.3368118462 | 0.244943750359 | False | 20.7052271804 | 0.398567576705 | False | 27.3375757853 | 0.58918480435 | False | 31.3964105913 | 1.81021439131 | False | 1.38803366657 | 0.228966141677 | 2.36243571709 | 0.105530359748 | 6.43398434717 | 0.180147924788 | 9.00658184682 | 0.257156421632 | 11.9266918904 | 0.765646775999 |