1

我正在尝试使用 Scipy 模块在 Python 中绘制绘图。根据http://docs.scipy.org/doc/scipy/reference/special.html我写了代码scipy.special.spherical_jn(n,x,0)

import matplotlib.pyplot as plt
import numpy as np
import scipy.special as sp

from matplotlib import rcParams
rcParams.update({'figure.autolayout': True})

def odrazTE(a,o,d):
    temp1 = sp.spherical_jn[1,a,0]
    temp2 = 1
    return abs(temp1/temp2)**2

t = np.arange(0.001, 2, 0.001)
plt.plot(t,odrazTE(t,t,1),label='TE1')
plt.show()

在编译程序时,我得到的只是这个错误:

Traceback (most recent call last):
  File "standing-sphere.py", line 33, in <module>
    plt.plot(t,odrazTE(t,t,1),label='TE1')
  File "standing-sphere.py", line 15, in odrazTE
    temp1 = sp.spherical_jn[1,a,0]
AttributeError: 'module' object has no attribute 'spherical_jn'

有办法用常规贝塞尔函数以及贝塞尔和球贝塞尔函数之间的关系来做到这一点,但由于 sph.bess 的导数,我不喜欢这个解决方案。我也需要的功能。

有没有可能我设置错误并且可以将其修复为 scipy.special.spherical_jn 工作?

4

1 回答 1

3

scipy.special.spherical_jn在 2016 年 7 月 25 日发布的 scipy 版本 0.18.0 中添加。我猜你使用的是旧版本的 scipy。要检查,运行

import scipy
print(scipy.__version__)
于 2016-08-08T00:34:16.050 回答