{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook prepare the catalogues that will be analysed by CIGALE for SED fitting and physical parameter estimation." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This notebook was run with herschelhelp_internal version: \n", "017bb1e (Mon Jun 18 14:58:59 2018 +0100)\n", "This notebook was executed on: \n", "2019-03-11 13:22:40.146036\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": [ "import numpy as np\n", "import os\n", "os.environ['LOG_LEVEL'] = 'INFO'\n", "\n", "from astropy.table import Table, Column\n", "\n", "from herschelhelp_internal.utils import gen_help_id\n", "\n", "from herschelhelp.filters import correct_galactic_extinction\n", "from herschelhelp.external import convert_table_for_cigale" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "source": [ "SUFFIX=\"20180619\"\n", "master_catalogue = Table.read(\"../../dmu32/dmu32_COSMOS/data/COSMOS_{}_cigale.fits\".format(SUFFIX))\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## id renaming\n", "\n", "Cigale requires the ids to be in the current format unlike the old ids used because COSMOS was processed first so we add new ones and create a cross ident for the final join to return them to the orginal values." ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": true }, "outputs": [], "source": [ "master_catalogue['help_id', 'old_help_id'].write(\n", " \"./data/master_list_help_cigale_cross_ident_cosmos_{}.fits\".format(SUFFIX), overwrite=True)\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "#For some reason there is an issue with the flag dtypes\n", "for col in master_catalogue.colnames:\n", " if col.startswith('flag') and master_catalogue[col].dtype == 'float64':\n", " master_catalogue[col] = master_catalogue[col].astype('bool')\n", " " ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/pyenv/versions/3.7.2/lib/python3.7/site-packages/astropy/table/column.py:965: RuntimeWarning: invalid value encountered in less\n", " return getattr(self.data, op)(other)\n" ] } ], "source": [ "#Remove infinities and negative values\n", "for col in master_catalogue.colnames:\n", " if col.startswith('f_') or col.startswith('ferr_') or col.startswith('m_') or col.startswith('merr_'):\n", " mask = np.isinf(master_catalogue[col]) | (master_catalogue[col] < 0)\n", " #print(\"Problems in {}: {}\".format(col,np.sum(mask)))\n", " master_catalogue[col][mask] = np.nan\n", " mask = np.isinf(master_catalogue[col]) | (master_catalogue[col] < 0)\n", " #print(\"probs after in {}: {}\".format(col,np.sum(mask)) ) " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2599374" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "len(master_catalogue)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Best sources\n", "\n", "Define a good far-IR measurement as:\n", "- an existing flux in the band;\n", "- the flag from XID+ must not be set;\n", "- the signal to noise ratio must be over 2." ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": true }, "outputs": [], "source": [ "good = {}\n", "for band in ['pacs_green', 'pacs_red', 'spire_250', 'spire_350', 'spire_500']:\n", " good[band] = (~np.isnan(master_catalogue['f_{}'.format(band)]) )\n", " good[band][good[band]] &= (master_catalogue[good[band]]['f_{}'.format(band)] /\n", " master_catalogue[good[band]]['ferr_{}'.format(band)] >= 2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We will keep only sources with at leat 2 good far-IR measurements (we may actually use less sources are not all may have a redshift)." ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": true }, "outputs": [], "source": [ "combined_good = np.sum(list(good.values()), axis=0) >= 2\n", "all_xid = np.sum(list(good.values()), axis=0) >= 0" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of good sources: 15769\n" ] } ], "source": [ "print(\"Number of good sources: {}\".format(np.sum(combined_good)))" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Only sources with at least two optical and at least two near infrared detections\n", "optnir = ((master_catalogue['flag_optnir_det'] == 3) \n", " | (master_catalogue['flag_optnir_det'] == 7))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Main catalogue for CIGALE" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": true }, "outputs": [], "source": [ "best_catalogue = master_catalogue[combined_good].copy()" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Correction for galactic extinction\n", "best_catalogue = correct_galactic_extinction(best_catalogue, inplace=True)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": true, "scrolled": false }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 851 sources, the band omegacam_u should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 778 sources, the band megacam_u should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 60 sources, the band suprime_ib427 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 326 sources, the band suprime_b should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 29 sources, the band suprime_ib464 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 109 sources, the band omegacam_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 96 sources, the band suprime_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 104 sources, the band decam_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 24 sources, the band suprime_ia484 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 91 sources, the band megacam_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 101 sources, the band gpc1_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 20 sources, the band suprime_ib505 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 15 sources, the band suprime_ia527 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 22 sources, the band suprime_v should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 10 sources, the band suprime_ib574 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 25 sources, the band acs_f606w should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 12 sources, the band suprime_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 10 sources, the band gpc1_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 8 sources, the band suprime_ia624 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 10 sources, the band megacam_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 10 sources, the band omegacam_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 10 sources, the band decam_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 9 sources, the band suprime_rc should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 4 sources, the band suprime_ia679 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 1 sources, the band suprime_ib709 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 1 sources, the band gpc1_i should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 1 sources, the band megacam_i should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 3 sources, the band omegacam_i should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 1 sources, the band suprime_ip should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 1 sources, the band suprime_i should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 1 sources, the band acs_f814w should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n" ] } ], "source": [ "# Convertion to CIGALE format\n", "best_catalogue = convert_table_for_cigale(best_catalogue, inplace=True, remove_zerofluxes=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Band selection\n", "\n", "We want to use only one filter for similar bands. We define an order of preference and set to NaN the flux in the lower prefered bands when a prefered band is available. Some band may have a 0 flux, we set there values to NaN." ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": true }, "outputs": [], "source": [ "u_bands = [\"megacam_u\", \"omegacam_u\"]\n", "g_bands = [\"megacam_g\", \"suprime_g\", \"omegacam_g\", \"decam_g\", \"gpc1_g\"]\n", "r_bands = [\"megacam_r\", \"suprime_r\", \"omegacam_r\", \"decam_r\", \"gpc1_r\"]\n", "i_bands = [\"megacam_i\", \"suprime_i\", \"omegacam_i\", \"gpc1_i\"]\n", "z_bands = [\"megacam_z\", \"suprime_z\", \"decam_z\", \"gpc1_z\"]\n", "y_bands = [ \"suprime_y\", \"gpc1_y\", \"vista_y\", \"ukidss_y\"]\n", "j_bands = [\"vista_j\", \"wircam_j\", \"ukidss_j\" ]\n", "h_bands = [\"vista_h\", \"wircam_h\", \"ukidss_h\" ]\n", "ks_bands = [\"vista_ks\", \"wircam_ks\" ]\n", "\n", "def remove_unneeded_fluxes(list_of_bands):\n", " for band_idx, band in enumerate(list_of_bands[:-1]):\n", " mask = ~np.isnan(best_catalogue[band])\n", " for lower_band in list_of_bands[band_idx+1:]:\n", " best_catalogue[lower_band][mask] = np.nan\n", " best_catalogue[\"{}_err\".format(lower_band)][mask] = np.nan" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": true }, "outputs": [], "source": [ "remove_unneeded_fluxes(u_bands)\n", "remove_unneeded_fluxes(g_bands)\n", "remove_unneeded_fluxes(r_bands)\n", "remove_unneeded_fluxes(i_bands)\n", "remove_unneeded_fluxes(z_bands)\n", "remove_unneeded_fluxes(y_bands)\n", "remove_unneeded_fluxes(j_bands)\n", "remove_unneeded_fluxes(h_bands)\n", "remove_unneeded_fluxes(ks_bands)" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": true }, "outputs": [], "source": [ "best_catalogue.write(\"data_tmp/COSMOS_cigale_best_extcor_{}.fits\".format(SUFFIX), overwrite=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## All XID+ objects" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "best_catalogue = master_catalogue[all_xid].copy()" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "# Correction for galactic extinction\n", "best_catalogue = correct_galactic_extinction(best_catalogue, inplace=True)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 123896 sources, the band omegacam_u should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 114820 sources, the band megacam_u should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 42625 sources, the band suprime_ib427 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 81401 sources, the band suprime_b should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 24427 sources, the band suprime_ib464 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 55964 sources, the band omegacam_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 53532 sources, the band suprime_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 55056 sources, the band decam_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 18364 sources, the band suprime_ia484 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 51995 sources, the band megacam_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 54278 sources, the band gpc1_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 13329 sources, the band suprime_ib505 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 10324 sources, the band suprime_ia527 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 14720 sources, the band suprime_v should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 4809 sources, the band suprime_ib574 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 19357 sources, the band acs_f606w should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 7319 sources, the band suprime_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 6912 sources, the band gpc1_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 2092 sources, the band suprime_ia624 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 6406 sources, the band megacam_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 6499 sources, the band omegacam_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 5153 sources, the band decam_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 3467 sources, the band suprime_rc should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 1007 sources, the band suprime_ia679 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 323 sources, the band suprime_ib709 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 229 sources, the band suprime_nb711 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 145 sources, the band suprime_ia738 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 352 sources, the band gpc1_i should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 389 sources, the band megacam_i should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 609 sources, the band omegacam_i should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 397 sources, the band suprime_ip should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 338 sources, the band suprime_i should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 290 sources, the band acs_f814w should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n" ] } ], "source": [ "# Convertion to CIGALE format\n", "best_catalogue = convert_table_for_cigale(best_catalogue, inplace=True, remove_zerofluxes=True)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "remove_unneeded_fluxes(u_bands)\n", "remove_unneeded_fluxes(g_bands)\n", "remove_unneeded_fluxes(r_bands)\n", "remove_unneeded_fluxes(i_bands)\n", "remove_unneeded_fluxes(z_bands)\n", "remove_unneeded_fluxes(y_bands)\n", "remove_unneeded_fluxes(j_bands)\n", "remove_unneeded_fluxes(h_bands)\n", "remove_unneeded_fluxes(ks_bands)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "best_catalogue.write(\"data_tmp/COSMOS_cigale_allxid_extcor_{}.fits\".format(SUFFIX), overwrite=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Make catalogue of all photo-z objects" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "best_catalogue = master_catalogue[optnir].copy()" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [], "source": [ "# Correction for galactic extinction\n", "best_catalogue = correct_galactic_extinction(best_catalogue, inplace=True)" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 115771 sources, the band omegacam_u should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 107289 sources, the band megacam_u should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 38631 sources, the band suprime_ib427 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 76043 sources, the band suprime_b should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 21169 sources, the band suprime_ib464 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 51511 sources, the band omegacam_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 49146 sources, the band suprime_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 50623 sources, the band decam_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 15481 sources, the band suprime_ia484 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 47661 sources, the band megacam_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 49868 sources, the band gpc1_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 10908 sources, the band suprime_ib505 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 8152 sources, the band suprime_ia527 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 12158 sources, the band suprime_v should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 3436 sources, the band suprime_ib574 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 16393 sources, the band acs_f606w should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 5607 sources, the band suprime_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 5275 sources, the band gpc1_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 1418 sources, the band suprime_ia624 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 4863 sources, the band megacam_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 4940 sources, the band omegacam_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 3728 sources, the band decam_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 2411 sources, the band suprime_rc should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 643 sources, the band suprime_ia679 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 251 sources, the band suprime_ib709 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 191 sources, the band suprime_nb711 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 127 sources, the band suprime_ia738 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 269 sources, the band gpc1_i should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 297 sources, the band megacam_i should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 413 sources, the band omegacam_i should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 302 sources, the band suprime_ip should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 259 sources, the band suprime_i should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 231 sources, the band acs_f814w should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n" ] } ], "source": [ "# Convertion to CIGALE format\n", "best_catalogue = convert_table_for_cigale(best_catalogue, inplace=True, remove_zerofluxes=True)" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "remove_unneeded_fluxes(u_bands)\n", "remove_unneeded_fluxes(g_bands)\n", "remove_unneeded_fluxes(r_bands)\n", "remove_unneeded_fluxes(i_bands)\n", "remove_unneeded_fluxes(z_bands)\n", "remove_unneeded_fluxes(y_bands)\n", "remove_unneeded_fluxes(j_bands)\n", "remove_unneeded_fluxes(h_bands)\n", "remove_unneeded_fluxes(ks_bands)" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [], "source": [ "best_catalogue.write(\"data_tmp/COSMOS_cigale_optnir_extcor_{}.fits\".format(SUFFIX), overwrite=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Catalogue using spectroscopic redshift" ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "collapsed": true }, "outputs": [], "source": [ "best_catalogue = master_catalogue[optnir].copy()" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "collapsed": true }, "outputs": [], "source": [ "best_catalogue.remove_column(\"redshift\")\n", "best_catalogue[\"zspec\"].name = \"redshift\"" ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "collapsed": true }, "outputs": [], "source": [ "best_catalogue = best_catalogue[~np.isnan(best_catalogue[\"redshift\"])]" ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec: 39892\n" ] } ], "source": [ "print(\"Number of sources with z-spec: {}\".format(len(best_catalogue)))" ] }, { "cell_type": "code", "execution_count": 32, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Correction for galactic extinction\n", "best_catalogue = correct_galactic_extinction(best_catalogue, inplace=True)" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 94 sources, the band omegacam_u should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 88 sources, the band megacam_u should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 22 sources, the band suprime_ib427 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 55 sources, the band suprime_b should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 13 sources, the band suprime_ib464 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 32 sources, the band omegacam_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 29 sources, the band suprime_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 32 sources, the band decam_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 12 sources, the band suprime_ia484 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 26 sources, the band megacam_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 30 sources, the band gpc1_g should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 5 sources, the band suprime_ib505 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 4 sources, the band suprime_ia527 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 6 sources, the band suprime_v should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 3 sources, the band suprime_ib574 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 12 sources, the band acs_f606w should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 3 sources, the band suprime_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 3 sources, the band gpc1_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 2 sources, the band suprime_ia624 should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 3 sources, the band megacam_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 3 sources, the band omegacam_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 3 sources, the band decam_r should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n", "INFO:herschelhelp.external:For 3 sources, the band suprime_rc should not be used because it overlaps or is below the Lyman limit at the redshift of these sources. These fluxes were set to NaN.\n" ] } ], "source": [ "# Convertion to CIGALE format\n", "os.environ['LOG_LEVEL'] = 'INFO'\n", "best_catalogue = convert_table_for_cigale(best_catalogue, inplace=True, remove_zerofluxes=True)" ] }, { "cell_type": "code", "execution_count": 34, "metadata": { "collapsed": true }, "outputs": [], "source": [ "remove_unneeded_fluxes(u_bands)\n", "remove_unneeded_fluxes(g_bands)\n", "remove_unneeded_fluxes(r_bands)\n", "remove_unneeded_fluxes(i_bands)\n", "remove_unneeded_fluxes(z_bands)\n", "remove_unneeded_fluxes(y_bands)\n", "remove_unneeded_fluxes(j_bands)\n", "remove_unneeded_fluxes(h_bands)\n", "remove_unneeded_fluxes(ks_bands)" ] }, { "cell_type": "code", "execution_count": 35, "metadata": { "collapsed": true }, "outputs": [], "source": [ "best_catalogue.write(\"data_tmp/COSMOS_cigale_optnir_extcor_zspec_{}.fits\".format(SUFFIX), overwrite=True)" ] } ], "metadata": { "anaconda-cloud": {}, "kernelspec": { "display_name": "Python (herschelhelp_internal)", "language": "python", "name": "helpint" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.2" } }, "nbformat": 4, "nbformat_minor": 2 }