{ "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": { "collapsed": true }, "outputs": [], "source": [ "import numpy as np\n", "import os\n", "os.environ['LOG_LEVEL'] = 'INFO'\n", "import glob\n", "from astropy.table import Table\n", "\n", "from herschelhelp.filters import correct_galactic_extinction\n", "from herschelhelp.external import convert_table_for_cigale" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "SUFFIX = '20180221'\n", "file_list = glob.glob('../../dmu32/dmu32_SGP/data/tiles/sgp_{}_cigale_*.fits'.format(SUFFIX))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": true }, "outputs": [], "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": 4, "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", "# ~master_catalogue['flag_{}'.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": 5, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# combined_good = np.sum(list(good.values()), axis=0) >= 2" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# print(\"Number of good sources: {}\".format(np.sum(combined_good)))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Main catalogue for CIGALE" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# best_catalogue = master_catalogue[combined_good].copy()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# # Correction for galactic extinction\n", "# best_catalogue = correct_galactic_extinction(best_catalogue, inplace=True)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": true, "scrolled": false }, "outputs": [], "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": 10, "metadata": { "collapsed": true }, "outputs": [], "source": [ "u_bands = [\"omegacam_u\"]\n", "g_bands = [\"omegacam_g\", \"decam_g\", \"gpc1_g\"]\n", "r_bands = [\"omegacam_r\", \"decam_r\", \"gpc1_r\"]\n", "i_bands = [\"omegacam_i\", \"decam_i\", \"gpc1_i\"]\n", "z_bands = [ \"decam_z\", \"vista_z\", \"gpc1_z\"]\n", "y_bands = [ \"decam_y\", \"vista_y\", \"gpc1_y\"]\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": 11, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# remove_unneeded_fluxes(g_bands)\n", "# remove_unneeded_fluxes(u_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)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": true }, "outputs": [], "source": [ "non_band_flags = ['flag_cigale', \n", " 'flag_cigale_opt', \n", " 'flag_cigale_ir', \n", " 'flag_cigale_ironly', \n", " 'flag_gaia', \n", " 'flag_cleaned', \n", " 'flag_merged', \n", " 'flag_optnir_obs', \n", " 'flag_optnir_det']" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 265: 1373\n", "Number of sources with z-spec in file 54: 772\n", "Number of sources with z-spec in file 182: 1219\n", "Number of sources with z-spec in file 120: 1607\n", "Number of sources with z-spec in file 111: 1544\n", "Number of sources with z-spec in file 254: 992\n", "Number of sources with z-spec in file 65: 1534\n", "Number of sources with z-spec in file 173: 1332\n", "Number of sources with z-spec in file 294: 1215\n", "Number of sources with z-spec in file 138: 590\n", "Number of sources with z-spec in file 236: 1259\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 36: 1275\n", "Number of sources with z-spec in file 207: 1233\n", "Number of sources with z-spec in file 109: 1800\n", "Number of sources with z-spec in file 94: 1612\n", "Number of sources with z-spec in file 142: 590\n", "Number of sources with z-spec in file 9: 1137\n", "Number of sources with z-spec in file 115: 1529\n", "Number of sources with z-spec in file 88: 1624\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 61: 819\n", "Number of sources with z-spec in file 250: 991\n", "Number of sources with z-spec in file 186: 1194\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 50: 1097\n", "Number of sources with z-spec in file 261: 1277\n", "Number of sources with z-spec in file 124: 1436\n", "Number of sources with z-spec in file 288: 819\n", "Number of sources with z-spec in file 248: 1019\n", "Number of sources with z-spec in file 79: 1753\n", "Number of sources with z-spec in file 203: 1098\n", "Number of sources with z-spec in file 32: 1688\n", "Number of sources with z-spec in file 146: 508\n", "Number of sources with z-spec in file 90: 1341\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 290: 1013\n", "Number of sources with z-spec in file 177: 985\n", "Number of sources with z-spec in file 232: 1166\n", "Number of sources with z-spec in file 279: 871\n", "Number of sources with z-spec in file 48: 1594\n", "Number of sources with z-spec in file 130: 581\n", "Number of sources with z-spec in file 192: 909\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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 1 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 1 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 1 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 1 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 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 44: 1604\n", "Number of sources with z-spec in file 275: 902\n", "Number of sources with z-spec in file 75: 1589\n", "Number of sources with z-spec in file 244: 1335\n", "Number of sources with z-spec in file 1: 1309\n", "Number of sources with z-spec in file 101: 1390\n", "Number of sources with z-spec in file 226: 1092\n", "Number of sources with z-spec in file 17: 985\n", "Number of sources with z-spec in file 128: 1088\n", "Number of sources with z-spec in file 284: 1014\n", "Number of sources with z-spec in file 163: 888\n", "Number of sources with z-spec in file 152: 557\n", "Number of sources with z-spec in file 84: 1091\n", "Number of sources with z-spec in file 119: 1217\n", "Number of sources with z-spec in file 217: 1205\n", "Number of sources with z-spec in file 26: 1824\n", "Number of sources with z-spec in file 240: 1194\n", "Number of sources with z-spec in file 71: 1612\n", "Number of sources with z-spec in file 5: 1013\n", "Number of sources with z-spec in file 98: 1151\n", "Number of sources with z-spec in file 105: 1590\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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 1 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 1 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 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 134: 146\n", "Number of sources with z-spec in file 271: 859\n", "Number of sources with z-spec in file 40: 1608\n", "Number of sources with z-spec in file 196: 1224\n", "Number of sources with z-spec in file 80: 1582\n", "Number of sources with z-spec in file 156: 687\n", "Number of sources with z-spec in file 22: 777\n", "Number of sources with z-spec in file 213: 1277\n", "Number of sources with z-spec in file 69: 1117\n", "Number of sources with z-spec in file 258: 1077\n", "Number of sources with z-spec in file 58: 750\n", "Number of sources with z-spec in file 269: 1014\n", "Number of sources with z-spec in file 13: 1366\n", "Number of sources with z-spec in file 222: 1261\n", "Number of sources with z-spec in file 167: 777\n", "Number of sources with z-spec in file 280: 1193\n", "Number of sources with z-spec in file 131: 524\n", "Number of sources with z-spec in file 45: 1579\n", "Number of sources with z-spec in file 274: 910\n", "Number of sources with z-spec in file 193: 1115\n", "Number of sources with z-spec in file 74: 1537\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 2 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 245: 1181\n", "Number of sources with z-spec in file 100: 1513\n", "Number of sources with z-spec in file 0: 1388\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 2 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 2 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 2 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 2 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 1 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 1 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 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 227: 1043\n", "Number of sources with z-spec in file 16: 1178\n", "Number of sources with z-spec in file 162: 986\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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 1 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 1 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 1 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 1 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 1 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 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 129: 762\n", "Number of sources with z-spec in file 285: 1117\n", "Number of sources with z-spec in file 85: 1417\n", "Number of sources with z-spec in file 118: 1586\n", "Number of sources with z-spec in file 153: 774\n", "Number of sources with z-spec in file 216: 908\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 27: 1334\n", "Number of sources with z-spec in file 241: 1225\n", "Number of sources with z-spec in file 70: 1399\n", "Number of sources with z-spec in file 99: 1425\n", "Number of sources with z-spec in file 104: 1567\n", "Number of sources with z-spec in file 4: 854\n", "Number of sources with z-spec in file 135: 537\n", "Number of sources with z-spec in file 197: 1377\n", "Number of sources with z-spec in file 270: 1223\n", "Number of sources with z-spec in file 41: 1811\n", "Number of sources with z-spec in file 157: 684\n", "Number of sources with z-spec in file 81: 1353\n", "Number of sources with z-spec in file 68: 1206\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 2 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 259: 1012\n", "Number of sources with z-spec in file 23: 1075\n", "Number of sources with z-spec in file 212: 1183\n", "Number of sources with z-spec in file 12: 1280\n", "Number of sources with z-spec in file 223: 1105\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 59: 649\n", "Number of sources with z-spec in file 268: 1093\n", "Number of sources with z-spec in file 281: 1191\n", "Number of sources with z-spec in file 166: 910\n", "Number of sources with z-spec in file 183: 1388\n", "Number of sources with z-spec in file 264: 1422\n", "Number of sources with z-spec in file 55: 727\n", "Number of sources with z-spec in file 121: 1647\n", "Number of sources with z-spec in file 110: 1322\n", "Number of sources with z-spec in file 255: 886\n", "Number of sources with z-spec in file 64: 1923\n", "Number of sources with z-spec in file 295: 980\n", "Number of sources with z-spec in file 139: 732\n", "Number of sources with z-spec in file 172: 1502\n", "Number of sources with z-spec in file 237: 1288\n", "Number of sources with z-spec in file 37: 1722\n", "Number of sources with z-spec in file 206: 1190\n", "Number of sources with z-spec in file 8: 876\n", "Number of sources with z-spec in file 143: 575\n", "Number of sources with z-spec in file 108: 1841\n", "Number of sources with z-spec in file 95: 1555\n", "Number of sources with z-spec in file 114: 1620\n", "Number of sources with z-spec in file 89: 1489\n", "Number of sources with z-spec in file 60: 1542\n", "Number of sources with z-spec in file 251: 798\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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 1 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 1 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 1 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 1 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 1 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 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 51: 884\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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 1 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 1 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 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 260: 1204\n", "Number of sources with z-spec in file 187: 1334\n", "Number of sources with z-spec in file 125: 1081\n", "Number of sources with z-spec in file 289: 929\n", "Number of sources with z-spec in file 202: 1123\n", "Number of sources with z-spec in file 33: 1372\n", "Number of sources with z-spec in file 249: 1211\n", "Number of sources with z-spec in file 78: 2026\n", "Number of sources with z-spec in file 91: 1371\n", "Number of sources with z-spec in file 147: 475\n", "Number of sources with z-spec in file 176: 1358\n", "Number of sources with z-spec in file 291: 975\n", "Number of sources with z-spec in file 278: 749\n", "Number of sources with z-spec in file 49: 1449\n", "Number of sources with z-spec in file 233: 1023\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 47: 1403\n", "Number of sources with z-spec in file 276: 863\n", "Number of sources with z-spec in file 191: 1119\n", "Number of sources with z-spec in file 178: 1217\n", "Number of sources with z-spec in file 133: 79\n", "Number of sources with z-spec in file 2: 1045\n", "Number of sources with z-spec in file 102: 1508\n", "Number of sources with z-spec in file 149: 7\n", "Number of sources with z-spec in file 76: 1429\n", "Number of sources with z-spec in file 247: 995\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 160: 897\n", "Number of sources with z-spec in file 287: 1008\n", "Number of sources with z-spec in file 225: 1107\n", "Number of sources with z-spec in file 189: 1009\n", "Number of sources with z-spec in file 14: 1614\n", "Number of sources with z-spec in file 214: 1121\n", "Number of sources with z-spec in file 25: 1550\n", "Number of sources with z-spec in file 87: 1849\n", "Number of sources with z-spec in file 151: 160\n", "Number of sources with z-spec in file 6: 981\n", "Number of sources with z-spec in file 106: 1364\n", "Number of sources with z-spec in file 243: 1111\n", "Number of sources with z-spec in file 72: 1551\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 208: 1329\n", "Number of sources with z-spec in file 39: 1482\n", "Number of sources with z-spec in file 195: 1292\n", "Number of sources with z-spec in file 239: 1188\n", "Number of sources with z-spec in file 272: 1044\n", "Number of sources with z-spec in file 43: 1323\n", "Number of sources with z-spec in file 137: 572\n", "Number of sources with z-spec in file 21: 1127\n", "Number of sources with z-spec in file 210: 955\n", "Number of sources with z-spec in file 155: 778\n", "Number of sources with z-spec in file 83: 1271\n", "Number of sources with z-spec in file 283: 1154\n", "Number of sources with z-spec in file 164: 1052\n", "Number of sources with z-spec in file 10: 1310\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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 1 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 1 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 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 221: 1138\n", "Number of sources with z-spec in file 123: 1465\n", "Number of sources with z-spec in file 168: 795\n", "Number of sources with z-spec in file 181: 975\n", "Number of sources with z-spec in file 266: 1377\n", "Number of sources with z-spec in file 57: 1187\n", "Number of sources with z-spec in file 257: 1100\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 66: 1651\n", "Number of sources with z-spec in file 159: 918\n", "Number of sources with z-spec in file 112: 1879\n", "Number of sources with z-spec in file 199: 1401\n", "Number of sources with z-spec in file 235: 1118\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 2 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 297: 1165\n", "Number of sources with z-spec in file 170: 1196\n", "Number of sources with z-spec in file 141: 472\n", "Number of sources with z-spec in file 97: 1416\n", "Number of sources with z-spec in file 35: 1173\n", "Number of sources with z-spec in file 204: 1135\n", "Number of sources with z-spec in file 29: 1829\n", "Number of sources with z-spec in file 218: 1426\n", "Number of sources with z-spec in file 62: 805\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 253: 947\n", "Number of sources with z-spec in file 116: 1530\n", "Number of sources with z-spec in file 127: 1335\n", "Number of sources with z-spec in file 53: 1476\n", "Number of sources with z-spec in file 262: 1285\n", "Number of sources with z-spec in file 18: 1160\n", "Number of sources with z-spec in file 229: 1102\n", "Number of sources with z-spec in file 185: 1519\n", "Number of sources with z-spec in file 93: 1482\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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 1 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 1 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 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 145: 540\n", "Number of sources with z-spec in file 200: 1228\n", "Number of sources with z-spec in file 31: 1571\n", "Number of sources with z-spec in file 231: 1217\n", "Number of sources with z-spec in file 174: 1335\n", "Number of sources with z-spec in file 293: 1138\n", "Number of sources with z-spec in file 169: 976\n", "Number of sources with z-spec in file 122: 1479\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 2 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 1 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 1 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 1 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 1 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 1 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 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 267: 1274\n", "Number of sources with z-spec in file 56: 1285\n", "Number of sources with z-spec in file 180: 1060\n", "Number of sources with z-spec in file 256: 983\n", "Number of sources with z-spec in file 67: 1604\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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 1 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 1 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 1 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 1 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 1 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 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 113: 1565\n", "Number of sources with z-spec in file 158: 971\n", "Number of sources with z-spec in file 198: 1276\n", "Number of sources with z-spec in file 234: 964\n", "Number of sources with z-spec in file 171: 1356\n", "Number of sources with z-spec in file 296: 1131\n", "Number of sources with z-spec in file 96: 1535\n", "Number of sources with z-spec in file 140: 536\n", "Number of sources with z-spec in file 34: 1642\n", "Number of sources with z-spec in file 205: 1418\n", "Number of sources with z-spec in file 63: 1593\n", "Number of sources with z-spec in file 252: 787\n", "Number of sources with z-spec in file 28: 1712\n", "Number of sources with z-spec in file 219: 1270\n", "Number of sources with z-spec in file 117: 1372\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 126: 1151\n", "Number of sources with z-spec in file 19: 1631\n", "Number of sources with z-spec in file 228: 1242\n", "Number of sources with z-spec in file 184: 1535\n", "Number of sources with z-spec in file 52: 1046\n", "Number of sources with z-spec in file 263: 1361\n", "Number of sources with z-spec in file 144: 577\n", "Number of sources with z-spec in file 92: 1587\n", "Number of sources with z-spec in file 201: 1364\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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 1 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 1 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 1 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 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 30: 1606\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 230: 1150\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 292: 973\n", "Number of sources with z-spec in file 175: 1365\n", "Number of sources with z-spec in file 190: 1281\n", "Number of sources with z-spec in file 46: 1642\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 277: 718\n", "Number of sources with z-spec in file 132: 425\n", "Number of sources with z-spec in file 179: 1083\n", "Number of sources with z-spec in file 148: 273\n", "Number of sources with z-spec in file 103: 1491\n", "Number of sources with z-spec in file 3: 868\n", "Number of sources with z-spec in file 77: 1688\n", "Number of sources with z-spec in file 246: 1072\n", "Number of sources with z-spec in file 286: 1034\n", "Number of sources with z-spec in file 161: 953\n", "Number of sources with z-spec in file 224: 1312\n", "Number of sources with z-spec in file 188: 1061\n", "Number of sources with z-spec in file 15: 1798\n", "Number of sources with z-spec in file 215: 996\n", "Number of sources with z-spec in file 24: 1535\n", "Number of sources with z-spec in file 150: 0\n", "Number of sources with z-spec in file 86: 1749\n", "Number of sources with z-spec in file 107: 1447\n", "Number of sources with z-spec in file 7: 972\n", "Number of sources with z-spec in file 209: 1172\n", "Number of sources with z-spec in file 38: 1547\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 242: 1216\n", "Number of sources with z-spec in file 73: 1048\n", "Number of sources with z-spec in file 273: 1056\n", "Number of sources with z-spec in file 42: 1633\n", "Number of sources with z-spec in file 194: 1195\n", "Number of sources with z-spec in file 238: 1351\n", "Number of sources with z-spec in file 136: 632\n", "Number of sources with z-spec in file 20: 1199\n", "Number of sources with z-spec in file 211: 1018\n", "Number of sources with z-spec in file 82: 1350\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "INFO:herschelhelp.external:For 1 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" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 154: 745\n", "Number of sources with z-spec in file 165: 969\n", "Number of sources with z-spec in file 282: 1274\n", "Number of sources with z-spec in file 11: 1727\n", "Number of sources with z-spec in file 220: 1186\n", "Number of zphot optnir objects: 352804\n" ] } ], "source": [ "#best_catalogue.write(\"data_tmp/CDFS-SWIRE_cigale_best_extcor_20180129.fits\")\n", "n_zphot = 0\n", "for tile in file_list:\n", " \n", " file_num = tile.split('_')[4].split('.')[0]\n", " best_catalogue = Table.read(tile)\n", " \n", " #Temp solution to problem caused by flag unit = mag:\n", " for col in best_catalogue.colnames:\n", " if col.startswith('flag_') and (col not in non_band_flags):\n", " best_catalogue[col].unit = None\n", " best_catalogue[col] = best_catalogue[col].astype(bool)\n", " \n", " \n", " optnir = ((best_catalogue['flag_optnir_det'] == 3) \n", " | (best_catalogue['flag_optnir_det'] == 7))\n", " \n", " good = {}\n", " for band in [ 'spire_250', 'spire_350', 'spire_500']:\n", " good[band] = (~np.isnan(best_catalogue['f_{}'.format(band)]) & \n", " ~best_catalogue['flag_{}'.format(band)])\n", " good[band][good[band]] &= (best_catalogue[good[band]]['f_{}'.format(band)] /\n", " best_catalogue[good[band]]['ferr_{}'.format(band)] >= 2)\n", " \n", " combined_good = np.sum(list(good.values()), axis=0) >= 2\n", " \n", " best_catalogue = best_catalogue[combined_good]\n", " #best_catalogue = best_catalogue[optnir]\n", "\n", "\n", " best_catalogue = best_catalogue[~np.isnan(best_catalogue[\"redshift\"])]\n", " n_zphot += len(best_catalogue)\n", " \n", "\n", " print(\"Number of sources with z-spec in file {}: {}\".format(file_num, len(best_catalogue)))\n", "\n", " # Correction for galactic extinction\n", " best_catalogue = correct_galactic_extinction(best_catalogue, inplace=True)\n", "\n", " # Convertion to CIGALE format\n", "\n", " best_catalogue = convert_table_for_cigale(best_catalogue, inplace=True, remove_zerofluxes=True)\n", "\n", " remove_unneeded_fluxes(g_bands)\n", " remove_unneeded_fluxes(u_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", "\n", " #best_catalogue.write(\"data_tmp/tiles/SGP_cigale_optnir_extcor_{}_{}.fits\".format(SUFFIX, file_num), overwrite=True)\n", " best_catalogue.write(\"data_tmp/tiles/SGP_cigale_best_extcor_{}_{}.fits\".format(SUFFIX, file_num), overwrite=True)\n", " \n", "print(\"Number of zphot optnir objects: {}\".format(n_zphot))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Catalogue using spectroscopic redshift" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Number of sources with z-spec in file 265: 12\n", "Number of sources with z-spec in file 54: 16\n", "Number of sources with z-spec in file 182: 30\n", "Number of sources with z-spec in file 120: 33\n", "Number of sources with z-spec in file 111: 39\n", "Number of sources with z-spec in file 254: 14\n", "Number of sources with z-spec in file 65: 40\n", "Number of sources with z-spec in file 173: 17\n", "Number of sources with z-spec in file 294: 57\n", "Number of sources with z-spec in file 138: 5\n", "Number of sources with z-spec in file 236: 36\n", "Number of sources with z-spec in file 36: 27\n", "Number of sources with z-spec in file 207: 33\n", "Number of sources with z-spec in file 109: 38\n", "Number of sources with z-spec in file 94: 35\n", "Number of sources with z-spec in file 142: 14\n", "Number of sources with z-spec in file 9: 26\n", "Number of sources with z-spec in file 115: 36\n", "Number of sources with z-spec in file 88: 36\n", "Number of sources with z-spec in file 61: 22\n", "Number of sources with z-spec in file 250: 41\n", "Number of sources with z-spec in file 186: 32\n", "Number of sources with z-spec in file 50: 25\n", "Number of sources with z-spec in file 261: 20\n", "Number of sources with z-spec in file 124: 41\n", "Number of sources with z-spec in file 288: 31\n", "Number of sources with z-spec in file 248: 22\n", "Number of sources with z-spec in file 79: 28\n", "Number of sources with z-spec in file 203: 18\n", "Number of sources with z-spec in file 32: 45\n", "Number of sources with z-spec in file 146: 9\n", "Number of sources with z-spec in file 90: 18\n", "Number of sources with z-spec in file 290: 43\n", "Number of sources with z-spec in file 177: 16\n", "Number of sources with z-spec in file 232: 33\n", "Number of sources with z-spec in file 279: 10\n", "Number of sources with z-spec in file 48: 31\n", "Number of sources with z-spec in file 130: 2\n", "Number of sources with z-spec in file 192: 23\n", "Number of sources with z-spec in file 44: 20\n", "Number of sources with z-spec in file 275: 8\n", "Number of sources with z-spec in file 75: 23\n", "Number of sources with z-spec in file 244: 31\n", "Number of sources with z-spec in file 1: 20\n", "Number of sources with z-spec in file 101: 37\n", "Number of sources with z-spec in file 226: 34\n", "Number of sources with z-spec in file 17: 24\n", "Number of sources with z-spec in file 128: 20\n", "Number of sources with z-spec in file 284: 5\n", "Number of sources with z-spec in file 163: 22\n", "Number of sources with z-spec in file 152: 15\n", "Number of sources with z-spec in file 84: 23\n", "Number of sources with z-spec in file 119: 23\n", "Number of sources with z-spec in file 217: 36\n", "Number of sources with z-spec in file 26: 37\n", "Number of sources with z-spec in file 240: 36\n", "Number of sources with z-spec in file 71: 42\n", "Number of sources with z-spec in file 5: 17\n", "Number of sources with z-spec in file 98: 26\n", "Number of sources with z-spec in file 105: 28\n", "Number of sources with z-spec in file 134: 2\n", "Number of sources with z-spec in file 271: 10\n", "Number of sources with z-spec in file 40: 27\n", "Number of sources with z-spec in file 196: 47\n", "Number of sources with z-spec in file 80: 25\n", "Number of sources with z-spec in file 156: 20\n", "Number of sources with z-spec in file 22: 8\n", "Number of sources with z-spec in file 213: 26\n", "Number of sources with z-spec in file 69: 19\n", "Number of sources with z-spec in file 258: 32\n", "Number of sources with z-spec in file 58: 15\n", "Number of sources with z-spec in file 269: 10\n", "Number of sources with z-spec in file 13: 27\n", "Number of sources with z-spec in file 222: 27\n", "Number of sources with z-spec in file 167: 6\n", "Number of sources with z-spec in file 280: 7\n", "Number of sources with z-spec in file 131: 5\n", "Number of sources with z-spec in file 45: 31\n", "Number of sources with z-spec in file 274: 4\n", "Number of sources with z-spec in file 193: 27\n", "Number of sources with z-spec in file 74: 32\n", "Number of sources with z-spec in file 245: 20\n", "Number of sources with z-spec in file 100: 24\n", "Number of sources with z-spec in file 0: 36\n", "Number of sources with z-spec in file 227: 34\n", "Number of sources with z-spec in file 16: 38\n", "Number of sources with z-spec in file 162: 11\n", "Number of sources with z-spec in file 129: 13\n", "Number of sources with z-spec in file 285: 14\n", "Number of sources with z-spec in file 85: 23\n", "Number of sources with z-spec in file 118: 25\n", "Number of sources with z-spec in file 153: 22\n", "Number of sources with z-spec in file 216: 27\n", "Number of sources with z-spec in file 27: 25\n", "Number of sources with z-spec in file 241: 26\n", "Number of sources with z-spec in file 70: 28\n", "Number of sources with z-spec in file 99: 21\n", "Number of sources with z-spec in file 104: 32\n", "Number of sources with z-spec in file 4: 14\n", "Number of sources with z-spec in file 135: 3\n", "Number of sources with z-spec in file 197: 49\n", "Number of sources with z-spec in file 270: 5\n", "Number of sources with z-spec in file 41: 36\n", "Number of sources with z-spec in file 157: 20\n", "Number of sources with z-spec in file 81: 29\n", "Number of sources with z-spec in file 68: 19\n", "Number of sources with z-spec in file 259: 15\n", "Number of sources with z-spec in file 23: 19\n", "Number of sources with z-spec in file 212: 17\n", "Number of sources with z-spec in file 12: 20\n", "Number of sources with z-spec in file 223: 33\n", "Number of sources with z-spec in file 59: 8\n", "Number of sources with z-spec in file 268: 17\n", "Number of sources with z-spec in file 281: 13\n", "Number of sources with z-spec in file 166: 16\n", "Number of sources with z-spec in file 183: 42\n", "Number of sources with z-spec in file 264: 11\n", "Number of sources with z-spec in file 55: 20\n", "Number of sources with z-spec in file 121: 39\n", "Number of sources with z-spec in file 110: 22\n", "Number of sources with z-spec in file 255: 11\n", "Number of sources with z-spec in file 64: 47\n", "Number of sources with z-spec in file 295: 44\n", "Number of sources with z-spec in file 139: 14\n", "Number of sources with z-spec in file 172: 25\n", "Number of sources with z-spec in file 237: 22\n", "Number of sources with z-spec in file 37: 35\n", "Number of sources with z-spec in file 206: 33\n", "Number of sources with z-spec in file 8: 14\n", "Number of sources with z-spec in file 143: 8\n", "Number of sources with z-spec in file 108: 27\n", "Number of sources with z-spec in file 95: 27\n", "Number of sources with z-spec in file 114: 34\n", "Number of sources with z-spec in file 89: 32\n", "Number of sources with z-spec in file 60: 27\n", "Number of sources with z-spec in file 251: 15\n", "Number of sources with z-spec in file 51: 21\n", "Number of sources with z-spec in file 260: 17\n", "Number of sources with z-spec in file 187: 33\n", "Number of sources with z-spec in file 125: 24\n", "Number of sources with z-spec in file 289: 31\n", "Number of sources with z-spec in file 202: 29\n", "Number of sources with z-spec in file 33: 28\n", "Number of sources with z-spec in file 249: 31\n", "Number of sources with z-spec in file 78: 38\n", "Number of sources with z-spec in file 91: 14\n", "Number of sources with z-spec in file 147: 1\n", "Number of sources with z-spec in file 176: 19\n", "Number of sources with z-spec in file 291: 41\n", "Number of sources with z-spec in file 278: 4\n", "Number of sources with z-spec in file 49: 24\n", "Number of sources with z-spec in file 233: 40\n", "Number of sources with z-spec in file 47: 24\n", "Number of sources with z-spec in file 276: 9\n", "Number of sources with z-spec in file 191: 22\n", "Number of sources with z-spec in file 178: 10\n", "Number of sources with z-spec in file 133: 2\n", "Number of sources with z-spec in file 2: 27\n", "Number of sources with z-spec in file 102: 20\n", "Number of sources with z-spec in file 149: 1\n", "Number of sources with z-spec in file 76: 20\n", "Number of sources with z-spec in file 247: 18\n", "Number of sources with z-spec in file 160: 15\n", "Number of sources with z-spec in file 287: 18\n", "Number of sources with z-spec in file 225: 33\n", "Number of sources with z-spec in file 189: 25\n", "Number of sources with z-spec in file 14: 35\n", "Number of sources with z-spec in file 214: 24\n", "Number of sources with z-spec in file 25: 48\n", "Number of sources with z-spec in file 87: 37\n", "Number of sources with z-spec in file 151: 4\n", "Number of sources with z-spec in file 6: 25\n", "Number of sources with z-spec in file 106: 28\n", "Number of sources with z-spec in file 243: 32\n", "Number of sources with z-spec in file 72: 45\n", "Number of sources with z-spec in file 208: 35\n", "Number of sources with z-spec in file 39: 30\n", "Number of sources with z-spec in file 195: 32\n", "Number of sources with z-spec in file 239: 23\n", "Number of sources with z-spec in file 272: 8\n", "Number of sources with z-spec in file 43: 24\n", "Number of sources with z-spec in file 137: 10\n", "Number of sources with z-spec in file 21: 23\n", "Number of sources with z-spec in file 210: 18\n", "Number of sources with z-spec in file 155: 8\n", "Number of sources with z-spec in file 83: 29\n", "Number of sources with z-spec in file 283: 4\n", "Number of sources with z-spec in file 164: 14\n", "Number of sources with z-spec in file 10: 34\n", "Number of sources with z-spec in file 221: 25\n", "Number of sources with z-spec in file 123: 28\n", "Number of sources with z-spec in file 168: 14\n", "Number of sources with z-spec in file 181: 18\n", "Number of sources with z-spec in file 266: 16\n", "Number of sources with z-spec in file 57: 26\n", "Number of sources with z-spec in file 257: 13\n", "Number of sources with z-spec in file 66: 26\n", "Number of sources with z-spec in file 159: 18\n", "Number of sources with z-spec in file 112: 37\n", "Number of sources with z-spec in file 199: 34\n", "Number of sources with z-spec in file 235: 19\n", "Number of sources with z-spec in file 297: 33\n", "Number of sources with z-spec in file 170: 17\n", "Number of sources with z-spec in file 141: 10\n", "Number of sources with z-spec in file 97: 37\n", "Number of sources with z-spec in file 35: 15\n", "Number of sources with z-spec in file 204: 21\n", "Number of sources with z-spec in file 29: 42\n", "Number of sources with z-spec in file 218: 36\n", "Number of sources with z-spec in file 62: 20\n", "Number of sources with z-spec in file 253: 14\n", "Number of sources with z-spec in file 116: 41\n", "Number of sources with z-spec in file 127: 27\n", "Number of sources with z-spec in file 53: 32\n", "Number of sources with z-spec in file 262: 19\n", "Number of sources with z-spec in file 18: 17\n", "Number of sources with z-spec in file 229: 40\n", "Number of sources with z-spec in file 185: 30\n", "Number of sources with z-spec in file 93: 29\n", "Number of sources with z-spec in file 145: 9\n", "Number of sources with z-spec in file 200: 43\n", "Number of sources with z-spec in file 31: 33\n", "Number of sources with z-spec in file 231: 41\n", "Number of sources with z-spec in file 174: 25\n", "Number of sources with z-spec in file 293: 54\n", "Number of sources with z-spec in file 169: 12\n", "Number of sources with z-spec in file 122: 46\n", "Number of sources with z-spec in file 267: 22\n", "Number of sources with z-spec in file 56: 23\n", "Number of sources with z-spec in file 180: 17\n", "Number of sources with z-spec in file 256: 10\n", "Number of sources with z-spec in file 67: 26\n", "Number of sources with z-spec in file 113: 40\n", "Number of sources with z-spec in file 158: 33\n", "Number of sources with z-spec in file 198: 32\n", "Number of sources with z-spec in file 234: 21\n", "Number of sources with z-spec in file 171: 16\n", "Number of sources with z-spec in file 296: 58\n", "Number of sources with z-spec in file 96: 34\n", "Number of sources with z-spec in file 140: 8\n", "Number of sources with z-spec in file 34: 45\n", "Number of sources with z-spec in file 205: 31\n", "Number of sources with z-spec in file 63: 46\n", "Number of sources with z-spec in file 252: 29\n", "Number of sources with z-spec in file 28: 25\n", "Number of sources with z-spec in file 219: 35\n", "Number of sources with z-spec in file 117: 38\n", "Number of sources with z-spec in file 126: 38\n", "Number of sources with z-spec in file 19: 42\n", "Number of sources with z-spec in file 228: 43\n", "Number of sources with z-spec in file 184: 44\n", "Number of sources with z-spec in file 52: 25\n", "Number of sources with z-spec in file 263: 22\n", "Number of sources with z-spec in file 144: 13\n", "Number of sources with z-spec in file 92: 25\n", "Number of sources with z-spec in file 201: 34\n", "Number of sources with z-spec in file 30: 26\n", "Number of sources with z-spec in file 230: 30\n", "Number of sources with z-spec in file 292: 59\n", "Number of sources with z-spec in file 175: 7\n", "Number of sources with z-spec in file 190: 26\n", "Number of sources with z-spec in file 46: 35\n", "Number of sources with z-spec in file 277: 5\n", "Number of sources with z-spec in file 132: 3\n", "Number of sources with z-spec in file 179: 16\n", "Number of sources with z-spec in file 148: 4\n", "Number of sources with z-spec in file 103: 32\n", "Number of sources with z-spec in file 3: 14\n", "Number of sources with z-spec in file 77: 18\n", "Number of sources with z-spec in file 246: 26\n", "Number of sources with z-spec in file 286: 7\n", "Number of sources with z-spec in file 161: 29\n", "Number of sources with z-spec in file 224: 31\n", "Number of sources with z-spec in file 188: 27\n", "Number of sources with z-spec in file 15: 39\n", "Number of sources with z-spec in file 215: 30\n", "Number of sources with z-spec in file 24: 28\n", "Number of sources with z-spec in file 150: 0\n", "Number of sources with z-spec in file 86: 42\n", "Number of sources with z-spec in file 107: 31\n", "Number of sources with z-spec in file 7: 22\n", "Number of sources with z-spec in file 209: 30\n", "Number of sources with z-spec in file 38: 35\n", "Number of sources with z-spec in file 242: 25\n", "Number of sources with z-spec in file 73: 20\n", "Number of sources with z-spec in file 273: 1\n", "Number of sources with z-spec in file 42: 38\n", "Number of sources with z-spec in file 194: 11\n", "Number of sources with z-spec in file 238: 31\n", "Number of sources with z-spec in file 136: 4\n", "Number of sources with z-spec in file 20: 26\n", "Number of sources with z-spec in file 211: 12\n", "Number of sources with z-spec in file 82: 33\n", "Number of sources with z-spec in file 154: 16\n", "Number of sources with z-spec in file 165: 19\n", "Number of sources with z-spec in file 282: 10\n", "Number of sources with z-spec in file 11: 38\n", "Number of sources with z-spec in file 220: 30\n", "Number of zspec optnir objects: 7356\n" ] } ], "source": [ "n_zspec = 0\n", "for tile in file_list:\n", " \n", " file_num = tile.split('_')[4].split('.')[0]\n", " best_catalogue = Table.read(tile)\n", " \n", " #Temp solution to problem caused by flag unit = mag:\n", " for col in best_catalogue.colnames:\n", " if col.startswith('flag_') and (col not in non_band_flags):\n", " best_catalogue[col].unit = None\n", " best_catalogue[col] = best_catalogue[col].astype(bool)\n", " \n", " \n", " \n", " \n", " optnir = ((best_catalogue['flag_optnir_det'] == 3) \n", " | (best_catalogue['flag_optnir_det'] == 7))\n", " \n", " good = {}\n", " for band in [ 'spire_250', 'spire_350', 'spire_500']:\n", " good[band] = (~np.isnan(best_catalogue['f_{}'.format(band)]) & \n", " ~best_catalogue['flag_{}'.format(band)])\n", " good[band][good[band]] &= (best_catalogue[good[band]]['f_{}'.format(band)] /\n", " best_catalogue[good[band]]['ferr_{}'.format(band)] >= 2)\n", " \n", " combined_good = np.sum(list(good.values()), axis=0) >= 2\n", " \n", " best_catalogue = best_catalogue[combined_good]\n", " #best_catalogue = best_catalogue[optnir]\n", "\n", "\n", " best_catalogue = best_catalogue[~np.isnan(best_catalogue[\"zspec\"])]\n", " best_catalogue.remove_column('redshift')\n", " best_catalogue[\"zspec\"].name = \"redshift\"\n", " n_zspec += len(best_catalogue)\n", "\n", " print(\"Number of sources with z-spec in file {}: {}\".format(file_num, len(best_catalogue)))\n", "\n", " # Correction for galactic extinction\n", " best_catalogue = correct_galactic_extinction(best_catalogue, inplace=True)\n", "\n", " # Convertion to CIGALE format\n", "\n", " best_catalogue = convert_table_for_cigale(best_catalogue, inplace=True, remove_zerofluxes=True)\n", "\n", " remove_unneeded_fluxes(g_bands)\n", " remove_unneeded_fluxes(u_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", "\n", "\n", " best_catalogue.write(\"data_tmp/tiles/SGP_cigale_best_extcor_zspec_{}_{}.fits\".format(SUFFIX, file_num), \n", " overwrite=True)\n", " \n", "print(\"Number of zspec optnir objects: {}\".format(n_zspec))" ] } ], "metadata": { "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.6.4" } }, "nbformat": 4, "nbformat_minor": 2 }