anthonyjsmith / pIDLy

pIDLy: IDL within Python
Other
33 stars 14 forks source link

======================== pIDLy: IDL within Python


Control ITT's IDL (Interactive Data Language) from within Python.

Version 0.2.7

Copyright (c) 2008-2017, Anthony Smith

anthonysmith80@gmail.com

(NB: since pIDLy was written, IDL has developed a two-way Python Bridge <http://www.harrisgeospatial.com/docs/Python.html>_. I recommend trying that first.)

This module has been written to enable an IDL <http://www.ittvis.com/idl/> session to be controlled from within Python <http://www.python.org/">. I was inspired by pyIDL <http://www.its.caltech.edu/~mmckerns/software.html>_, which looks great but which I couldn't manage to install. So I wrote my own.

pIDLy works by launching an IDL session as a child application and then passing data between Python and the IDL shell. It's not particularly fast, so not suitable for applications which require huge amounts of data to be passed around with ease. But it should be fine for most applications.

pIDLy requires NumPy <http://www.numpy.org/>, SciPy <https://www.scipy.org/> and Pexpect <http://pexpect.readthedocs.io/en/stable/>_, but these will (hopefully!) be installed automatically if you follow the instructions below. You also need IDL, of course.

Contributions welcome!

Contents

  1. Requirements

  2. Installation

  3. Usage

  4. Further information

  5. Known bugs/issues

  6. To do

  7. Release history

  8. Requirements

The following are required, but should be installed automatically if you follow the installation instructions below:

Also required:

This version tested on

  1. Installation

  2. Type "pip install pidly"

If that fails:

  1. Download https://raw.github.com/pypa/pip/master/contrib/get-pip.py

  2. run it (type "python get-pip.py")

  3. Type "pip install pidly"

  4. Usage

Initiate::

import pidly idl = pidly.IDL()

Or:: idl = pidly.IDL('/path/to/idl')

Or:: idl = pidly.IDL('/path/to/gdl', idl_prompt='GDL> ')

Execute commands::

idl('x = total([1, 1], /int)')

Retrieve values::

print idl.x 2

Or (slightly faster)::

print idl.ev('x') 2

Evaluate expressions::

print idl.ev('x ^ 2') 4

Use cache (IDL save) to handle large arrays::

idl('x=[1,2,3,4,5,6]') print(idl.ev('x', use_cache=True)) [1 2 3 4 5 6]

Transfer a list of IDL variables, using cache::

idl('y=[1,2,3,4,5,6]') xy = idl.ev_list(['x','y'], use_cache=True) print(sorted(xy.keys())) ['x', 'y'] print(xy['x']) [1 2 3 4 5 6]

Assign value from Python expression::

idl.x = 2 + 2 print idl.x 4

Or::

idl('x', 2 + 2) print idl.x 4

Perform IDL function on Python expression(s)::

idl.reform(range(4), 2, 2) array([[0, 1], [2, 3]])

Or (slightly faster)::

idl.func('reform', range(4), 2, 2) array([[0, 1], [2, 3]])

With keywords (/L64 -> L64=True or L64=1):

idl.histogram(range(4), binsize=3, L64=True) array([3, 1], dtype=int64)

IDL procedure with Python argument(s)::

idl.pro('plot', range(10), range(10), xstyle=True, ystyle=True)

Interactive mode::

idl.interact() IDL> print, x 4 IDL> ^D

Close::

idl.close()

pIDLy supports the transfer of

NB if getting Syntax Errors when passing large arrays to IDL, try using::

idl = pidly.IDL(long_delay=0.05) # default is 0.02.

  1. Further information

Further information is available

  1. Known bugs/issues

  1. To do

  1. Release history

Version 0.2.7, 2 Apr 2017

Version 0.2.6, 4 Aug 2014

Version 0.2.5, 19 Feb 2014

Version 0.2.4, 22 Feb 2008

Version 0.2.3, 18 Feb 2008

Version 0.2.2, 9 Feb 2008

Version 0.2.1, 8 Feb 2008

Version 0.2, 7 Feb 2008

Version 0.1.3, 6 Feb 2008

Version 0.1.2, 4 Feb 2008

Version 0.1.1, 1 Feb 2008

Version 0.1, 31 Jan 2008