Python Bridge

Overview

The Python Bridge consists of two components: the IDL to Python bridge and the Python to IDL bridge. The bridge provides the following features:

The Python Bridge also has a kernel for running IDL in an IPython notebook. See IDL IPython Notebook Kernel for details.

Examples

Use Python commands in the following ways to convert a 10 x 2 matrix representing Cartesian coordinates to Polar coordinates.

Example 1, IDL to Python Objects

In IDL:

IDL> np = Python.Import('numpy')

IDL> coords = np.random.random([10,2])

IDL> x = coords[0,*]

IDL> y = coords[1,*]

IDL> r = np.sqrt(x^2+y^2)

IDL> t = np.arctan2(y,x)

IDL> print, r

IDL> print, t

Example 2, IDL to Python Command Line Mode

In IDL you can directly enter Python "command-line mode" by typing three ">>>" characters and pressing the Enter key:

IDL> >>>

>>> import numpy as np

>>> coords = np.random.random((10,2))

>>> x,y = coords[:,0], coords[:,1]

>>> r = np.sqrt(x**2+y**2)

>>> t = np.arctan2(y,x)

>>> print(r)

>>> print(t)

>>>

IDL>

At the end, press the Enter key to re-enter the normal IDL command mode.

Example 3, Python to IDL

In Python, you can easily access all IDL functionality:

>>> from idlpy import *

>>> import numpy as np

>>> coords = np.random.random((10,2))

>>> x,y = coords[:,0], coords[:,1]

>>> r = IDL.sqrt(x**2+y**2)

>>> t = IDL.atan(y,x)

>>> print(r)

>>> print(t)

Version History

8.5

Introduced

8.6

Added support for Python 3.5, added setup.py script

8.6.1

Added support for Python 3.6

8.7.1 Removed Python 3.4 support.
8.8 Added support for Python 3.7 and 3.8. Removed support for Python 2.7 and 3.5.
8.8.1 Added support for Python 3.9
8.8.2 Added support for Python 3.10. Removed support for Python 3.6.
8.9 Removed support for Python 3.7; simplified installation for all platforms.
9.0 Added support for Python 3.11.