Python的数学方程式

时间:2014-06-13 06:38:04

标签: python math equation

我试图用python获得数学方程的解决方案如下:

# Open netCDF file
fd1 = nc.Dataset(nc_file1, 'r')

# Read variables from the netCDF file
rng1 = fd1.variables['range'][:]
tim1 = fd1.variables['time'][:]
pwr1 = fd1.variables['pwr'][:]
dpl1 = fd1.variables['dpl'][:]
nfft1 = fd1.variables['nfft'][0]
pn1 = fd1.variables['pnoise'][:]

# Close netCDF file

fd1.close()

# Specify beam 
ibeam1 = 0

# Time convertion from seconds to hours
tim1 = tim1/3600.0

# Select data and transpose
p_plot1 = pwr1[ibeam1]
for it1 in range(len(tim1)):
   p_plot1[it1] = p_plot1[it1] - pn1[ibeam1][it1] - 10.*np.log10(nfft1)
p_plot1 = p_plot1.transpose() 

**#Determine Height**
A=6378.1370
Tetha=math.cos((37.5 * math.pi) / 180)
for j in range(len(tim1)):
   for i in range(len(rng1)):
       D[i]=sqrt(A**2+(rng1[i]**2)+(2*A*(rng1[i])*Tetha)
       height1(i,j)=(D[i]-A)

从数学方程式(确定高度)我得到了错误。它可能是python中方程的语法。实际上,我专注于三个变量的数据,即tim1,rng1和pwr1。从rng1数据我将获得height1,只需通过使用该等式将rng1转换为height1。 提前谢谢。

1 个答案:

答案 0 :(得分:1)

问题是行

D[i]=sqrt(A**2+(rng1[i]**2)+(2*A*(rng1[i])*Tetha)

括号不匹配,只需在最后添加一个,这样就可以了。

D[i]=sqrt(A**2+(rng1[i]**2)+(2*A*(rng1[i])*Tetha))