Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "metadata": {
- "trusted": true
- },
- "cell_type": "code",
- "source": "import os\nfrom os import path\nimport glob\nimport warnings\n\n# Third-party\nimport astropy.coordinates as coord\nfrom astropy.table import Table, vstack\nfrom astropy.io import fits\nimport astropy.units as u\nimport matplotlib as mpl\nimport matplotlib.pyplot as plt\nimport numpy as np\n%matplotlib inline\n\nimport gala.coordinates as gc\nimport gala.dynamics as gd\nfrom pyia import GaiaData\nfrom sfd import reddening\nfrom astroquery.gaia import Gaia\n\n# Enter your Gaia archive info here:\n# Gaia.login(user=username, password=password)",
- "execution_count": null,
- "outputs": []
- },
- {
- "metadata": {
- "trusted": true
- },
- "cell_type": "code",
- "source": "data_path = 'orphan-data'\nif not path.exists(data_path):\n os.makedirs(data_path)",
- "execution_count": null,
- "outputs": []
- },
- {
- "metadata": {
- "trusted": true
- },
- "cell_type": "code",
- "source": "q_base = '''SELECT *\nFROM gaiadr2.gaia_source\nWHERE parallax < 1 AND bp_rp < 0.6 AND \n CONTAINS(POINT('ICRS', ra, dec), \n POLYGON('ICRS', \n {0[0].ra.degree}, {0[0].dec.degree}, \n {0[1].ra.degree}, {0[1].dec.degree}, \n {0[2].ra.degree}, {0[2].dec.degree}, \n {0[3].ra.degree}, {0[3].dec.degree})) = 1'''",
- "execution_count": null,
- "outputs": []
- },
- {
- "metadata": {
- "trusted": true
- },
- "cell_type": "code",
- "source": "queries = []\njobs = []\nfor l in np.arange(-60, 60, 10):\n print(l)\n \n fn = path.join(data_path, 'orp_{0:.0f}.fits'.format(l))\n if path.exists(fn):\n print('{0} exists...skipping'.format(fn))\n continue\n \n corners = gc.Orphan(phi1=[l, l, l+10, l+10]*u.deg, \n phi2=[-5, 10, 10, -5]*u.deg)\n corners_icrs = corners.transform_to(coord.ICRS)\n q = q_base.format(corners_icrs)\n \n print(q)\n \n # remove the line below here when you're ready to execute the queries!\n break\n \n with warnings.catch_warnings():\n warnings.simplefilter('ignore')\n job = Gaia.launch_job_async(q, name='Orphan-{0}'.format(l), \n background=True)\n jobs.append(job)",
- "execution_count": null,
- "outputs": []
- },
- {
- "metadata": {
- "trusted": true
- },
- "cell_type": "code",
- "source": "",
- "execution_count": null,
- "outputs": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "name": "python3",
- "display_name": "Python [default]",
- "language": "python"
- },
- "language_info": {
- "name": "python",
- "version": "3.6.4",
- "mimetype": "text/x-python",
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "pygments_lexer": "ipython3",
- "nbconvert_exporter": "python",
- "file_extension": ".py"
- },
- "gist": {
- "id": "",
- "data": {
- "description": "Orphan-query-demo.ipynb",
- "public": true
- }
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Add Comment
Please, Sign In to add comment