{"id":865,"date":"2013-05-04T12:00:17","date_gmt":"2013-05-04T19:00:17","guid":{"rendered":"http:\/\/bellm.org\/blog\/?p=865"},"modified":"2013-05-05T22:43:13","modified_gmt":"2013-05-06T05:43:13","slug":"idl-magics-for-the-ipython-notebook","status":"publish","type":"post","link":"http:\/\/bellm.org\/blog\/2013\/05\/04\/idl-magics-for-the-ipython-notebook\/","title":{"rendered":"IDL Magics for the IPython Notebook"},"content":{"rendered":"<p>The <a href=\"http:\/\/ipython.org\/ipython-doc\/stable\/interactive\/htmlnotebook.html\">IPython Notebook<\/a> combines code, documentation, and computational results in one package that&#8217;s <a href=\"http:\/\/nbviewer.ipython.org\/\">easy to share<\/a>.? It&#8217;s proving a great way to teach, as notebooks are easy for the instructor to write and for students to modify.? Notebooks also provide seamless integration with <a href=\"https:\/\/github.com\/ipython\/ipython\/wiki\/Extensions-Index\">other programming environments<\/a> through <a href=\"http:\/\/ipython.org\/ipython-doc\/stable\/config\/extensions\/index.html\">extensions<\/a> providing &#8220;<a href=\"http:\/\/ipython.org\/ipython-doc\/stable\/interactive\/tutorial.html#magic-functions\">magic functions<\/a>&#8220;: short code prefixes beginning with <code>%<\/code> or <code>%%<\/code> that call other interpreters, like R or Octave.<\/p>\n<p>Since many astronomers who might want to transition to Python already know <a href=\"http:\/\/www.exelisvis.com\/ProductsServices\/IDL.aspx\">IDL<\/a>, I wanted to provide an <code>%idl<\/code> magic function for IPython so they could easily call existing code.? The difficult interfacing between IDL and Python was already done by <a href=\"http:\/\/www.anthonysmith.me.uk\/\">Anthony Smith<\/a>&#8216;s <a href=\"https:\/\/github.com\/anthonyjsmith\/pIDLy\">pIDLy<\/a> package.? (As a bonus, it supports the free <a href=\"http:\/\/gnudatalanguage.sourceforge.net\/\">GDL<\/a> interpreter as well.)? I adapted the Octave magic code to provide <code>%idl<\/code> magic functions with consistent syntax.? You can find the code on github as <a href=\"https:\/\/github.com\/ebellm\/ipython-idlmagic\">ipython-idlmagic<\/a>.<\/p>\n<p>The demonstration notebook below is <a href=\"https:\/\/raw.github.com\/ebellm\/ipython-idlmagic\/master\/demo_idlmagic.ipynb\">available on github<\/a> as well, or you can <a href=\"http:\/\/nbviewer.ipython.org\/urls\/raw.github.com\/ebellm\/ipython-idlmagic\/master\/demo_idlmagic.ipynb\">view it with nbviewer<\/a>.<\/p>\n<div class=\"ipynb\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h2 class=\"ipynb\">Installation<\/h2>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>To begin, we install <a href=\"https:\/\/github.com\/anthonyjsmith\/pIDLy\">pIDLy<\/a>:<\/p>\n<pre class=\"ipynb\"><code>pip install pidly\r\n<\/code><\/pre>\n<p>Then we install idlmagic:<\/p>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[?]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"o\">%<\/span><span class=\"k\">install_ext<\/span> <span class=\"n\">https<\/span><span class=\"p\">:<\/span><span class=\"o\">\/\/<\/span><span class=\"n\">raw<\/span><span class=\"o\">.<\/span><span class=\"n\">github<\/span><span class=\"o\">.<\/span><span class=\"n\">com<\/span><span class=\"o\">\/<\/span><span class=\"n\">ebellm<\/span><span class=\"o\">\/<\/span><span class=\"n\">ipython<\/span><span class=\"o\">-<\/span><span class=\"n\">idlmagic<\/span><span class=\"o\">\/<\/span><span class=\"n\">master<\/span><span class=\"o\">\/<\/span><span class=\"n\">idlmagic<\/span><span class=\"o\">.<\/span><span class=\"n\">py<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h2 class=\"ipynb\">Usage<\/h2>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>When starting a new notebook, we load the magic:<\/p>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[1]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"o\">%<\/span><span class=\"k\">load_ext<\/span> <span class=\"n\">idlmagic<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"vbox output_wrapper\">\n<div class=\"output vbox\">\n<div class=\"hbox output_area\">\n<div class=\"prompt output_prompt\"><\/div>\n<div class=\"output_subarea output_stream output_stdout\">\n<pre class=\"ipynb\">IDL not found, using GDL<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>(I am using <a href=\"http:\/\/gnudatalanguage.sourceforge.net\/\">GDL<\/a> rather than IDL on this computer. <code>idlmagic<\/code> will first look for the <code>idl<\/code> interpreter on the search path and and fall back to <code>gdl<\/code> if needed.)<\/p>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h3 class=\"ipynb\">Line magics<\/h3>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>The <code>%idl<\/code> magic enables one-line execution of IDL commands in the IPython interpreter or notebook:<\/p>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[2]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"o\">%<\/span><span class=\"k\">idl<\/span> <span class=\"k\">print<\/span><span class=\"p\">,<\/span> <span class=\"n\">findgen<\/span><span class=\"p\">(<\/span><span class=\"mi\">5<\/span><span class=\"p\">)<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"vbox output_wrapper\">\n<div class=\"output vbox\">\n<div class=\"hbox output_area\">\n<div class=\"prompt output_prompt\"><\/div>\n<div class=\"output_subarea output_display_data\">\n<pre class=\"ipynb\">      0.00000      1.00000      2.00000      3.00000      4.00000<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>(Note that the <code>%idl<\/code> line magic fails with <code>TypeError: coercing to Unicode: need string or buffer, dict found<\/code> in current release versions of IPython (0.13.2 and below) due to a <a href=\"http:\/\/stackoverflow.com\/questions\/14574434\/unicode-error-with-ipython-rmagic-r-seems-to-work-but-not-r-fully\">known bug<\/a>; the github development version of IPython works as expected.)<\/p>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h3 class=\"ipynb\">Cell magics<\/h3>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>Multi-line input can be entered with the <code>%%idl<\/code> cell magic:<\/p>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[3]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"o\">%%<\/span><span class=\"k\">idl<\/span>\r\n<span class=\"n\">x<\/span> <span class=\"o\">=<\/span> <span class=\"n\">findgen<\/span><span class=\"p\">(<\/span><span class=\"mi\">5<\/span><span class=\"p\">)<\/span>\r\n<span class=\"n\">y<\/span> <span class=\"o\">=<\/span> <span class=\"n\">x<\/span><span class=\"o\">^<\/span><span class=\"mf\">2.<\/span>\r\n<span class=\"p\">;<\/span> <span class=\"n\">comments<\/span> <span class=\"n\">are<\/span> <span class=\"n\">supported<\/span>\r\n<span class=\"k\">print<\/span><span class=\"p\">,<\/span> <span class=\"err\">$<\/span> <span class=\"p\">;<\/span> <span class=\"k\">as<\/span> <span class=\"n\">are<\/span> <span class=\"n\">line<\/span> <span class=\"n\">continuations<\/span>\r\n<span class=\"n\">mean<\/span><span class=\"p\">(<\/span><span class=\"n\">y<\/span><span class=\"p\">)<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"vbox output_wrapper\">\n<div class=\"output vbox\">\n<div class=\"hbox output_area\">\n<div class=\"prompt output_prompt\"><\/div>\n<div class=\"output_subarea output_display_data\">\n<pre class=\"ipynb\">% Compiled module: MEAN.\r\n      6.00000<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h3 class=\"ipynb\">Passing variables between Python and IDL<\/h3>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>The mechanisms for passing variables to and from IDL are based on those in the built-in <code>%R<\/code> and <code>%octave<\/code> magics.<\/p>\n<p>Variables may be pushed from Python into IDL with <code>%idl_push<\/code>:<\/p>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[4]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"n\">msg<\/span> <span class=\"o\">=<\/span> <span class=\"s\">'  padded   string   '<\/span>\r\n<span class=\"kn\">import<\/span> <span class=\"nn\">numpy<\/span> <span class=\"kn\">as<\/span> <span class=\"nn\">np<\/span>\r\n<span class=\"n\">arr<\/span> <span class=\"o\">=<\/span> <span class=\"n\">np<\/span><span class=\"o\">.<\/span><span class=\"n\">arange<\/span><span class=\"p\">(<\/span><span class=\"mi\">5<\/span><span class=\"p\">)<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[5]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"o\">%<\/span><span class=\"k\">idl_push<\/span> <span class=\"n\">msg<\/span> <span class=\"n\">arr<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[6]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"o\">%%<\/span><span class=\"k\">idl<\/span>\r\n<span class=\"k\">print<\/span><span class=\"p\">,<\/span> <span class=\"n\">strcompress<\/span><span class=\"p\">(<\/span><span class=\"n\">msg<\/span><span class=\"p\">,<\/span><span class=\"o\">\/<\/span><span class=\"n\">REMOVE_ALL<\/span><span class=\"p\">)<\/span>\r\n<span class=\"k\">print<\/span><span class=\"p\">,<\/span> <span class=\"n\">reverse<\/span><span class=\"p\">(<\/span><span class=\"n\">arr<\/span><span class=\"p\">)<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"vbox output_wrapper\">\n<div class=\"output vbox\">\n<div class=\"hbox output_area\">\n<div class=\"prompt output_prompt\"><\/div>\n<div class=\"output_subarea output_display_data\">\n<pre class=\"ipynb\">paddedstring\r\n              4                     3                     2\r\n              1                     0<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>Similarly, variables can be pulled from IDL back to Python with <code>%idl_pull<\/code>:<\/p>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[7]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"o\">%<\/span><span class=\"k\">idl<\/span> <span class=\"n\">arr<\/span> <span class=\"o\">+=<\/span> <span class=\"mi\">1<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[8]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"o\">%<\/span><span class=\"k\">idl_pull<\/span> <span class=\"n\">arr<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[9]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"n\">arr<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"vbox output_wrapper\">\n<div class=\"output vbox\">\n<div class=\"hbox output_area\">\n<div class=\"prompt output_prompt\">Out[9]:<\/div>\n<div class=\"output_subarea output_pyout\">\n<pre class=\"ipynb\">array([1, 2, 3, 4, 5])<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>Variables can also be pushed and pulled from IDL inline using the <code>-i<\/code> (or <code>--input<\/code>) and <code>-o<\/code> (or <code>--output<\/code>) flags:<\/p>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[10]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"n\">Z<\/span> <span class=\"o\">=<\/span> <span class=\"n\">np<\/span><span class=\"o\">.<\/span><span class=\"n\">array<\/span><span class=\"p\">([<\/span><span class=\"mi\">1<\/span><span class=\"p\">,<\/span> <span class=\"mi\">4<\/span><span class=\"p\">,<\/span> <span class=\"mi\">5<\/span><span class=\"p\">,<\/span> <span class=\"mi\">10<\/span><span class=\"p\">])<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[11]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"o\">%<\/span><span class=\"k\">idl<\/span> <span class=\"o\">-<\/span><span class=\"n\">i<\/span> <span class=\"n\">Z<\/span> <span class=\"o\">-<\/span><span class=\"n\">o<\/span> <span class=\"n\">W<\/span> <span class=\"n\">W<\/span> <span class=\"o\">=<\/span> <span class=\"n\">sqrt<\/span><span class=\"p\">(<\/span><span class=\"n\">Z<\/span><span class=\"p\">)<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[12]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"n\">W<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"vbox output_wrapper\">\n<div class=\"output vbox\">\n<div class=\"hbox output_area\">\n<div class=\"prompt output_prompt\">Out[12]:<\/div>\n<div class=\"output_subarea output_pyout\">\n<pre class=\"ipynb\">array([ 1.        ,  2.        ,  2.23606801,  3.1622777 ])<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h3 class=\"ipynb\">Plotting<\/h3>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>Inline plots are displayed automatically by the IPython notebook. IDL Direct graphics are used. The optional <code>-s width,height<\/code> argument (or <code>--size<\/code>; default: <code>600,375<\/code>) specifies the size of the resulting png image.<\/p>\n<\/div>\n<div class=\"cell border-box-sizing code_cell vbox\">\n<div class=\"input hbox\">\n<div class=\"prompt input_prompt\">In?[13]:<\/div>\n<div class=\"input_area box-flex1\">\n<div class=\"highlight-ipynb\">\n<pre class=\"ipynb\"><span class=\"o\">%%<\/span><span class=\"k\">idl<\/span> <span class=\"o\">-<\/span><span class=\"n\">s<\/span> <span class=\"mi\">400<\/span><span class=\"p\">,<\/span><span class=\"mi\">400<\/span>\r\n<span class=\"n\">plot<\/span><span class=\"p\">,<\/span><span class=\"n\">findgen<\/span><span class=\"p\">(<\/span><span class=\"mi\">10<\/span><span class=\"p\">),<\/span><span class=\"n\">xtitle<\/span><span class=\"o\">=<\/span><span class=\"s\">'X'<\/span><span class=\"p\">,<\/span><span class=\"n\">ytitle<\/span><span class=\"o\">=<\/span><span class=\"s\">'Y'<\/span><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"vbox output_wrapper\">\n<div class=\"output vbox\">\n<div class=\"hbox output_area\">\n<div class=\"prompt output_prompt\"><\/div>\n<div class=\"output_subarea output_display_data\">\n<pre class=\"ipynb\">% Compiled module: WRITE_PNG.<\/pre>\n<\/div>\n<\/div>\n<div class=\"hbox output_area\">\n<div class=\"prompt output_prompt\"><\/div>\n<div class=\"output_subarea output_display_data\"><img decoding=\"async\" alt=\"\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQAQAAAACoxAthAAAABGdBTUEAALGPC\/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAJiS0dEAAHdihOkAAAEk0lEQVR42u3bTY7kNBTA8XyYKiNFGi+DhGjPDYoLgIGL1EEQ8rBiwYIjzFGKm\/QRvGQFtMqprkrybOcvdTIjyFuME8s\/+TkvpY5TU1W1xx577LEHie4dJ9pT8nXvKFFmG2I5Of9TjDBNzDeVqVxdqcpWL8c6Hpt4bOPxiOgLJx6Td95fD+p43gzdsdGxGZOX2JLkYiefgoQimY34bNeyk50gErLD2wrf\/IonpjnpObGbEMeJx+T6Z4eRlhO1Cek5MZxYTpxIQo54cURulvq+oKWk5URtQnpODCeWEyeR24OiHF4i2mVIXYnEZkgrk3OGKJG8u7wtkZ9ge\/t3msTiH8O41+SWb8VZssTxK+bx8utKJLl7rOVEbUJ6TgwnZ04cJx6TWyUBaZIkpIhKjkjOonlihhPLyZkTj0nNyWtZViUdJ5oTw4nlxHHi0yTI4l7JxTf\/vSyLE1OcdJyYTYjlxHHiMak5eajkiqTjRHNiciSIxOZGyLM4npjHpObksSzrkY4TzYnhxGbIUd4muAzp5G2CzxB5m1BnibiWUVmWbXmyRF6LyhEtbhNGxZ9uE+Tlm8xZgtgsEbcJLkeO4jbB54h4j9WcjMuyFuk40ZycOLGcOE48JnVVIGFGmtKI+Sxqcr4gMc2J4eTEiePkgsm0LOuQAycqTWyC6DTpE8SkO1SC2DQ5JIhLk+Nf1yZMR1ymHfcRicTqaUd5+dMP2IKLfOBEZ0j1ZuTEieXEceIxmX3AyqTh5MCJXoeE8elpTsK0YzKL5Yk5TjwmQiVLpOHkwIlehdST5+RTmTQTYjlxZaImxJdJNyZSJWdv4MekWURGz\/xSJafP\/E9hNItUllkpx4n1nNiVyLgSF048Jm2FScOJ4kRzYjixnJw58auRcD+UK5n9YyFXMpuY4kRzYjixnJw58VuQRCVzpOFEcaI5MZzYpSS8Hp0TJEw77rNccGJ1hUnLidqE9JwYTiwnjhOPSbKSadJyolYlYWiTlUzf\/CZJkolZThwnHpN0JZOk5UStSV6\/GugXk9fX6WYxeX3RbZeT24tut3z5txfdfjkZlp+p5HxjFbcJmUpOtwmHIaNMWVLfjHTLSS\/\/h68ceXrG5HZ1z5w4TObv0cqkwqThRHGiOTGcnDhxiIQiCdIs2UrKiWUrKZOGE8WJ5sRwcuLEbUHylZRJhUnDieJEc2IgCaVKip+XM0\/MY1JzUijLG5GOE82J4cRy4jjxmJQqKZBSWd6EhFIlhZu\/VEkhMcOJ5cRx4jH5wMmvJfEG5Oh\/v7bgt6Kd+42S3v5BibEf4a9rX8iFE88J\/T1yxX\/1\/LJL4sRhcrxg8vlGGxdz9PEsdn4Tm59jXztZ78Fem85dmy9i57ex+TGSxo5JZ66Nto9k2AX\/EBM4mDHRAzlfmy8HEpufrv\/WSibD68Sv4sl3sfklT2Iq70druREtknpEhrX8OZBeJMN3aN8\/P5IPcmLqFGU8qyuBNKcJiVenH5H3\/vGKTevSxlSenh\/J02j5w5A9\/gfRFB9QZlGbLUj1kZPnTWbhZJsr1hQfHOdEYbLHHnvs8d+MfwHiWHM\/mhaQZAAAAABJRU5ErkJggg==\" \/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h2 class=\"ipynb\">Known issues and limitations<\/h2>\n<\/div>\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<ul>\n<li>The <code>%idl<\/code> line magic fails with <code>TypeError: coercing to Unicode: need string or buffer, dict found<\/code> in current release versions of IPython (0.13.2 and below) due to a <a href=\"http:\/\/stackoverflow.com\/questions\/14574434\/unicode-error-with-ipython-rmagic-r-seems-to-work-but-not-r-fully\">known bug<\/a>; the github development version of IPython works as expected.<\/li>\n<li>Only one plot can be rendered per cell<\/li>\n<li>Processing for possibly unused plot output slows execution<\/li>\n<li>Scalar variables from IDL may be returned as single-element Numpy arrays<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<p>The plotting capabilities are rather kludgy due to IDL&#8217;s old-school graphics routines.? I opted to implement Direct Graphics, which are the lowest common denominator supported by IDL and GDL.? Since I have to initialize the device before the plot call and close it afterwards, the <code>%idl<\/code> magic can only produce one plot output per notebook cell.? The plotting code produces overhead on non-plotting lines as well, unfortunately; I chose syntactic simplicity over execution speed for the time being.<\/p>\n<p>Stay tuned to see it in action!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The IPython Notebook combines code, documentation, and computational results in one package that&#8217;s easy to share.? It&#8217;s proving a great way to teach, as notebooks are easy for the instructor to write and for students to modify.? Notebooks also provide seamless integration with other programming environments through extensions providing &#8220;magic functions&#8220;: short code prefixes beginning [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[21,8],"tags":[],"class_list":["post-865","post","type-post","status-publish","format-standard","hentry","category-programming-2","category-tools"],"_links":{"self":[{"href":"http:\/\/bellm.org\/blog\/wp-json\/wp\/v2\/posts\/865","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bellm.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bellm.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bellm.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/bellm.org\/blog\/wp-json\/wp\/v2\/comments?post=865"}],"version-history":[{"count":39,"href":"http:\/\/bellm.org\/blog\/wp-json\/wp\/v2\/posts\/865\/revisions"}],"predecessor-version":[{"id":903,"href":"http:\/\/bellm.org\/blog\/wp-json\/wp\/v2\/posts\/865\/revisions\/903"}],"wp:attachment":[{"href":"http:\/\/bellm.org\/blog\/wp-json\/wp\/v2\/media?parent=865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bellm.org\/blog\/wp-json\/wp\/v2\/categories?post=865"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bellm.org\/blog\/wp-json\/wp\/v2\/tags?post=865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}