Arctan功能是不连续的

时间:2017-01-28 21:07:44

标签: python-2.7 list-comprehension atan2

我有很多问题试图通过我的omega与时间的情节来解决问题,因为从arctan函数返回的角度跳跃到正值。我尝试添加2 * pi以便它返回到第一个象限,但无济于事(从using arctan / arctan2 to plot a from 0 to 2π的答案)。然后我尝试将数组中的所有项目都设为负数,以便继续,但我不确定问题是什么: arctan plot returns values that jump discontinuously 我也尝试过使用arctan2,math.atan,math.atan2

h = h5py.File("Waveforms/BBH0001/rhOverM_Asymptotic_GeometricUnits.h5", "r")
data = h['Extrapolated_N2.dir/Y_l2_m1.dat']

我必须定义一个函数,因为我在尝试查找数组的arctan时遇到错误,然后vectorize iy

def f(z):
    return np.int(math.degrees(np.arctan(z)))

f2 = np.vectorize(f)
z = data[:,2]/data[:,1]
a = f2(z)

对于你们中的一些人来说,这部分代码可能看起来很痛苦。我尝试使用很多不同的方法来解决问题

i = 1
for i in xrange(len(z)):
    if a[i] > (a[i-1] + 10):
        b = [-x for x in a]

plt.plot(data[:,0], b, label='w')

0 个答案:

没有答案