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

How could I do it?

解决方案

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)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值