问题描述
我想在python代码中运行IDL脚本,因为稍后需要在python脚本中分析IDL代码的结果,但是我不知道它是如何工作的.我想例如以python代码调用此IDL脚本:
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
我该怎么办?
推荐答案
IDL的最新版本(8.5)本机支持此功能,它们提供了自己的双向桥接器,用于从IDL调用Python和从Python调用IDL.他们的文档在这里: http://www.exelisvis.com/docs/pythontoidl.html
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)
这篇关于在Python中调用IDL脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!