Skip to content

Instantly share code, notes, and snippets.

@jdnc
Created June 10, 2013 18:13
Show Gist options
  • Save jdnc/5750959 to your computer and use it in GitHub Desktop.
Save jdnc/5750959 to your computer and use it in GitHub Desktop.
ipython notebook demonstrating some functions of irsa_dust v0
{
"metadata": {
"name": "irsa_dust_3"
},
"name": "irsa_dust_3",
"nbformat": 2,
"worksheets": [
{
"cells": [
{
"cell_type": "markdown",
"source": "Trying the following functions : \n1. get_images \n2. get_images_async \n3. get_image_list \n4. get_ext_table \n5. get_ext_table_async \n6. get_query_table (requires an async counterpart?)"
},
{
"cell_type": "code",
"collapsed": false,
"input": "from astroquery import irsa_dust as id",
"language": "python",
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "\u001b[0;33mWARNING\u001b[0m: ConfigurationDefaultMissingWarning: Requested default configuration file /home/rk7/astroquery/astroquery/astroquery.cfg is not a file. Cannot install default profile. If you are importing from source, this is expected. [astroquery]"
}
],
"prompt_number": 1
},
{
"cell_type": "markdown",
"source": "get_images"
},
{
"cell_type": "code",
"collapsed": false,
"input": "id.IrsaDust().get_images('m81')",
"language": "python",
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "\u001b[0;39mDownloading http://irsa.ipac.caltech.edu//workspace/TMP_EWYXVj_30302/DUST/m81.v0001/p414Dust.fits\u001b[0m\n\n|\u001b[0;34m\u001b[0m\u001b[0;32m>\u001b[0m----------------------------------------| 0.0 /331k ( 0.00%)"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m========\u001b[0m\u001b[0;32m>\u001b[0m--------------------------------| 65k/331k ( 19.79%) ETA 05s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m================\u001b[0m\u001b[0;32m>\u001b[0m------------------------| 131k/331k ( 39.57%) ETA 02s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m========================\u001b[0m\u001b[0;32m>\u001b[0m----------------| 196k/331k ( 59.36%) ETA 01s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m================================\u001b[0m\u001b[0;32m>\u001b[0m--------| 262k/331k ( 79.15%) ETA 00s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m========================================\u001b[0m\u001b[0;32m>\u001b[0m| 327k/331k ( 98.94%) ETA 00s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m=========================================\u001b[0m| 331k/331k (100.00%) 05s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m=========================================\u001b[0m| 331k/331k (100.00%) 05s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": ""
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\u001b[0;39mDownloading http://irsa.ipac.caltech.edu//workspace/TMP_EWYXVj_30302/DUST/m81.v0001/p414i100.fits\u001b[0m\n\n|\u001b[0;34m\u001b[0m\u001b[0;32m>\u001b[0m----------------------------------------| 0.0 /331k ( 0.00%)"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m========\u001b[0m\u001b[0;32m>\u001b[0m--------------------------------| 65k/331k ( 19.79%) ETA 06s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m================\u001b[0m\u001b[0;32m>\u001b[0m------------------------| 131k/331k ( 39.57%) ETA 03s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m========================\u001b[0m\u001b[0;32m>\u001b[0m----------------| 196k/331k ( 59.36%) ETA 01s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m================================\u001b[0m\u001b[0;32m>\u001b[0m--------| 262k/331k ( 79.15%) ETA 00s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m========================================\u001b[0m\u001b[0;32m>\u001b[0m| 327k/331k ( 98.94%) ETA 00s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m=========================================\u001b[0m| 331k/331k (100.00%) 03s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m=========================================\u001b[0m| 331k/331k (100.00%) 03s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": ""
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\u001b[0;39mDownloading http://irsa.ipac.caltech.edu//workspace/TMP_EWYXVj_30302/DUST/m81.v0001/p414temp.fits\u001b[0m\n\n|\u001b[0;34m\u001b[0m\u001b[0;32m>\u001b[0m----------------------------------------| 0.0 /331k ( 0.00%)"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m========\u001b[0m\u001b[0;32m>\u001b[0m--------------------------------| 65k/331k ( 19.79%) ETA 06s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m================\u001b[0m\u001b[0;32m>\u001b[0m------------------------| 131k/331k ( 39.57%) ETA 03s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m========================\u001b[0m\u001b[0;32m>\u001b[0m----------------| 196k/331k ( 59.36%) ETA 01s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m================================\u001b[0m\u001b[0;32m>\u001b[0m--------| 262k/331k ( 79.15%) ETA 00s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m========================================\u001b[0m\u001b[0;32m>\u001b[0m| 327k/331k ( 98.94%) ETA 00s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m=========================================\u001b[0m| 331k/331k (100.00%) 06s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m=========================================\u001b[0m| 331k/331k (100.00%) 06s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": ""
},
{
"output_type": "pyout",
"prompt_number": 2,
"text": "[[<astropy.io.fits.hdu.image.PrimaryHDU at 0x3bec0d0>],\n [<astropy.io.fits.hdu.image.PrimaryHDU at 0x3beca50>],\n [<astropy.io.fits.hdu.image.PrimaryHDU at 0x3be9250>]]"
}
],
"prompt_number": 2
},
{
"cell_type": "markdown",
"source": " get_images_async"
},
{
"cell_type": "code",
"collapsed": false,
"input": "id.IrsaDust().get_images_async('m81')",
"language": "python",
"outputs": [
{
"output_type": "pyout",
"prompt_number": 3,
"text": "[<contextlib.GeneratorContextManager at 0x3c7d650>,\n <contextlib.GeneratorContextManager at 0x3c7d610>,\n <contextlib.GeneratorContextManager at 0x3c7d5d0>]"
}
],
"prompt_number": 3
},
{
"cell_type": "markdown",
"source": "get_image_list"
},
{
"cell_type": "code",
"collapsed": false,
"input": "id.IrsaDust().get_image_list('m81')",
"language": "python",
"outputs": [
{
"output_type": "pyout",
"prompt_number": 4,
"text": "['http://irsa.ipac.caltech.edu//workspace/TMP_t4f0T5_31534/DUST/m81.v0001/p414Dust.fits',\n 'http://irsa.ipac.caltech.edu//workspace/TMP_t4f0T5_31534/DUST/m81.v0001/p414i100.fits',\n 'http://irsa.ipac.caltech.edu//workspace/TMP_t4f0T5_31534/DUST/m81.v0001/p414temp.fits']"
}
],
"prompt_number": 4
},
{
"cell_type": "markdown",
"source": "get_ext_table"
},
{
"cell_type": "code",
"collapsed": false,
"input": "id.IrsaDust().get_ext_table('m81')",
"language": "python",
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
"text": "\u001b[0;39mDownloading http://irsa.ipac.caltech.edu//workspace/TMP_MkMsak_4452/DUST/m81.v0001/extinction.tbl\u001b[0m\n\n|\u001b[0;34m\u001b[0m\u001b[0;32m>\u001b[0m----------------------------------------| 0.0 /1.2k ( 0.00%)"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m=========================================\u001b[0m| 1.2k/1.2k (100.00%) 00s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": "\n|\u001b[0;34m=========================================\u001b[0m| 1.2k/1.2k (100.00%) 00s"
},
{
"output_type": "stream",
"stream": "stdout",
"text": ""
},
{
"html": "<table><tr><th>Filter_name</th><th>LamEff(A)</th><th>A/Av</th><th>A/E(B-V)</th><th>A(mag)</th></tr><tr><td>CTIO U</td><td>0.3683</td><td>1.521</td><td>4.968</td><td>0.398</td></tr><tr><td>CTIO B</td><td>0.4393</td><td>1.324</td><td>4.325</td><td>0.347</td></tr><tr><td>DSS-II g</td><td>0.4814</td><td>1.197</td><td>3.907</td><td>0.313</td></tr><tr><td>CTIO V</td><td>0.5519</td><td>0.992</td><td>3.24</td><td>0.26</td></tr><tr><td>DSS-II r</td><td>0.6571</td><td>0.811</td><td>2.649</td><td>0.212</td></tr><tr><td>CTIO R</td><td>0.6602</td><td>0.807</td><td>2.634</td><td>0.211</td></tr><tr><td>CTIO I</td><td>0.8046</td><td>0.601</td><td>1.962</td><td>0.157</td></tr><tr><td>DSS-II i</td><td>0.8183</td><td>0.58</td><td>1.893</td><td>0.152</td></tr><tr><td>UKIRT J</td><td>1.266</td><td>0.276</td><td>0.902</td><td>0.072</td></tr><tr><td>UKIRT H</td><td>1.6732</td><td>0.176</td><td>0.576</td><td>0.046</td></tr><tr><td>UKIRT K</td><td>2.2152</td><td>0.112</td><td>0.367</td><td>0.029</td></tr><tr><td>IRAC-1</td><td>3.6</td><td>0.06</td><td>0.197</td><td>0.016</td></tr><tr><td>IRAC-2</td><td>4.5</td><td>0.055</td><td>0.18</td><td>0.014</td></tr><tr><td>IRAC-3</td><td>5.8</td><td>0.05</td><td>0.164</td><td>0.013</td></tr><tr><td>IRAC-4</td><td>8.0</td><td>0.045</td><td>0.148</td><td>0.012</td></tr></table>",
"output_type": "pyout",
"prompt_number": 5,
"text": "<Table rows=15 names=('Filter_name','LamEff(A)','A/Av','A/E(B-V)','A(mag)')>\narray([('CTIO U', 0.3683, 1.521, 4.968, 0.398),\n ('CTIO B', 0.4393, 1.324, 4.325, 0.347),\n ('DSS-II g', 0.4814, 1.197, 3.907, 0.313),\n ('CTIO V', 0.5519, 0.992, 3.24, 0.26),\n ('DSS-II r', 0.6571, 0.811, 2.649, 0.212),\n ('CTIO R', 0.6602, 0.807, 2.634, 0.211),\n ('CTIO I', 0.8046, 0.601, 1.962, 0.157),\n ('DSS-II i', 0.8183, 0.58, 1.893, 0.152),\n ('UKIRT J', 1.266, 0.276, 0.902, 0.072),\n ('UKIRT H', 1.6732, 0.176, 0.576, 0.046),\n ('UKIRT K', 2.2152, 0.112, 0.367, 0.029),\n ('IRAC-1', 3.6, 0.06, 0.197, 0.016),\n ('IRAC-2', 4.5, 0.055, 0.18, 0.014),\n ('IRAC-3', 5.8, 0.05, 0.164, 0.013),\n ('IRAC-4', 8.0, 0.045, 0.148, 0.012)], \n dtype=[('Filter_name', '|S8'), ('LamEff(A)', '<f8'), ('A/Av', '<f8'), ('A/E(B-V)', '<f8'), ('A(mag)', '<f8')])"
}
],
"prompt_number": 5
},
{
"cell_type": "markdown",
"source": "get_ext_table_async"
},
{
"cell_type": "code",
"collapsed": false,
"input": "id.IrsaDust().get_ext_table_async('m81')",
"language": "python",
"outputs": [
{
"output_type": "pyout",
"prompt_number": 6,
"text": "<contextlib.GeneratorContextManager at 0x3c7f250>"
}
],
"prompt_number": 6
},
{
"cell_type": "code",
"collapsed": false,
"input": "id.IrsaDust().get_query_table('m81')",
"language": "python",
"outputs": [
{
"html": "<table><tr><th>RA</th><th>Dec</th><th>coord sys</th><th>regSize</th><th>...</th><th>temp mean</th><th>temp std</th><th>temp max</th><th>temp min</th></tr><tr><td>148.88822</td><td>69.06529</td><td>equ J2000</td><td>5.0</td><td>...</td><td>17.157</td><td>0.0069</td><td>17.1796</td><td>17.1522</td></tr></table>",
"output_type": "pyout",
"prompt_number": 7,
"text": "<Table rows=1 names=('RA','Dec','coord sys','regSize','ext desc','ext image','ext table','ext ref','ext ref RA','ext ref Dec','ext ref coord sys','ext mean','ext std','ext max','ext min','em desc','em image','em ref','em ref RA','em ref Dec','em ref coord sys','em mean','em std','em max','em min','temp desc','temp image','temp ref','temp ref RA','temp ref Dec','temp ref coord sys','temp mean','temp std','temp max','temp min')>\narray([ (148.88822, 69.06529, 'equ J2000', 5.0, 'E(B-V) Reddening', 'http://irsa.ipac.caltech.edu//workspace/TMP_13vBJX_8073/DUST/m81.v0001/p414Dust.fits', 'http://irsa.ipac.caltech.edu//workspace/TMP_13vBJX_8073/DUST/m81.v0001/extinction.tbl', 0.0802, 148.88822, 69.06529, 'equ J2000', 0.0801, 0.0001, 0.0803, 0.0798, '100 Micron Emission', 'http://irsa.ipac.caltech.edu//workspace/TMP_13vBJX_8073/DUST/m81.v0001/p414i100.fits', 2.723, 148.88822, 69.06529, 'equ J2000', 2.7229, 0.0039, 2.7302, 2.7157, 'Dust Temperature', 'http://irsa.ipac.caltech.edu//workspace/TMP_13vBJX_8073/DUST/m81.v0001/p414temp.fits', 17.1522, 148.88822, 69.06529, 'equ J2000', 17.157, 0.0069, 17.1796, 17.1522)], \n dtype=[('RA', '<f8'), ('Dec', '<f8'), ('coord sys', '|S25'), ('regSize', '<f8'), ('ext desc', '|S100'), ('ext image', '|S255'), ('ext table', '|S255'), ('ext ref', '<f8'), ('ext ref RA', '<f8'), ('ext ref Dec', '<f8'), ('ext ref coord sys', '|S25'), ('ext mean', '<f8'), ('ext std', '<f8'), ('ext max', '<f8'), ('ext min', '<f8'), ('em desc', '|S100'), ('em image', '|S255'), ('em ref', '<f8'), ('em ref RA', '<f8'), ('em ref Dec', '<f8'), ('em ref coord sys', '|S25'), ('em mean', '<f8'), ('em std', '<f8'), ('em max', '<f8'), ('em min', '<f8'), ('temp desc', '|S100'), ('temp image', '|S255'), ('temp ref', '<f8'), ('temp ref RA', '<f8'), ('temp ref Dec', '<f8'), ('temp ref coord sys', '|S25'), ('temp mean', '<f8'), ('temp std', '<f8'), ('temp max', '<f8'), ('temp min', '<f8')])"
}
],
"prompt_number": 7
},
{
"cell_type": "markdown",
"source": "An example with get_query_payload = True"
},
{
"cell_type": "code",
"collapsed": false,
"input": "id.IrsaDust().get_images('m81', get_query_payload=True)",
"language": "python",
"outputs": [
{
"output_type": "pyout",
"prompt_number": 8,
"text": "{'locstr': 'm81'}"
}
],
"prompt_number": 8
},
{
"cell_type": "markdown",
"source": "TODO: \nThis only covers a very limited number of cases.\n1. Modify the functions as required \n2. Write a test suite for detailed coverage \n3. for me id.IrsaDust.get_images and similar are not working (i.e. as classmethods). Need to look at that \n4. Documentation very sparse. Will do it thoroughly once the implementation is finalized\n5. Need to implement the case when the query fails\n6. Need to implement the case when the query parsing fails\n7 ..."
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment