Wednesday, November 7, 2012

Issues with GDL Python module

1-) Importing GDL segfaults in IPython

$ ii # this is alias for ipython --pylab
Python 2.7, IPython

I1 import GDL

I2 Segmentation fault (core dumped)

however, works fine in Python shell

>>> import GDL
>>> GDL.findgen(5)

>>> GDL.function('findgen',5)
array([ 0.,  1.,  2.,  3.,  4.], dtype=float32)

possibly readline module issue? Interestingly, works fine in Spyder's IPython console.

2-) Source compiled (with --enable-python_module option) GDL Python module fails to work

 >>> import GDL
Traceback (most recent call last):
  File "", line 1, in
ImportError: ./ invalid ELF header

possibly, due to wrong lib arch use, during compilation?

3-) GDL's dindgen yields wrong result while accessed through its Python module

>>> GDL.function('dindgen',10)
array([  0.00000000e+000,   1.00000000e+000,   2.00000000e+000,
         3.00000000e+000,   4.00000000e+000,   0.00000000e+000,
         5.92878775e-323,   3.30571061e-313,   6.94380683e-310,

Posted this issue on dindgen with GDL python module

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 ''

$ 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'cgplot', np.sin(np.linspace(0, 6*np.pi, 1000)))

I6'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

Worldcloud for ccnworks

Here is a worldcloud created for my code repository on:

First get the commit message history into a text file (the last commit is r287):

svn log >> test.txt

Then with a bit of VIM trick and manual step, remove unwanted lines:

sort u

Select of all the text, and import into

Tadaaa, here comes the result :)

Indeed, we are data scientists here in atmospheric science!

Alternative wordcloud implementation comes from Andreas Mueller. I saw his A Wordcloud in Python titled posting via Planet SciPy. In order to run his I needed to change unsigned int[:,:] integral_image -> unsigned long[:,:] integral_image in query_integral_image.pyx to get past 'ValueError: Buffer dtype mismatch, expected 'unsigned int' but got 'unsigned long''.

Then feeding the same log data I get the following image, which is nicer looking than the wordle's image :)