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!
Requirements
Installation
Usage
Further information
Known bugs/issues
To do
Release history
The following are required, but should be installed automatically if you follow the installation instructions below:
Pexpect <http://pexpect.sourceforge.net/>
_NumPy <http://numpy.scipy.org/>
_Also required:
IDL <http://www.ittvis.com/idl/>
_This version tested on
Type "pip install pidly"
If that fails:
Download https://raw.github.com/pypa/pip/master/contrib/get-pip.py
run it (type "python get-pip.py")
Type "pip install pidly"
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.
Further information is available
Python Package Index <http://pypi.python.org/pypi/pIDLy/>
_GitHub repository <https://github.com/anthonyjsmith/pIDLy>
_Structures can be transferred from IDL to Python as dictionaries
Dictionaries can be transferred from Python to IDL as structures. But:
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
Performance improvement:
Renamed Session class to IDL