{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# EGS master catalogue\n", "## Preparation of Canada France Hawaii Telescope Legacy Survey (CFHTLS) wide data\n", "\n", "CFHTLS has both a wide area across EGS and a smaller deep field. We will process each independently and add them both to the master catalogue, taking the deep photometry where both are available.\n", "\n", "The catalogue is in `dmu0_CFHTLS`.\n", "\n", "In the catalogue, we keep:\n", "\n", "- The position;\n", "- The stellarity (g band stellarity);\n", "- The aperture magnitude (3 arcsec).\n", "- The total magnitude (Kron like aperture magnitude).\n", "\n", "We use the 2007 release, which we take as the date." ] }, { "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:28:32.237264\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 = \"cfhtls-wide_ra\"\n", "DEC_COL = \"cfhtls-wide_dec\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I - Column selection" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "imported_columns = OrderedDict({\n", " 'cfhtls': \"cfhtls-wide_id\",\n", " 'raj2000': \"cfhtls-wide_ra\",\n", " 'dej2000': \"cfhtls-wide_dec\",\n", " 'gcl': \"cfhtls-wide_stellarity\",\n", " 'umaga': \"m_cfhtls-wide_u\",\n", " 'e_umaga': \"merr_cfhtls-wide_u\",\n", " 'gmaga': \"m_cfhtls-wide_g\",\n", " 'e_gmaga': \"merr_cfhtls-wide_g\",\n", " 'rmaga': \"m_cfhtls-wide_r\",\n", " 'e_rmaga': \"merr_cfhtls-wide_r\",\n", " 'imaga': \"m_cfhtls-wide_i\",\n", " 'e_imaga': \"merr_cfhtls-wide_i\",\n", " 'zmaga': \"m_cfhtls-wide_z\",\n", " 'e_zmaga': \"merr_cfhtls-wide_z\",\n", " 'umag': \"m_ap_cfhtls-wide_u\",\n", " 'e_umag': \"merr_ap_cfhtls-wide_u\",\n", " 'gmag': \"m_ap_cfhtls-wide_g\",\n", " 'e_gmag': \"merr_ap_cfhtls-wide_g\",\n", " 'rmag': \"m_ap_cfhtls-wide_r\",\n", " 'e_rmag': \"merr_ap_cfhtls-wide_r\",\n", " 'imag': \"m_ap_cfhtls-wide_i\",\n", " 'e_imag': \"merr_ap_cfhtls-wide_i\",\n", " 'zmag': \"m_ap_cfhtls-wide_z\",\n", " 'e_zmag': \"merr_ap_cfhtls-wide_z\"\n", " \n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_CFHTLS/data/CFHTLS-WIDE_EGS.fits\")[list(imported_columns)]\n", "for column in imported_columns:\n", " catalogue[column].name = imported_columns[column]\n", "\n", "epoch = 2007\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", " \n", " #catalogue[col][catalogue[col] <= 0] = np.nan\n", " #catalogue[errcol][catalogue[errcol] <= 0] = 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", " # 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 | cfhtls-wide_id | cfhtls-wide_ra | cfhtls-wide_dec | cfhtls-wide_stellarity | m_cfhtls-wide_u | merr_cfhtls-wide_u | m_cfhtls-wide_g | merr_cfhtls-wide_g | m_cfhtls-wide_r | merr_cfhtls-wide_r | m_cfhtls-wide_i | merr_cfhtls-wide_i | m_cfhtls-wide_z | merr_cfhtls-wide_z | m_ap_cfhtls-wide_u | merr_ap_cfhtls-wide_u | m_ap_cfhtls-wide_g | merr_ap_cfhtls-wide_g | m_ap_cfhtls-wide_r | merr_ap_cfhtls-wide_r | m_ap_cfhtls-wide_i | merr_ap_cfhtls-wide_i | m_ap_cfhtls-wide_z | merr_ap_cfhtls-wide_z | f_cfhtls-wide_u | ferr_cfhtls-wide_u | flag_cfhtls-wide_u | f_cfhtls-wide_g | ferr_cfhtls-wide_g | flag_cfhtls-wide_g | f_cfhtls-wide_r | ferr_cfhtls-wide_r | flag_cfhtls-wide_r | f_cfhtls-wide_i | ferr_cfhtls-wide_i | flag_cfhtls-wide_i | f_cfhtls-wide_z | ferr_cfhtls-wide_z | flag_cfhtls-wide_z | f_ap_cfhtls-wide_u | ferr_ap_cfhtls-wide_u | f_ap_cfhtls-wide_g | ferr_ap_cfhtls-wide_g | f_ap_cfhtls-wide_r | ferr_ap_cfhtls-wide_r | f_ap_cfhtls-wide_i | ferr_ap_cfhtls-wide_i | f_ap_cfhtls-wide_z | ferr_ap_cfhtls-wide_z |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deg | deg | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | mag | ||||||||||||||||||||||||||||
0 | 1330_132328 | 217.288974 | 53.658061 | 0.5 | 28.313 | 4.609 | 26.071 | 0.344 | 25.579 | 0.414 | 24.08 | 0.146 | nan | nan | 26.619 | 0.709 | 25.876 | 0.21 | 26.288 | 0.58 | 24.646 | 0.179 | nan | nan | 0.0171712 | 0.0728924 | False | 0.135394 | 0.0428978 | False | 0.21301 | 0.0812224 | False | 0.847227 | 0.113927 | False | nan | nan | False | 0.0817335 | 0.0533731 | 0.162032 | 0.0313397 | 0.110866 | 0.0592248 | 0.503037 | 0.0829333 | nan | nan |
1 | 1330_132406 | 217.286743 | 53.658362 | 0.01 | nan | nan | 24.99 | 0.23 | 24.097 | 0.19 | 23.744 | 0.193 | 22.405 | 0.204 | 25.457 | 0.246 | 24.98 | 0.093 | 24.724 | 0.137 | 24.658 | 0.175 | 24.006 | 0.361 | nan | nan | False | 0.366438 | 0.0776254 | False | 0.834065 | 0.145958 | False | 1.15452 | 0.205226 | False | 3.96278 | 0.74457 | False | 0.238341 | 0.0540021 | 0.369828 | 0.0316781 | 0.468166 | 0.0590739 | 0.497507 | 0.0801887 | 0.906984 | 0.301566 |
2 | 1330_132843 | 217.285602 | 53.660206 | 0.35 | 26.633 | 0.714 | nan | nan | nan | nan | 27.252 | 2.039 | nan | nan | 26.571 | 0.677 | nan | nan | 29.343 | 9.907 | 26.994 | 1.609 | nan | nan | 0.0806864 | 0.0530608 | False | nan | nan | False | nan | nan | False | 0.0456247 | 0.0856826 | False | nan | nan | False | 0.085428 | 0.0532678 | nan | nan | 0.00664966 | 0.0606761 | 0.0578629 | 0.0857496 | nan | nan |
3 | 1330_132939 | 217.283753 | 53.660607 | 0.46 | nan | nan | nan | nan | nan | nan | nan | nan | 26.344 | 4.104 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | False | nan | nan | False | nan | nan | False | nan | nan | False | 0.105293 | 0.398 | False | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan |
4 | 1330_132793 | 217.283488 | 53.659969 | 0.02 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | False | nan | nan | False | nan | nan | False | nan | nan | False | nan | nan | False | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan |
5 | 1330_133082 | 217.283624 | 53.661201 | 0.45 | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan | False | nan | nan | False | nan | nan | False | nan | nan | False | nan | nan | False | nan | nan | nan | nan | nan | nan | nan | nan | nan | nan |
6 | 1330_133430 | 217.281823 | 53.662807 | 0.69 | 26.552 | 0.875 | 25.84 | 0.267 | 25.817 | 0.498 | 26.17 | 0.93 | 25.627 | 2.122 | 26.592 | 0.688 | 25.677 | 0.174 | 25.705 | 0.339 | 25.516 | 0.386 | 25.674 | 1.676 | 0.0869361 | 0.0700622 | False | 0.167494 | 0.0411895 | False | 0.17108 | 0.0784703 | False | 0.123595 | 0.105867 | False | 0.203798 | 0.398309 | False | 0.0837915 | 0.0530963 | 0.194626 | 0.0311907 | 0.189671 | 0.0592209 | 0.225735 | 0.0802532 | 0.195164 | 0.301266 |
7 | 1330_133019 | 217.282465 | 53.66096 | 0.37 | nan | nan | nan | nan | nan | nan | nan | nan | 23.614 | 0.476 | nan | nan | nan | nan | nan | nan | nan | nan | 23.829 | 0.307 | nan | nan | False | nan | nan | False | nan | nan | False | nan | nan | False | 1.30137 | 0.570535 | False | nan | nan | nan | nan | nan | nan | nan | nan | 1.06758 | 0.301866 |
8 | 1330_132820 | 217.282205 | 53.660111 | 0.02 | 27.953 | 3.428 | nan | nan | nan | nan | nan | nan | nan | nan | 26.875 | 0.909 | nan | nan | nan | nan | nan | nan | 25.641 | 1.629 | 0.0239222 | 0.0755295 | False | nan | nan | False | nan | nan | False | nan | nan | False | nan | nan | False | 0.0645654 | 0.0540554 | nan | nan | nan | nan | nan | nan | 0.201187 | 0.301853 |
9 | 1330_133111 | 217.281526 | 53.661365 | 0.35 | nan | nan | nan | nan | nan | nan | nan | nan | 25.935 | 3.338 | nan | nan | nan | nan | nan | nan | 27.03 | 1.573 | 24.773 | 0.731 | nan | nan | False | nan | nan | False | nan | nan | False | nan | nan | False | 0.153462 | 0.471804 | False | nan | nan | nan | nan | nan | nan | 0.0559757 | 0.0810969 | 0.447507 | 0.301296 |