{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# EGS master catalogue\n", "## Preparation of DEEP2 data\n", "\n", "DEEP2 catalogue: the catalogue comes from `dmu0_DEEP2`.\n", "\n", "In the catalogue, we keep:\n", "\n", "- The identifier (it's unique in the catalogue);\n", "- The position;\n", "- The stellarity;\n", "- The total magnitude. No aperture magnitudes are given.\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", "0246c5d (Thu Jan 25 17:01:47 2018 +0000) [with local modifications]\n", "This notebook was executed on: \n", "2018-02-07 19:30:51.539432\n" ] } ], "source": [ "from herschelhelp_internal import git_version\n", "print(\"This notebook was run with herschelhelp_internal version: \\n{}\".format(git_version()))\n", "import datetime\n", "print(\"This notebook was executed on: \\n{}\".format(datetime.datetime.now()))" ] }, { "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, 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 = \"deep2_ra\"\n", "DEC_COL = \"deep2_dec\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I - Column selection" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "imported_columns = OrderedDict({\n", " 'objno': \"deep2_id\",\n", " 'ra': \"deep2_ra\",\n", " 'dec': \"deep2_dec\",\n", " # 'pgal': \"deep2_stellarity\", #TODO these numbers seems strange.\n", " 'magb': \"m_deep2_b\", \n", " 'magberr': \"merr_deep2_b\",\n", " 'magr': \"m_deep2_r\", \n", " 'magrerr': \"merr_deep2_r\",\n", " 'magi': \"m_deep2_i\", \n", " 'magierr': \"merr_deep2_i\",\n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_DEEP2/data/DEEP2_EGS.fits\")[list(imported_columns)]\n", "for column in imported_columns:\n", " catalogue[column].name = imported_columns[column]\n", "\n", "epoch = 2011 # TODO : check this\n", "\n", "# Clean table metadata\n", "catalogue.meta = None" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/astropy/table/column.py:1096: MaskedArrayFutureWarning: setting an item on a masked array which has a shared mask will not copy the mask and also change the original mask array in the future.\n", "Check the NumPy 1.11 release notes for more information.\n", " ma.MaskedArray.__setitem__(self, index, value)\n" ] } ], "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", " \n", " # Some object have a magnitude to 0, we suppose this means missing value\n", " catalogue[col][catalogue[col] < 0.] = np.nan\n", " catalogue[errcol][np.isclose(catalogue[errcol], 9.99)] = np.nan \n", " \n", "\n", " flux, error = mag_to_flux(np.array(catalogue[col]), np.array(catalogue[errcol]))\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", " #Add empty aperture columns\n", " catalogue.add_column(Column(np.full(len(catalogue), np.nan), name=\"f_ap{}\".format(col[1:])))\n", " catalogue.add_column(Column(np.full(len(catalogue), np.nan), name=\"ferr_ap{}\".format(col[1:])))\n", " catalogue.add_column(Column(np.full(len(catalogue), np.nan), name=\"m_ap{}\".format(col[1:])))\n", " catalogue.add_column(Column(np.full(len(catalogue), np.nan), name=\"merr_ap{}\".format(col[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", "# TODO: Set to True the flag columns for fluxes that should not be used for SED fitting." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<Table masked=True length=10>\n", "
idx | deep2_id | deep2_ra | deep2_dec | m_deep2_b | merr_deep2_b | m_deep2_r | merr_deep2_r | m_deep2_i | merr_deep2_i | f_deep2_b | ferr_deep2_b | f_ap_deep2_b | ferr_ap_deep2_b | m_ap_deep2_b | merr_ap_deep2_b | flag_deep2_b | f_deep2_r | ferr_deep2_r | f_ap_deep2_r | ferr_ap_deep2_r | m_ap_deep2_r | merr_ap_deep2_r | flag_deep2_r | f_deep2_i | ferr_deep2_i | f_ap_deep2_i | ferr_ap_deep2_i | m_ap_deep2_i | merr_ap_deep2_i | flag_deep2_i |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | mag | mag | mag | mag | mag | mag | |||||||||||||||||||||||
0 | 14025920 | 216.29397583 | 53.5285301208 | 25.1572 | nan | 24.533 | nan | 23.6281 | nan | 0.314138 | nan | nan | nan | nan | nan | False | 0.558212 | nan | nan | nan | nan | nan | False | 1.28458 | nan | nan | nan | nan | nan | False |
1 | 14026150 | 216.292160034 | 53.5215988159 | 24.6332 | 0.283395 | 23.3823 | 0.0580336 | 23.5803 | 0.391634 | 0.509002 | 0.132858 | nan | nan | nan | nan | False | 1.61094 | 0.0861063 | nan | nan | nan | nan | False | 1.34239 | 0.484213 | nan | nan | nan | nan | False |
2 | 14026187 | 216.293151855 | 53.5245666504 | 25.0175 | 0.419661 | 22.317 | 0.0255119 | 21.303 | 0.0499797 | 0.357273 | 0.138094 | nan | nan | nan | nan | False | 4.29734 | 0.100976 | nan | nan | nan | nan | False | 10.9345 | 0.503349 | nan | nan | nan | nan | False |
3 | 14026147 | 216.29107666 | 53.5273628235 | 27.7236 | 4.42076 | 22.1867 | 0.0212053 | 21.0688 | 0.0301138 | 0.0295501 | 0.120318 | nan | nan | nan | nan | False | 4.84529 | 0.0946323 | nan | nan | nan | nan | False | 13.5669 | 0.376288 | nan | nan | nan | nan | False |
4 | 14026196 | 216.295944214 | 53.5155410767 | 25.5545 | 2.82323 | 23.0359 | 0.14998 | 24.0105 | nan | 0.217871 | 0.566528 | nan | nan | nan | nan | False | 2.21636 | 0.30616 | nan | nan | nan | nan | False | 0.903234 | nan | nan | nan | nan | nan | False |
5 | 14025984 | 216.295516968 | 53.5116119385 | 25.3563 | nan | 24.1624 | nan | 24.6074 | nan | 0.261505 | nan | nan | nan | nan | nan | False | 0.785308 | nan | nan | nan | nan | nan | False | 0.521242 | nan | nan | nan | nan | nan | False |
6 | 14026202 | 216.294799805 | 53.5106735229 | 27.2561 | nan | 23.8307 | nan | 24.2675 | nan | 0.0454527 | nan | nan | nan | nan | nan | False | 1.06591 | nan | nan | nan | nan | nan | False | 0.712853 | nan | nan | nan | nan | nan | False |
7 | 14026017 | 216.293212891 | 53.5123023987 | 24.3531 | 0.157522 | 24.0236 | 0.0774925 | 23.9112 | 0.392262 | 0.65881 | 0.0955821 | nan | nan | nan | nan | False | 0.892401 | 0.0636935 | nan | nan | nan | nan | False | 0.989738 | 0.357579 | nan | nan | nan | nan | False |
8 | 14026199 | 216.289123535 | 53.5124740601 | 25.7492 | 0.989321 | 22.8401 | 0.0497578 | 21.3645 | 0.0558166 | 0.182104 | 0.165933 | nan | nan | nan | nan | False | 2.65436 | 0.121646 | nan | nan | nan | nan | False | 10.3324 | 0.531176 | nan | nan | nan | nan | False |
9 | 14026120 | 216.294448853 | 53.5181694031 | 24.6752 | 0.52318 | 24.1771 | 0.177209 | 24.1368 | nan | 0.489689 | 0.235965 | nan | nan | nan | nan | False | 0.774747 | 0.126451 | nan | nan | nan | nan | False | 0.804044 | nan | nan | nan | nan | nan | False |