{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Lockman SWIRE master catalogue\n", "## Preparation of Red Cluster Sequence Lensing Survey (RCSLenS) data\n", "\n", "This catalogue comes from `dmu0_RCSLenS`.\n", "\n", "In the catalogue, we keep:\n", "\n", "- The `id` as unique object identifier;\n", "- The position;\n", "- The g, r, i, z, y auto magnitudes.\n", "\n", "### Strange magnitudes\n", "\n", "The missing values seems to be encoded as -99. but there are also quite some 99. magnitudes.\n", "\n", "The “sensible” range of magnitudes seems to go from 14 to 37 (depending on the bands and given that 37 is really\n", "faint and may not be reliable). In addition to that there are some very low magnitudes under -40. and very high ones\n", "above 90. We don't know the meaning of these extreme values so we are removing all the negative magnitudes and and\n", "those above 80.\n", "\n", "We are also removing the sources for which we have no magnitude information given the modifications above." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This notebook was run with herschelhelp_internal version: \n", "44f1ae0 (Thu Nov 30 18:27:54 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 = \"rcs_ra\"\n", "DEC_COL = \"rcs_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\": \"rcs_id\",\n", " \"ALPHA_J2000\": \"rcs_ra\",\n", " \"DELTA_J2000\": \"rcs_dec\",\n", " \"CLASS_STAR\": \"rcs_stellarity\",\n", " \"MAG_g\": \"m_rcs_g\",\n", " \"MAGERR_g\": \"merr_rcs_g\",\n", " \"MAG_r\": \"m_rcs_r\",\n", " \"MAGERR_r\": \"merr_rcs_r\", \n", " \"MAG_i\": \"m_rcs_i\",\n", " \"MAGERR_i\": \"merr_rcs_i\",\n", " \"MAG_z\": \"m_rcs_z\",\n", " \"MAGERR_z\": \"merr_rcs_z\",\n", " \"MAG_y\": \"m_rcs_y\",\n", " \"MAGERR_y\": \"merr_rcs_y\" \n", " })\n", "\n", "\n", "catalogue = Table.read(\"../../dmu0/dmu0_RCSLenS/data/RCSLenS_Lockman-SWIRE.fits\")[list(imported_columns)]\n", "for column in imported_columns:\n", " catalogue[column].name = imported_columns[column]\n", "\n", "epoch = 2017\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", " # Remove missing values (-99, 99?) and extreme magnitudes (see above).\n", " mask = (catalogue[col] < 0) | (catalogue[col] > 80)\n", " catalogue[col][mask] = np.nan\n", " catalogue[errcol][mask] = 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 columns because no aperture fluxes are present\n", " # EDIT: Better not add empty columns if we can avoid.\n", " #nancol = np.zeros(len(catalogue))\n", " #nancol.fill(np.nan)\n", " #catalogue.add_column(Column(nancol, \n", " # name=\"m_ap{}\".format(col[1:])))\n", " #catalogue.add_column(Column(nancol, \n", " # name=\"merr_ap{}\".format(col[1:])))\n", " #catalogue.add_column(Column(nancol, \n", " # name=\"f_ap{}\".format(col[1:])))\n", " #catalogue.add_column(Column(nancol, \n", " # name=\"ferr_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 length=10>\n", "
idx | rcs_id | rcs_ra | rcs_dec | rcs_stellarity | m_rcs_g | merr_rcs_g | m_rcs_r | merr_rcs_r | m_rcs_i | merr_rcs_i | m_rcs_z | merr_rcs_z | m_rcs_y | merr_rcs_y | f_rcs_g | ferr_rcs_g | flag_rcs_g | f_rcs_r | ferr_rcs_r | flag_rcs_r | f_rcs_i | ferr_rcs_i | flag_rcs_i | f_rcs_z | ferr_rcs_z | flag_rcs_z | f_rcs_y | ferr_rcs_y | flag_rcs_y |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | CDE1040A1_012221 | 164.8274632 | 55.9342951 | 0.59 | 26.4383 | 0.192844 | 24.954 | 0.0591562 | 24.3109 | 0.0468637 | 24.2471 | 0.128944 | nan | nan | 0.096534 | 0.017146 | False | 0.378791 | 0.0206384 | False | 0.68492 | 0.0295633 | False | 0.726372 | 0.0862653 | False | nan | nan | False |
1 | CDE1040A1_012351 | 164.8598581 | 55.9352114 | 0.51 | nan | nan | 24.0958 | 0.111241 | 24.3293 | 0.179642 | nan | nan | nan | nan | nan | nan | False | 0.834987 | 0.08555 | False | 0.673411 | 0.11142 | False | nan | nan | False | nan | nan | False |
2 | CDE1040A1_012523 | 164.8440663 | 55.9366953 | 0.05 | 24.9588 | 0.0891576 | 24.0017 | 0.0422543 | 23.8614 | 0.0494575 | 23.3469 | 0.096879 | nan | nan | 0.37712 | 0.0309681 | False | 0.910584 | 0.0354378 | False | 1.03619 | 0.0472006 | False | 1.66433 | 0.148506 | False | nan | nan | False |
3 | CDE1040A1_012541 | 164.856439 | 55.936853 | 0.05 | 24.7429 | 0.0641804 | 24.0179 | 0.0365814 | 23.8584 | 0.0421868 | 23.8193 | 0.125855 | nan | nan | 0.460086 | 0.0271968 | False | 0.897098 | 0.0302257 | False | 1.03906 | 0.0403731 | False | 1.07716 | 0.124861 | False | nan | nan | False |
4 | CDE1040A1_012593 | 164.844011 | 55.9373469 | 0.69 | 25.0123 | 0.0667518 | 25.01 | 0.067012 | 24.947 | 0.0838051 | nan | nan | nan | nan | 0.358988 | 0.0220708 | False | 0.359749 | 0.0222038 | False | 0.381241 | 0.029427 | False | nan | nan | False | nan | nan | False |
5 | CDE1040A1_012610 | 164.8309266 | 55.9375784 | 0.53 | 25.7485 | 0.158175 | 25.0131 | 0.0894123 | 24.6255 | 0.0859212 | 24.1334 | 0.171663 | nan | nan | 0.182222 | 0.0265469 | False | 0.358724 | 0.0295415 | False | 0.512625 | 0.0405673 | False | 0.806566 | 0.127524 | False | nan | nan | False |
6 | CDE1040A1_012657 | 164.8606267 | 55.9380141 | 0.7 | 25.164 | 0.0863055 | 24.5895 | 0.0555585 | 24.4154 | 0.0632862 | 24.1565 | 0.154603 | nan | nan | 0.312176 | 0.024815 | False | 0.529907 | 0.027116 | False | 0.622071 | 0.0362597 | False | 0.789587 | 0.112433 | False | nan | nan | False |
7 | CDE1040A1_012667 | 164.8430236 | 55.9382088 | 0.48 | 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 |
8 | CDE1040A1_012677 | 164.8294469 | 55.9382729 | 0.9 | nan | nan | 24.0691 | 0.0291555 | nan | nan | 23.2083 | 0.0539764 | nan | nan | nan | nan | False | 0.855776 | 0.0229803 | False | nan | nan | False | 1.89095 | 0.0940069 | False | nan | nan | False |
9 | CDE1040A1_012702 | 164.8438543 | 55.9384471 | 0.58 | 25.2618 | 0.104723 | 25.1174 | 0.0949201 | nan | nan | nan | nan | nan | nan | 0.285285 | 0.0275167 | False | 0.325867 | 0.0284888 | False | nan | nan | False | nan | nan | False | nan | nan | False |