Guest User

Untitled

a guest
Jul 25th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "metadata": {
  5. "trusted": true
  6. },
  7. "cell_type": "code",
  8. "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)",
  9. "execution_count": null,
  10. "outputs": []
  11. },
  12. {
  13. "metadata": {
  14. "trusted": true
  15. },
  16. "cell_type": "code",
  17. "source": "data_path = 'orphan-data'\nif not path.exists(data_path):\n os.makedirs(data_path)",
  18. "execution_count": null,
  19. "outputs": []
  20. },
  21. {
  22. "metadata": {
  23. "trusted": true
  24. },
  25. "cell_type": "code",
  26. "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'''",
  27. "execution_count": null,
  28. "outputs": []
  29. },
  30. {
  31. "metadata": {
  32. "trusted": true
  33. },
  34. "cell_type": "code",
  35. "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)",
  36. "execution_count": null,
  37. "outputs": []
  38. },
  39. {
  40. "metadata": {
  41. "trusted": true
  42. },
  43. "cell_type": "code",
  44. "source": "",
  45. "execution_count": null,
  46. "outputs": []
  47. }
  48. ],
  49. "metadata": {
  50. "kernelspec": {
  51. "name": "python3",
  52. "display_name": "Python [default]",
  53. "language": "python"
  54. },
  55. "language_info": {
  56. "name": "python",
  57. "version": "3.6.4",
  58. "mimetype": "text/x-python",
  59. "codemirror_mode": {
  60. "name": "ipython",
  61. "version": 3
  62. },
  63. "pygments_lexer": "ipython3",
  64. "nbconvert_exporter": "python",
  65. "file_extension": ".py"
  66. },
  67. "gist": {
  68. "id": "",
  69. "data": {
  70. "description": "Orphan-query-demo.ipynb",
  71. "public": true
  72. }
  73. }
  74. },
  75. "nbformat": 4,
  76. "nbformat_minor": 2
  77. }
Add Comment
Please, Sign In to add comment