Calling an IDL script in Python

和自甴很熟 提交于 2019-12-11 02:38:17

问题


I would like to run an IDL script in a python code, since I need to analyse the results of IDL code later in the python script but I have no idea how it works. I want to call this IDL script for example in a python code:

pro plotgaussian, center, sigma, X=x, Y=y
x = findgen(1000) / 999; numbers running 0 to 1 in steps of 0.001
x = x * 6 * sigma - 3 * sigma; widen x to range over 6 sigma
x = x + center; center the x range on the bell curve center
arg = ((x – center)/sigma)^2
y = exp(-arg)
plot, x, y
end

How could I do it?


回答1:


The newest version of IDL (8.5) supports this natively, they provide their own bidirectional bridge for calling Python from IDL, and IDL from Python. Their docs are here: http://www.exelisvis.com/docs/pythontoidl.html

Some example code from their docs:

>>> from idlpy import IDL
>>> arr = IDL.findgen(100)/50*3.14159
>>> x = 50*IDL.sin(arr)
>>> y = 50*IDL.cos(arr)
>>> m = IDL.map(test=1)
% Compiled module: MAP.
>>> p = IDL.plot(x - 90, y, 'r-o2', overplot=1)
% Compiled module: PLOT.
>>> p = IDL.plot(x + 90, y, 'b-o2', overplot=1)
>>> m.save('map.png', resolution=96, border=0, transparent=1)



回答2:


Try pyIDL. Google for it, I'm not sure where the most recent version lives. It seems to be fairly old, you might have to do some work to convert from numarray to NumPy.




回答3:


More recently maintained than pyIDL seems to be pIDLy. I have not tried it (I am not an IDL user).



来源:https://stackoverflow.com/questions/18368582/calling-an-idl-script-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!