{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# XMM-LSS 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": null, "metadata": { "collapsed": true }, "outputs": [], "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": null, "metadata": { "collapsed": true }, "outputs": [], "source": [ "from herschelhelp_internal import starmask\n", "from pymoc import MOC\n", "\n", "import time\n", "import os" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "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 = 'XMM-LSS'" ] }, { "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": null, "metadata": { "collapsed": true }, "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": null, "metadata": { "collapsed": true, "scrolled": false }, "outputs": [], "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": null, "metadata": { "collapsed": true }, "outputs": [], "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": null, "metadata": { "collapsed": true }, "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", " \n", " [field, 'irac1', 2.54721, -0.0988295, 16], # Using 18 as faint limit.50% cross linear params \n", "\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": null, "metadata": { "collapsed": true }, "outputs": [], "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": null, "metadata": { "collapsed": true }, "outputs": [], "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 + '_MOC.fits',\n", " ra_typ=fields[field][0],\n", " dec_typ=fields[field][1],\n", " order=ORDER)" ] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:herschelhelp_internal]", "language": "python", "name": "conda-env-herschelhelp_internal-py" }, "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 }