pIDLy: IDL within Python
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.
It has been tested on
- Linux (Python 2.5, IDL 6.3, 6.4 and 7) and
- Mac OS X (Python 2.5, IDL 6.4).
DownloadUpdate: pIDLy is now on GitHub, so visit there for any recent developments. Contributions and improvements welcome! But the following instructions are still valid for the latest released version.
To install (Linux, Mac):
- Download ez_setup.py and
run it (
To make sure you have the latest version:
easy_install --upgrade pidly
Source and egg distributions are available from the pIDLy page on the Python Package Index.
Initiate: >>> import pidly >>> idl = pidly.IDL() Or: idl = pidly.IDL('/path/to/idl') 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 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: * ints, longs, ... * floats, doubles, ... * strings * arrays of the above types, with arbitrary size and shape * dictionaries <-> structures & lists of dicts <-> arrays of structures but with certain limitations on transfer from Python to IDL [NB if getting Syntax Errors when passing large arrays to IDL, try using >> idl = pidly.IDL(long_delay=0.05) default is 0.02.]
* Python variables cannot be used as "output" parameters for IDL procedures and functions; use idl('my_procedure, output_parameter') to run the procedure then idl.output_parameter to retrieve the output. * If Python is force-killed when IDL is running, IDL will persist and run wild * Restrictive limits on size of Python dictionaries to send to IDL structures * Slow transferring large Python arrays to IDL, e.g., 20,000 doubles in 12-15s * IPython on Aquamacs: prints input in interactive mode * Aquamacs: interactive mode has very small input buffer (253 bytes?) * idl.f(..., idl.g(...)) doesn't work (pidly_tmp conflict)
Version 0.2.4, 22 Feb 2008 * Fixed bug with keyword arguments in functions * Added pro() method for IDL procedures with Python arguments Version 0.2.3, 18 Feb 2008 * Improved garbage collection (using weakref and atexit) * IDL Errors: launches interactive after '% Stop' or '% Execution Halted' * If IDL pauses (waiting for input?), KeyboardInterrupt -> interactive mode * Fixed bugs with NumPy array input * Fixed problems with double precision float transfer * Fixed problem with spaces in strings in structures/dictionaries * Added test() function for full tests * Added NaN and Inf support Version 0.2.2, 9 Feb 2008 * Fixed bug, where IDL would run wild when IPython closed Version 0.2.1, 8 Feb 2008 * Added keyword parameters in calls to IDL functions * Added support for Python bool type Version 0.2, 7 Feb 2008 * Structures can be transferred from IDL to Python as dictionaries * Dictionaries can be transferred from Python to IDL as structures. But: - lists of dictionaries must be explicitly and consistently typed - the dictionary, or each dictionary in the list, must be short enough to fit into a single command for IDL - long lists of dictionaries are likely to be slow from Python to IDL, as assignment takes place one dictionary at a time * Now gives "live" output while waiting for the IDL prompt * Fixed bug related to long IDL 'help' output * String arrays with arbitrary spaces now work Version 0.1.3, 6 Feb 2008 * Added support for unsigned integers * Fixed bug with byte/int8 * Added easy access to IDL variables and functions (__getattr__ and __setattr__) Version 0.1.2, 4 Feb 2008 * Performance improvement: * 5-100 times faster, tranferring from Python to IDL * ~1.5x faster, transferring from IDL to Python * Renamed Session class to IDL Version 0.1.1, 1 Feb 2008 * Removed timeout limit * Fixed typo in license * README and LICENSE files Version 0.1, 31 Jan 2008 * Wrapper on Pexpect, with conversions between IDL data and NumPy arrays * Handles arbitrarily sized and shaped arrays of strings, ints and floats
Please feel free to contact me with comments, questions and suggestions: A.J.Smith at sussex.ac.ukLast modified: 22 Feb 2008