| 
 
	积分3625贡献 精华在线时间 小时注册时间2014-10-21最后登录1970-1-1 
 | 
 
 
 楼主|
发表于 2020-7-3 09:24:28
|
显示全部楼层 
| 本帖最后由 15195775117 于 2020-7-3 09:28 编辑 
 python调用IDL,我从网上找到3个包:
 
 1、IDLpy:
 IDL的help里内置了
 
 2、pyIDL:
 https://pypi.org/project/pyIDL/0.6/
 这个还没试过,
 网上说:“pyidl是很久之前的包,依赖于numarray。但是,numarray是numpy的前身,现在numarray已经弃用了,使用pip是无法安装的”
 
 3、pIDLy:Github:https://github.com/anthonyjsmith/pIDLy
 (以下内容来源:http://blog.sciencenet.cn/blog-3413604-1177710.html)
 “虽然它为Python2.6.x写的,但是在Python3.X依然好用~”
 “注意:由于pIDLy依赖pexpect包,但是pexpect包的spawm函数在Windows下是不可用的,所以pIDLy只能在Linux和MacOS下运行!!!”
 
 安装:pip install pidly
 下载源文件(tar.gz),解压后[python setup.py install ]
 
 pIDLy使用示例:
 
 Usage:
 Initiate:
 >>> import pidly
 >>> idl = pidly.IDL()
 Or:
 idl = pidly.IDL('/path/to/idl')
 Execute commands:
 >>> idl('x = total([1, 1], /int)')
 Retrieve values:
 >>> print(idl.ev('x'))
 2
 Or (slightly slower):
 >>> print(idl.x)
 2
 Evaluate expressions:
 >>> print(idl.ev('x ^ 2'))
 4
 Use cache (IDL save) to handle large arrays:
 >>> idl('x=[1,2,3,4,5,6]')
 >>> print(idl.ev('x', use_cache=True))
 [1 2 3 4 5 6]
 Transfer a list of IDL variables, using cache:
 >>> idl('y=[1,2,3,4,5,6]')
 >>> xy = idl.ev_list(['x','y'], use_cache=True)
 >>> print(sorted(xy.keys()))
 ['x', 'y']
 >>> print(xy['x'])
 [1 2 3 4 5 6]
 Assign value from Python expression:
 >>> idl.x = 2 + 2
 >>> print(idl.x)
 4
 Or:
 >>> idl('x', 2 + 2)
 >>> print(idl.x)
 4
 Perform IDL function on Python expression(s):
 >>> idl.func('reform', range(4), 2, 2)
 array([[0, 1],
 [2, 3]])
 Or (slightly slower):
 >>> idl.reform(range(4), 2, 2)
 array([[0, 1],
 [2, 3]])
 With keywords (/L64 -> L64=True or L64=1)
 >>> x = idl.histogram(range(4), binsize=3, L64=True)
 >>> print(x)
 [3 1]
 >>> print(x.dtype)
 int64
 IDL procedure with Python argument(s):
 >>> idl.pro('plot', range(10), range(10), xstyle=True, ystyle=True)
 Interactive mode:
 >>  idl.interact()
 IDL> print, x
 4
 IDL> ^D
 >>>
 Close:
 >>> idl.close()
 pIDLy supports the transfer of:
 * ints, longs, ...
 * floats, doubles, ...
 * strings
 * arrays of the above types, with arbitrary size and shape
 * dictionaries <-> structures & lists of dicts <-> arrays of structures
 but with certain limitations on transfer from Python to IDL
 [NB if getting Syntax Errors when passing large arrays to IDL, try using
 >>  idl = pidly.IDL(long_delay=0.05)
 default is 0.02.]
 
 
 以上接口是否可用,是否好用,有待测试
 
 
 
 | 
 |