{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Spitzer Matching Survey of the Ultra-VISTA Deep Stripes (SMUVS)\n", "\n", "Converting table format." ] }, { "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) [with local modifications]\n", "This notebook was executed on: \n", "2018-10-23 12:11:31.380643\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": 27, "metadata": {}, "outputs": [], "source": [ "\n", "from astropy.table import Table, Column\n", "from astropy.io import ascii\n", "\n", "import numpy as np\n", "\n", "import yaml\n", "\n", "import os\n", "\n", "from pymoc import MOC\n", "\n", "from herschelhelp_internal.utils import inMoc" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [], "source": [ "smuvs = ascii.read('./data/spitzer.smuvs10589.tbl')" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Table masked=True length=355913\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
surveyobjectradecmag1_psfmag1_24mag1_36mag1_48mag1_60mag1_72mag1_120mag1_errcov1flag1mag2_psfmag2_24mag2_36mag2_48mag2_60mag2_72mag2_120mag2_errcov2flag2
degdegmagmagmagmagmagmagmagmaghsmagmagmagmagmagmagmagmaghs
str5str19float64float64float64float64float64float64float64float64float64float64int64int64float64float64float64float64float64float64float64float64int64int64
SMUVSJ100059.87+021342.6150.249472.2285124.7425.0725.4326.75-99.0-99.0-99.00.251523------------------0
SMUVSJ100058.17+015800.5150.242381.9668124.7424.9524.9825.0225.2725.87-99.00.252203------------------0
SMUVSJ095957.96+022431.7149.991512.408824.7425.0925.5526.71-99.0-99.022.980.25353------------------0
SMUVSJ100050.92+021311.4150.212182.2198424.7424.8624.925.0525.2525.5-99.00.2510133------------------0
SMUVSJ100038.49+023815.0150.160372.637524.7424.8824.9425.125.3925.94-99.00.254423------------------0
SMUVSJ100004.74+020347.2150.019772.0631224.7424.925.0225.1825.4925.89-99.00.254453------------------0
SMUVSJ100057.99+022858.0150.241622.4827824.7426.02-99.0-99.0-99.0-99.0-99.00.252523------------------0
SMUVSJ100050.58+023756.6150.210732.6323824.7425.9729.12-99.0-99.0-99.0-99.00.253683------------------0
SMUVSJ095953.03+021037.7149.970952.1771424.7424.8624.8824.9925.3225.42-99.00.251003------------------0
........................................................................
SMUVSJ100132.15+022517.8150.383962.421620.9520.7820.6820.5820.4320.319.90.09758020.9820.8720.820.7120.5820.4920.050.099020
SMUVSJ100116.64+021647.1150.319342.2797620.9520.8120.7220.6220.520.3919.940.09171021.1321.1221.0921.0521.0120.9720.840.12050
SMUVSJ100226.57+014458.3150.61071.7495220.9520.9520.9520.9520.9520.9520.980.09216021.0321.0120.9820.9420.9220.9120.920.12170
SMUVSJ100220.64+021150.0150.585992.1972420.9520.9420.9420.9320.9120.920.890.09491021.5121.021.0220.9820.8920.8420.80.13940
SMUVSJ100143.37+022821.3150.430692.4725920.9520.9520.9520.9520.9420.9420.870.091529021.3721.3721.3721.3621.3521.3421.240.113640
SMUVSJ100135.17+020925.5150.396532.1570820.9520.8720.8120.7720.7220.6820.540.09430020.9120.8620.8320.7920.7620.7320.650.095150
SMUVSJ100208.92+021443.3150.537162.2453620.9520.9220.8720.8420.8120.7920.50.09850021.1621.1421.121.0721.0621.0620.850.17440
SMUVSJ100212.93+020529.9150.553872.0916320.9520.9120.920.8820.8220.7820.710.091128020.8220.7420.6220.5420.4720.4320.410.098920
SMUVSJ100130.34+020538.1150.37642.0939120.9520.9721.021.0321.0521.0721.120.09709021.0621.0621.0721.0621.0621.0621.040.16980
SMUVSJ100148.69+021019.1150.452872.1719620.9520.920.8220.7620.7220.7120.730.091736021.4321.3721.2721.2121.1721.1521.180.116880
" ], "text/plain": [ "\n", "survey object ra dec ... mag2_120 mag2_err cov2 flag2\n", " deg deg ... mag mag hs \n", " str5 str19 float64 float64 ... float64 float64 int64 int64\n", "------ ------------------- --------- ------- ... -------- -------- ----- -----\n", " SMUVS J100059.87+021342.6 150.24947 2.22851 ... -- -- -- 0\n", " SMUVS J100058.17+015800.5 150.24238 1.96681 ... -- -- -- 0\n", " SMUVS J095957.96+022431.7 149.99151 2.4088 ... -- -- -- 0\n", " SMUVS J100050.92+021311.4 150.21218 2.21984 ... -- -- -- 0\n", " SMUVS J100038.49+023815.0 150.16037 2.6375 ... -- -- -- 0\n", " SMUVS J100004.74+020347.2 150.01977 2.06312 ... -- -- -- 0\n", " SMUVS J100057.99+022858.0 150.24162 2.48278 ... -- -- -- 0\n", " SMUVS J100050.58+023756.6 150.21073 2.63238 ... -- -- -- 0\n", " SMUVS J095953.03+021037.7 149.97095 2.17714 ... -- -- -- 0\n", " ... ... ... ... ... ... ... ... ...\n", " SMUVS J100132.15+022517.8 150.38396 2.4216 ... 20.05 0.09 902 0\n", " SMUVS J100116.64+021647.1 150.31934 2.27976 ... 20.84 0.1 205 0\n", " SMUVS J100226.57+014458.3 150.6107 1.74952 ... 20.92 0.1 217 0\n", " SMUVS J100220.64+021150.0 150.58599 2.19724 ... 20.8 0.1 394 0\n", " SMUVS J100143.37+022821.3 150.43069 2.47259 ... 21.24 0.1 1364 0\n", " SMUVS J100135.17+020925.5 150.39653 2.15708 ... 20.65 0.09 515 0\n", " SMUVS J100208.92+021443.3 150.53716 2.24536 ... 20.85 0.1 744 0\n", " SMUVS J100212.93+020529.9 150.55387 2.09163 ... 20.41 0.09 892 0\n", " SMUVS J100130.34+020538.1 150.3764 2.09391 ... 21.04 0.1 698 0\n", " SMUVS J100148.69+021019.1 150.45287 2.17196 ... 21.18 0.1 1688 0" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "smuvs" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Table length=355913\n", "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
surveyobjectradecmag1_psfmag1_24mag1_36mag1_48mag1_60mag1_72mag1_120mag1_errcov1flag1mag2_psfmag2_24mag2_36mag2_48mag2_60mag2_72mag2_120mag2_errcov2flag2
degdegmagmagmagmagmagmagmagmaghsmagmagmagmagmagmagmagmaghs
str5str19float64float64float64float64float64float64float64float64float64float64int64int64float64float64float64float64float64float64float64float64int64int64
SMUVSJ100059.87+021342.6150.249472.2285124.7425.0725.4326.75-99.0-99.0-99.00.251523nannannannannannannannan-10
SMUVSJ100058.17+015800.5150.242381.9668124.7424.9524.9825.0225.2725.87-99.00.252203nannannannannannannannan-10
SMUVSJ095957.96+022431.7149.991512.408824.7425.0925.5526.71-99.0-99.022.980.25353nannannannannannannannan-10
SMUVSJ100050.92+021311.4150.212182.2198424.7424.8624.925.0525.2525.5-99.00.2510133nannannannannannannannan-10
SMUVSJ100038.49+023815.0150.160372.637524.7424.8824.9425.125.3925.94-99.00.254423nannannannannannannannan-10
SMUVSJ100004.74+020347.2150.019772.0631224.7424.925.0225.1825.4925.89-99.00.254453nannannannannannannannan-10
SMUVSJ100057.99+022858.0150.241622.4827824.7426.02-99.0-99.0-99.0-99.0-99.00.252523nannannannannannannannan-10
SMUVSJ100050.58+023756.6150.210732.6323824.7425.9729.12-99.0-99.0-99.0-99.00.253683nannannannannannannannan-10
SMUVSJ095953.03+021037.7149.970952.1771424.7424.8624.8824.9925.3225.42-99.00.251003nannannannannannannannan-10
........................................................................
SMUVSJ100132.15+022517.8150.383962.421620.9520.7820.6820.5820.4320.319.90.09758020.9820.8720.820.7120.5820.4920.050.099020
SMUVSJ100116.64+021647.1150.319342.2797620.9520.8120.7220.6220.520.3919.940.09171021.1321.1221.0921.0521.0120.9720.840.12050
SMUVSJ100226.57+014458.3150.61071.7495220.9520.9520.9520.9520.9520.9520.980.09216021.0321.0120.9820.9420.9220.9120.920.12170
SMUVSJ100220.64+021150.0150.585992.1972420.9520.9420.9420.9320.9120.920.890.09491021.5121.021.0220.9820.8920.8420.80.13940
SMUVSJ100143.37+022821.3150.430692.4725920.9520.9520.9520.9520.9420.9420.870.091529021.3721.3721.3721.3621.3521.3421.240.113640
SMUVSJ100135.17+020925.5150.396532.1570820.9520.8720.8120.7720.7220.6820.540.09430020.9120.8620.8320.7920.7620.7320.650.095150
SMUVSJ100208.92+021443.3150.537162.2453620.9520.9220.8720.8420.8120.7920.50.09850021.1621.1421.121.0721.0621.0620.850.17440
SMUVSJ100212.93+020529.9150.553872.0916320.9520.9120.920.8820.8220.7820.710.091128020.8220.7420.6220.5420.4720.4320.410.098920
SMUVSJ100130.34+020538.1150.37642.0939120.9520.9721.021.0321.0521.0721.120.09709021.0621.0621.0721.0621.0621.0621.040.16980
SMUVSJ100148.69+021019.1150.452872.1719620.9520.920.8220.7620.7220.7120.730.091736021.4321.3721.2721.2121.1721.1521.180.116880
" ], "text/plain": [ "\n", "survey object ra dec ... mag2_120 mag2_err cov2 flag2\n", " deg deg ... mag mag hs \n", " str5 str19 float64 float64 ... float64 float64 int64 int64\n", "------ ------------------- --------- ------- ... -------- -------- ----- -----\n", " SMUVS J100059.87+021342.6 150.24947 2.22851 ... nan nan -1 0\n", " SMUVS J100058.17+015800.5 150.24238 1.96681 ... nan nan -1 0\n", " SMUVS J095957.96+022431.7 149.99151 2.4088 ... nan nan -1 0\n", " SMUVS J100050.92+021311.4 150.21218 2.21984 ... nan nan -1 0\n", " SMUVS J100038.49+023815.0 150.16037 2.6375 ... nan nan -1 0\n", " SMUVS J100004.74+020347.2 150.01977 2.06312 ... nan nan -1 0\n", " SMUVS J100057.99+022858.0 150.24162 2.48278 ... nan nan -1 0\n", " SMUVS J100050.58+023756.6 150.21073 2.63238 ... nan nan -1 0\n", " SMUVS J095953.03+021037.7 149.97095 2.17714 ... nan nan -1 0\n", " ... ... ... ... ... ... ... ... ...\n", " SMUVS J100132.15+022517.8 150.38396 2.4216 ... 20.05 0.09 902 0\n", " SMUVS J100116.64+021647.1 150.31934 2.27976 ... 20.84 0.1 205 0\n", " SMUVS J100226.57+014458.3 150.6107 1.74952 ... 20.92 0.1 217 0\n", " SMUVS J100220.64+021150.0 150.58599 2.19724 ... 20.8 0.1 394 0\n", " SMUVS J100143.37+022821.3 150.43069 2.47259 ... 21.24 0.1 1364 0\n", " SMUVS J100135.17+020925.5 150.39653 2.15708 ... 20.65 0.09 515 0\n", " SMUVS J100208.92+021443.3 150.53716 2.24536 ... 20.85 0.1 744 0\n", " SMUVS J100212.93+020529.9 150.55387 2.09163 ... 20.41 0.09 892 0\n", " SMUVS J100130.34+020538.1 150.3764 2.09391 ... 21.04 0.1 698 0\n", " SMUVS J100148.69+021019.1 150.45287 2.17196 ... 21.18 0.1 1688 0" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "for col in smuvs.colnames:\n", " if (smuvs[col].dtype == 'float64'): \n", " smuvs[col].fill_value = np.nan\n", " if (smuvs[col].dtype == 'int64'):\n", " smuvs[col].fill_value = -1\n", " \n", "smuvs = smuvs.filled()\n", "\n", "smuvs" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [], "source": [ "def cut_to_help(cat, fields_yml, ra_col='ra', dec_col='dec' ):\n", " catalogue = cat.copy()\n", " try:\n", " catalogue.add_column(Column(data=np.full(len(catalogue), '') , dtype='S18', name = 'field'))\n", " except ValueError:\n", " print('field column already exists, flushing column')\n", " catalogue['field'] = np.full(len(catalogue), '')\n", " catalogue['field'] = catalogue['field'].astype('S18')\n", " for field in fields_yml['fields']:\n", " field_moc = MOC(filename= os.getcwd().split('dmu_products')[0] + field['region'] )\n", " in_field = inMoc(catalogue[ra_col], catalogue[dec_col], field_moc)\n", " catalogue['field'][in_field] = field['name']\n", " \n", " catalogue = catalogue[catalogue['field'] != '']\n", " \n", " return catalogue" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "field column already exists, flushing column\n" ] } ], "source": [ "fields_yml = yaml.load(open(\"../../dmu2/meta_main.yml\", 'r'))\n", "smuvs = cut_to_help(smuvs, fields_yml)" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "data": { "text/html": [ "<Column name='field' dtype='bytes18' length=1>\n", "
\n", "\n", "
COSMOS
" ], "text/plain": [ "\n", "COSMOS" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np.unique(smuvs['field'])" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [ { "data": { "text/html": [ "Table length=355913\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
surveyobjectradecmag1_psfmag1_24mag1_36mag1_48mag1_60mag1_72mag1_120mag1_errcov1flag1mag2_psfmag2_24mag2_36mag2_48mag2_60mag2_72mag2_120mag2_errcov2flag2field
degdegmagmagmagmagmagmagmagmaghsmagmagmagmagmagmagmagmaghs
str5str19float64float64float64float64float64float64float64float64float64float64int64int64float64float64float64float64float64float64float64float64int64int64bytes18
SMUVSJ100059.87+021342.6150.249472.2285124.7425.0725.4326.75-99.0-99.0-99.00.251523nannannannannannannannan-10COSMOS
SMUVSJ100058.17+015800.5150.242381.9668124.7424.9524.9825.0225.2725.87-99.00.252203nannannannannannannannan-10COSMOS
SMUVSJ095957.96+022431.7149.991512.408824.7425.0925.5526.71-99.0-99.022.980.25353nannannannannannannannan-10COSMOS
SMUVSJ100050.92+021311.4150.212182.2198424.7424.8624.925.0525.2525.5-99.00.2510133nannannannannannannannan-10COSMOS
SMUVSJ100038.49+023815.0150.160372.637524.7424.8824.9425.125.3925.94-99.00.254423nannannannannannannannan-10COSMOS
SMUVSJ100004.74+020347.2150.019772.0631224.7424.925.0225.1825.4925.89-99.00.254453nannannannannannannannan-10COSMOS
SMUVSJ100057.99+022858.0150.241622.4827824.7426.02-99.0-99.0-99.0-99.0-99.00.252523nannannannannannannannan-10COSMOS
SMUVSJ100050.58+023756.6150.210732.6323824.7425.9729.12-99.0-99.0-99.0-99.00.253683nannannannannannannannan-10COSMOS
SMUVSJ095953.03+021037.7149.970952.1771424.7424.8624.8824.9925.3225.42-99.00.251003nannannannannannannannan-10COSMOS
...........................................................................
SMUVSJ100132.15+022517.8150.383962.421620.9520.7820.6820.5820.4320.319.90.09758020.9820.8720.820.7120.5820.4920.050.099020COSMOS
SMUVSJ100116.64+021647.1150.319342.2797620.9520.8120.7220.6220.520.3919.940.09171021.1321.1221.0921.0521.0120.9720.840.12050COSMOS
SMUVSJ100226.57+014458.3150.61071.7495220.9520.9520.9520.9520.9520.9520.980.09216021.0321.0120.9820.9420.9220.9120.920.12170COSMOS
SMUVSJ100220.64+021150.0150.585992.1972420.9520.9420.9420.9320.9120.920.890.09491021.5121.021.0220.9820.8920.8420.80.13940COSMOS
SMUVSJ100143.37+022821.3150.430692.4725920.9520.9520.9520.9520.9420.9420.870.091529021.3721.3721.3721.3621.3521.3421.240.113640COSMOS
SMUVSJ100135.17+020925.5150.396532.1570820.9520.8720.8120.7720.7220.6820.540.09430020.9120.8620.8320.7920.7620.7320.650.095150COSMOS
SMUVSJ100208.92+021443.3150.537162.2453620.9520.9220.8720.8420.8120.7920.50.09850021.1621.1421.121.0721.0621.0620.850.17440COSMOS
SMUVSJ100212.93+020529.9150.553872.0916320.9520.9120.920.8820.8220.7820.710.091128020.8220.7420.6220.5420.4720.4320.410.098920COSMOS
SMUVSJ100130.34+020538.1150.37642.0939120.9520.9721.021.0321.0521.0721.120.09709021.0621.0621.0721.0621.0621.0621.040.16980COSMOS
SMUVSJ100148.69+021019.1150.452872.1719620.9520.920.8220.7620.7220.7120.730.091736021.4321.3721.2721.2121.1721.1521.180.116880COSMOS
" ], "text/plain": [ "\n", "survey object ra dec ... mag2_err cov2 flag2 field \n", " deg deg ... mag hs \n", " str5 str19 float64 float64 ... float64 int64 int64 bytes18\n", "------ ------------------- --------- ------- ... -------- ----- ----- -------\n", " SMUVS J100059.87+021342.6 150.24947 2.22851 ... nan -1 0 COSMOS\n", " SMUVS J100058.17+015800.5 150.24238 1.96681 ... nan -1 0 COSMOS\n", " SMUVS J095957.96+022431.7 149.99151 2.4088 ... nan -1 0 COSMOS\n", " SMUVS J100050.92+021311.4 150.21218 2.21984 ... nan -1 0 COSMOS\n", " SMUVS J100038.49+023815.0 150.16037 2.6375 ... nan -1 0 COSMOS\n", " SMUVS J100004.74+020347.2 150.01977 2.06312 ... nan -1 0 COSMOS\n", " SMUVS J100057.99+022858.0 150.24162 2.48278 ... nan -1 0 COSMOS\n", " SMUVS J100050.58+023756.6 150.21073 2.63238 ... nan -1 0 COSMOS\n", " SMUVS J095953.03+021037.7 149.97095 2.17714 ... nan -1 0 COSMOS\n", " ... ... ... ... ... ... ... ... ...\n", " SMUVS J100132.15+022517.8 150.38396 2.4216 ... 0.09 902 0 COSMOS\n", " SMUVS J100116.64+021647.1 150.31934 2.27976 ... 0.1 205 0 COSMOS\n", " SMUVS J100226.57+014458.3 150.6107 1.74952 ... 0.1 217 0 COSMOS\n", " SMUVS J100220.64+021150.0 150.58599 2.19724 ... 0.1 394 0 COSMOS\n", " SMUVS J100143.37+022821.3 150.43069 2.47259 ... 0.1 1364 0 COSMOS\n", " SMUVS J100135.17+020925.5 150.39653 2.15708 ... 0.09 515 0 COSMOS\n", " SMUVS J100208.92+021443.3 150.53716 2.24536 ... 0.1 744 0 COSMOS\n", " SMUVS J100212.93+020529.9 150.55387 2.09163 ... 0.09 892 0 COSMOS\n", " SMUVS J100130.34+020538.1 150.3764 2.09391 ... 0.1 698 0 COSMOS\n", " SMUVS J100148.69+021019.1 150.45287 2.17196 ... 0.1 1688 0 COSMOS" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "smuvs" ] }, { "cell_type": "code", "execution_count": 49, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING: Attribute `keywords` of type cannot be added to FITS Header - skipping [astropy.io.fits.convenience]\n" ] } ], "source": [ "smuvs.write('./data/SMUVS_COSMOS.fits', overwrite=True)" ] } ], "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.5" } }, "nbformat": 4, "nbformat_minor": 2 }