{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# SPIRE-NEP Generate hole region files\n", "\n", "## I. Produce simple 10 arcsec holes. \n", "First we produce the simplest possible hole regions. For every star brighter than 16 Mag it puts a 10 arcsec circle. \n", "\n", "We then go on to produce varying size holes for individual pristine catalogues based on parameters computed by Seb Oliver's IDL code." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "This notebook was run with herschelhelp_internal version: \n", <<<<<<< HEAD "017bb1e (Mon Jun 18 14:58:59 2018 +0100)\n" ======= "f5c65d1 (Fri Feb 1 10:51:16 2019 +0000)\n" >>>>>>> upstream/master ] } ], "source": [ "from herschelhelp_internal import git_version\n", "print(\"This notebook was run with herschelhelp_internal version: \\n{}\".format(git_version()))" ] }, { "cell_type": "code", "execution_count": 2, <<<<<<< HEAD "metadata": { "collapsed": true }, ======= "metadata": {}, >>>>>>> upstream/master "outputs": [], "source": [ "from herschelhelp_internal import starmask\n", "from pymoc import MOC\n", "\n", "import time\n", "import os" ] }, { "cell_type": "code", "execution_count": 3, <<<<<<< HEAD "metadata": { "collapsed": true }, ======= "metadata": {}, >>>>>>> upstream/master "outputs": [], "source": [ "OUT_DIR = os.environ.get('OUT_DIR', \"./data\")\n", "SUFFIX = os.environ.get('SUFFIX', time.strftime(\"_%Y%m%d\"))\n", "SUFFIX = SUFFIX #+ '_WARNING-MADE-WITH-Lockman-SWIRE-PARAMS'\n", "\n", "try:\n", " os.makedirs(OUT_DIR)\n", "except FileExistsError:\n", " pass\n", "\n", "field = 'SPIRE-NEP'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First we list all the fields including the ra and dec of the first star in the field. We do this because, due to a peculiarity of the pyregion code, we must supply an image header to produce mocs." ] }, { "cell_type": "code", "execution_count": 4, <<<<<<< HEAD "metadata": { "collapsed": true }, ======= "metadata": {}, >>>>>>> upstream/master "outputs": [], "source": [ "\n", "\n", "#Field names plus ra dec of first circle\n", "fields= {\n", "# Field RA DEC\n", "'AKARI-NEP': [274.654402036, 65.7962520276 ],\n", "'AKARI-SEP': [72.2316923316, -54.380443672 ],\n", "'Bootes': [216.431700722, 32.401081899 ],\n", "'CDFS-SWIRE': [51.0227099923, -29.8185285737 ],\n", "'COSMOS': [149.295925951, 1.08212668291 ],\n", "'EGS': [217.276981956, 53.6441519854 ],\n", "'ELAIS-N1': [247.096600963, 55.1757687739 ],\n", "'ELAIS-N2': [248.424493154, 39.1274077489 ],\n", "'ELAIS-S1': [7.10625839472, -43.8632559768 ],\n", "'GAMA-09': [129.076050945, -2.23171513025 ],\n", "'GAMA-12': [172.84437099, -0.482115877707],\n", "'GAMA-15': [211.756497623, -2.28573712848 ],\n", "'HDF-N': [190.259734752, 62.205265532 ],\n", "'Herschel-Stripe-82': [353.751913281, -7.10891111165 ],\n", "'Lockman-SWIRE': [161.942787703, 59.0563805825 ],\n", "'NGP': [192.899559129, 22.0990890388 ],\n", "'SA13': [197.895801254, 42.4400105492 ],\n", "'SGP': [334.297748942, -34.5037863499 ],\n", "'SPIRE-NEP': [266.334305546, 68.7904496043 ],\n", "'SSDF': [341.577544902, -59.1868365369 ],\n", "'xFLS': [261.387059958, 58.0184602211 ],\n", "'XMM-13hr': [203.318355937, 37.4745777866 ],\n", "'XMM-LSS': [32.9413834032, -6.02293494708 ]}\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then we generate a region file to define all the holes. At present this is very crude and simply puts a 10 arcsec hole over every star brighter than 16 Mag." ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "There are 3554 GAIA stars in SPIRE-NEP\n", "Starmask written to data/10_arcsec_holes_SPIRE-NEP.reg\n" ] } ], "source": [ "starmask.create_holes('../../dmu0/dmu0_GAIA/data/GAIA_{}.fits'.format(field),\n", " 'data/10_arcsec_holes_{}.reg'.format(field),\n", " '../../dmu2/dmu2_field_coverages/{}_MOC.fits'.format(field))\n", " \n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Then we convert the region files to MOC format. We recomend against using the MOC since, even at this high order, it doesn't capture shape that well. This will become increasingly significant if we have smaller or more detailed shapes in the future." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "\n", "WCSAXES = 2 / Number of coordinate axes\n", "CRPIX1 = [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", " 0.5 / Pixel coordinate of reference point\n", "CRPIX2 = 0.5 / Pi [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "xel coordinate of reference point\n", "CDELT1 = 0.675 / [deg] Coordin [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "ate increment at reference point\n", "CDELT2 = 0.675 / [deg] Coordina [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "te increment at reference point\n", "RADECSYSa= 'ICRS ' / International [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "Celestial Ref. System\n", "CUNIT1 = 'deg ' / Units of coordinate [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "increment and value\n", "CUNIT2 = 'deg ' / Units of coordinate in [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "crement and value\n", "CTYPE1 = 'RA---TAN' / \n", "CTYPE2 = 'DEC--TAN' [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", " / \n", "CRVAL1 = 266.334305546 / [deg] Coordinate value at refer [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "ence point\n", "CRVAL2 = 68.7904496043 / [deg] Coordinate value at [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "reference point\n", "LONPOLE = 0.0 / [deg] Native longitude of celes [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "tial pole\n", "LATPOLE = 90.0 / [deg] Native latitude of celestial pole\n", " [astropy.io.fits.card]\n", "WARNING: FITSFixedWarning: 0.5 / Pixel coordinate of reference point\n", "a floating-point value was expected. [astropy.wcs.wcs]\n", "WARNING: FITSFixedWarning: / \n", "the RADECSYS keyword is deprecated, use RADESYSa. [astropy.wcs.wcs]\n" ] } ], "source": [ "ORDER=16\n", "starmask.reg2moc('data/10_arcsec_holes_{}.reg'.format(field),\n", " '../../dmu2/dmu2_field_coverages/{}_MOC.fits'.format(field),\n", " 'data/10_arcsec_holes_{}_O'.format(field) + str(ORDER) + '_MOC.fits',\n", " ra_typ=fields[field][0],\n", " dec_typ=fields[field][1],\n", " order=ORDER)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## II Produce magnitude varying holes\n", "Then we produce a varying hole parameterised by Seb's code. We define an annulus with a 1 arcsec circle at the centre and an outer radius r_50 (the radius at which the artefact density goes over 0.5 x background density) = 10^(A + B x mag)." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "# Run with parameters from IDL code. The IDL output files are in ./data/\n", "\n", "per_catalogue_params = [\n", "# Field Band A B magnitude limit\n", "# [field, 'megacam_r', 2.30374, -0.0962746, 18], # Using 18 as faint limit.\n", " [field, 'gpc1_r', 2.46029, -0.111433, 16], # Using 18 as faint limit. \n", "# [field, 'irac1', 2.56501, -0.100879, 18], # Using 18 as faint limit.\n", "# [field, 'ukidss_k', 3.67944, -0.173850, 18], # Using 18 as faint limit.\n", "# [field, 'wfc_r', 3.43951, -0.173789, 18] # Using 18 as faint limit.\n", "] \n", "\n", "#We previously took a moc of the survey to only make holes on that area, which \n", "#was a mistake as it led to missing holes for the XID+ run\n" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "There are 3554 GAIA stars in SPIRE-NEP\n", "Starmask written to data/holes_SPIRE-NEP_megacam_r_20190201_WARNING-MADE-WITH-Lockman-SWIRE-PARAMS.reg\n", "There are 3554 GAIA stars in SPIRE-NEP\n", "Starmask written to data/holes_SPIRE-NEP_gpc1_r_20190201_WARNING-MADE-WITH-Lockman-SWIRE-PARAMS.reg\n", "There are 3554 GAIA stars in SPIRE-NEP\n", "Starmask written to data/holes_SPIRE-NEP_irac1_20190201_WARNING-MADE-WITH-Lockman-SWIRE-PARAMS.reg\n", "There are 3554 GAIA stars in SPIRE-NEP\n", "Starmask written to data/holes_SPIRE-NEP_ukidss_k_20190201_WARNING-MADE-WITH-Lockman-SWIRE-PARAMS.reg\n", "There are 3554 GAIA stars in SPIRE-NEP\n", "Starmask written to data/holes_SPIRE-NEP_wfc_r_20190201_WARNING-MADE-WITH-Lockman-SWIRE-PARAMS.reg\n" ] } ], "source": [ "for pristine_cat in per_catalogue_params:\n", " starmask.create_holes('../../dmu0/dmu0_GAIA/data/GAIA_' + pristine_cat[0] + '.fits', #GAIA catalogue\n", " 'data/holes_' + pristine_cat[0] + '_' + pristine_cat[1] + SUFFIX + '.reg', #output file\n", " '../../dmu2/dmu2_field_coverages/' + field + '_MOC.fits', #moc of region in which to produce holes\n", " AB = [pristine_cat[2],pristine_cat[3]], #radius as f of mag params\n", " mag_lim = pristine_cat[4]) #upper magnitude limit" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Again we convert the region files to MOC format." ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "\n", "WCSAXES = 2 / Number of coordinate axes\n", "CRPIX1 = [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", " 0.5 / Pixel coordinate of reference point\n", "CRPIX2 = 0.5 / Pi [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "xel coordinate of reference point\n", "CDELT1 = 0.675 / [deg] Coordin [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "ate increment at reference point\n", "CDELT2 = 0.675 / [deg] Coordina [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "te increment at reference point\n", "RADECSYSa= 'ICRS ' / International [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "Celestial Ref. System\n", "CUNIT1 = 'deg ' / Units of coordinate [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "increment and value\n", "CUNIT2 = 'deg ' / Units of coordinate in [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "crement and value\n", "CTYPE1 = 'RA---TAN' / \n", "CTYPE2 = 'DEC--TAN' [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", " / \n", "CRVAL1 = 266.334305546 / [deg] Coordinate value at refer [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "ence point\n", "CRVAL2 = 68.7904496043 / [deg] Coordinate value at [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "reference point\n", "LONPOLE = 0.0 / [deg] Native longitude of celes [astropy.io.fits.card]\n", "WARNING: The following header keyword is invalid or follows an unrecognized non-standard convention:\n", "tial pole\n", "LATPOLE = 90.0 / [deg] Native latitude of celestial pole\n", " [astropy.io.fits.card]\n", "WARNING: FITSFixedWarning: 0.5 / Pixel coordinate of reference point\n", "a floating-point value was expected. [astropy.wcs.wcs]\n", "WARNING: FITSFixedWarning: / \n", "the RADECSYS keyword is deprecated, use RADESYSa. [astropy.wcs.wcs]\n" ] } ], "source": [ "ORDER=16\n", "for pristine_cat in per_catalogue_params:\n", " starmask.reg2moc('data/holes_' + field + '_' + pristine_cat[1] + SUFFIX + '.reg',\n", " '../../dmu2/dmu2_field_coverages/' + field + '_MOC.fits',\n", " 'data/holes_' + field + '_' + pristine_cat[1] + '_O' + str(ORDER) + SUFFIX + '.fits',\n", " ra_typ=fields[field][0],\n", " dec_typ=fields[field][1],\n", " order=ORDER)" ] } ], "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", <<<<<<< HEAD "version": "3.6.6" ======= "version": "3.6.8" >>>>>>> upstream/master } }, "nbformat": 4, "nbformat_minor": 2 }