{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# XMM-LSS master catalogue\n", "## Preparation of Canada France Hawaii Telescope Lensing Survey (CFHTLenS) data\n", "\n", "CFHTLenS catalogue: the catalogue comes from `dmu0_CFHTLenS`.\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 kron magnitude, there doesn't appear to be aperture magnitudes. This may mean the survey is unusable.\n", "\n", "We use the publication year 2012 for the 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, 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 = \"cfhtlens_ra\"\n", "DEC_COL = \"cfhtlens_dec\"" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## I - Column selection" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "imported_columns = OrderedDict({\n", " 'id': \"cfhtlens_id\",\n", " 'ALPHA_J2000': \"cfhtlens_ra\",\n", " 'DELTA_J2000': \"cfhtlens_dec\",\n", " 'CLASS_STAR': \"cfhtlens_stellarity\",\n", " 'MAG_u': \"m_cfhtlens_u\",\n", " 'MAGERR_u': \"merr_cfhtlens_u\",\n", " 'MAG_g': \"m_cfhtlens_g\",\n", " 'MAGERR_g': \"merr_cfhtlens_g\",\n", " 'MAG_r': \"m_cfhtlens_r\",\n", " 'MAGERR_r': \"merr_cfhtlens_r\",\n", " 'MAG_i': \"m_cfhtlens_i\",\n", " 'MAGERR_i': \"merr_cfhtlens_i\",\n", " 'MAG_z': \"m_cfhtlens_z\",\n", " 'MAGERR_z': \"merr_cfhtlens_z\",\n", "\n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_CFHTLenS/data/CFHTLenS_XMM-LSS.fits\")[list(imported_columns)]\n", "for column in imported_columns:\n", " catalogue[column].name = imported_columns[column]\n", "\n", "epoch = 2012 #Year of publication\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", "/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/ipykernel/__main__.py:10: RuntimeWarning: invalid value encountered in greater\n", "/opt/anaconda3/envs/herschelhelp_internal/lib/python3.6/site-packages/ipykernel/__main__.py:11: RuntimeWarning: invalid value encountered in greater\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", "\n", " catalogue[col][catalogue[col] <= 0] = np.nan\n", " catalogue[errcol][catalogue[errcol] <= 0] = np.nan \n", " catalogue[col][catalogue[col] > 90.] = np.nan\n", " catalogue[errcol][catalogue[errcol] > 90.] = np.nan \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", " # We add nan filled aperture photometry for consistency\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", " 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=\"f_err{}\".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 | cfhtlens_id | cfhtlens_ra | cfhtlens_dec | cfhtlens_stellarity | m_cfhtlens_u | merr_cfhtlens_u | m_cfhtlens_g | merr_cfhtlens_g | m_cfhtlens_r | merr_cfhtlens_r | m_cfhtlens_i | merr_cfhtlens_i | m_cfhtlens_z | merr_cfhtlens_z | f_cfhtlens_u | ferr_cfhtlens_u | m_ap_cfhtlens_u | merr_ap_cfhtlens_u | f_ap_cfhtlens_u | f_err_cfhtlens_u | flag_cfhtlens_u | f_cfhtlens_g | ferr_cfhtlens_g | m_ap_cfhtlens_g | merr_ap_cfhtlens_g | f_ap_cfhtlens_g | f_err_cfhtlens_g | flag_cfhtlens_g | f_cfhtlens_r | ferr_cfhtlens_r | m_ap_cfhtlens_r | merr_ap_cfhtlens_r | f_ap_cfhtlens_r | f_err_cfhtlens_r | flag_cfhtlens_r | f_cfhtlens_i | ferr_cfhtlens_i | m_ap_cfhtlens_i | merr_ap_cfhtlens_i | f_ap_cfhtlens_i | f_err_cfhtlens_i | flag_cfhtlens_i | f_cfhtlens_z | ferr_cfhtlens_z | m_ap_cfhtlens_z | merr_ap_cfhtlens_z | f_ap_cfhtlens_z | f_err_cfhtlens_z | flag_cfhtlens_z |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | W1m0m0_58200 | 34.97608891 | -7.148180002 | 0.125238 | 24.7001 | 0.0244 | 24.5122 | 0.0153 | 24.2311 | 0.0164 | 23.6667 | 0.013 | 23.2328 | 0.0389 | 0.478586 | 0.0107554 | nan | nan | nan | nan | False | 0.56901 | 0.00801839 | nan | nan | nan | nan | False | 0.737157 | 0.0111347 | nan | nan | nan | nan | False | 1.23971 | 0.0148436 | nan | nan | nan | nan | False | 1.84876 | 0.0662377 | nan | nan | nan | nan | False |
1 | W1m0m0_58307 | 34.97553765 | -7.147594403 | 0.0348409 | 25.2701 | 0.042 | 24.9268 | 0.0235 | 24.2157 | 0.0177 | 23.9323 | 0.0187 | 23.8053 | 0.0723 | 0.283113 | 0.0109518 | nan | nan | nan | nan | False | 0.388401 | 0.00840666 | nan | nan | nan | nan | False | 0.747687 | 0.012189 | nan | nan | nan | nan | False | 0.970688 | 0.0167185 | nan | nan | nan | nan | False | 1.09114 | 0.0726598 | nan | nan | nan | nan | False |
2 | W1m0m0_58338 | 34.97477759 | -7.147310794 | 0.10283 | 25.7656 | 0.0546 | 25.4248 | 0.0307 | 25.0854 | 0.0309 | 24.1991 | 0.0193 | 23.9888 | 0.0714 | 0.179374 | 0.00902045 | nan | nan | nan | nan | False | 0.245516 | 0.00694214 | nan | nan | nan | nan | False | 0.335614 | 0.00955155 | nan | nan | nan | nan | False | 0.759206 | 0.0134956 | nan | nan | nan | nan | False | 0.921467 | 0.0605974 | nan | nan | nan | nan | False |
3 | W1m0m0_58425 | 34.97648555 | -7.147048435 | 0.0334521 | 25.0326 | 0.0318 | 24.1322 | 0.0115 | 23.4131 | 0.0093 | 23.116 | 0.0084 | 22.9289 | 0.0307 | 0.352338 | 0.0103196 | nan | nan | nan | nan | False | 0.807458 | 0.0085525 | nan | nan | nan | nan | False | 1.56589 | 0.0134128 | nan | nan | nan | nan | False | 2.05873 | 0.0159278 | nan | nan | nan | nan | False | 2.44591 | 0.0691599 | nan | nan | nan | nan | False |
4 | W1m0m0_59092 | 34.97096718 | -7.142727738 | 0.185944 | 25.351 | 0.0414 | 25.4873 | 0.0338 | 25.2047 | 0.0358 | 24.8708 | 0.036 | 24.6408 | 0.1331 | 0.262785 | 0.0100202 | nan | nan | nan | nan | False | 0.231782 | 0.00721559 | nan | nan | nan | nan | False | 0.300691 | 0.00991468 | nan | nan | nan | nan | False | 0.408959 | 0.01356 | nan | nan | nan | nan | False | 0.505452 | 0.0619631 | nan | nan | nan | nan | False |
5 | W1m0m0_59094 | 34.97634122 | -7.142734419 | 0.662571 | nan | nan | nan | nan | 26.3557 | 0.1188 | 25.3482 | 0.0704 | 24.3778 | 0.1312 | nan | nan | nan | nan | nan | nan | False | nan | nan | nan | nan | nan | nan | False | 0.104165 | 0.0113976 | nan | nan | nan | nan | False | 0.263463 | 0.0170832 | nan | nan | nan | nan | False | 0.643991 | 0.0778197 | nan | nan | nan | nan | False |
6 | W1m0m0_59109 | 34.97395827 | -7.142847132 | 0.0263345 | 23.4666 | 0.0116 | 23.0577 | 0.0061 | 22.3561 | 0.0053 | 21.7435 | 0.0035 | 21.5923 | 0.013 | 1.4906 | 0.0159255 | nan | nan | nan | nan | False | 2.1723 | 0.0122047 | nan | nan | nan | nan | False | 4.14534 | 0.0202354 | nan | nan | nan | nan | False | 7.28786 | 0.0234933 | nan | nan | nan | nan | False | 8.37683 | 0.100299 | nan | nan | nan | nan | False |
7 | W1m0m0_59314 | 34.96874302 | -7.1414873 | 0.502324 | nan | nan | 26.7327 | 0.1321 | 26.0602 | 0.1168 | 25.0129 | 0.0558 | nan | nan | nan | nan | nan | nan | nan | nan | False | 0.0736071 | 0.00895567 | nan | nan | nan | nan | False | 0.136748 | 0.0147109 | nan | nan | nan | nan | False | 0.35879 | 0.0184395 | nan | nan | nan | nan | False | nan | nan | nan | nan | nan | nan | False |
8 | W1m0m0_59397 | 34.96990438 | -7.141068291 | 0.786291 | 26.8578 | 0.1481 | 25.5332 | 0.036 | 24.7594 | 0.0257 | 24.5431 | 0.0278 | 24.7351 | 0.15 | 0.0655964 | 0.00894769 | nan | nan | nan | nan | False | 0.222188 | 0.00736713 | nan | nan | nan | nan | False | 0.453148 | 0.0107263 | nan | nan | nan | nan | False | 0.553044 | 0.0141606 | nan | nan | nan | nan | False | 0.463404 | 0.0640216 | nan | nan | nan | nan | False |
9 | W1m0m0_59409 | 34.96991906 | -7.142105269 | 0.982462 | 23.9837 | 0.0181 | 21.7363 | 0.0025 | 20.5776 | 0.0017 | 19.8505 | 0.001 | 19.4975 | 0.0023 | 0.925806 | 0.0154338 | nan | nan | nan | nan | False | 7.33635 | 0.0168926 | nan | nan | nan | nan | False | 21.3285 | 0.0333952 | nan | nan | nan | nan | False | 41.6677 | 0.0383774 | nan | nan | nan | nan | False | 57.6767 | 0.122181 | nan | nan | nan | nan | False |