Wednesday, November 7, 2012

Calling IDL, GDL, and FL from Python


Thanks to Anthony Smith's pIDLy module, accessing IDL, and its clones GDL and FL from within Python becomes really easy. 

Launch an IPython session, then typing these example lines to see pidly in action:

I1 import pidly
I2 idl = pidly.IDL()
I3 fl = pidly.IDL('fl', idl_prompt='FL> ')
I4 gdl = pidly.IDL('gdl', idl_prompt='GDL> ')
I5 idl.findgen(10)
O5 array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9.], dtype=float32)
I6 fl.findgen(10)
O6 array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9.], dtype=float32)
I7 gdl.findgen(10)
O7 array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9.], dtype=float32)
I8 np.arange(10, dtype='float32')
O8 array([ 0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.,  8.,  9.], dtype=float32)

Testing these with:

I2 pidly.__version__
O2 '0.2.4+'

I3 np.__version__
O3 '1.8.0.dev-82c0bb8'

$ idl
IDL Version 8.1 (linux x86_64 m64). (c) 2011, ITT Visual Information Solutions

$ gdl    # the version that ships with Fedora 16
GDL - GNU Data Language, Version 0.9.2

$ fl      # latest development snapshot (10/Oct/2012)
Fawlty Language 0.79.18 (linux amd64 m64) Copyright (c) 2000-2012


Example access to an IDL procedure:

I5 idl.pro('cgplot', np.sin(np.linspace(0, 6*np.pi, 1000)))

I6 idl.pro('iplot', np.sin(np.linspace(0, 6*np.pi, 1000)))

For more information, just read the quick usage guide on pidly's web-site, or clone the source from https://github.com/anthonyjsmith/pIDLy

No comments:

Post a Comment