2014-06-13 49 views
-3

我想这样如下获得与蟒蛇的数学方程求解:数学方程式与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

你忘了提问了。 – jonrsharpe

+0

'D [i] = sqrt(A ** 2 +(rng1 [i] ** 2)+(2 * A *(rng1 [i])* Tetha)'末尾需要额外的')' –

+0

只是一个额外的)。因为我给了额外的一个后,仍然有最后一行 – user3346361

回答

0

的问题是括号不匹配,仅添加一个类似这样的结尾,它会工作的行

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)) 
+0

错误不只是一个额外的)。因为在我给了额外的一个之后,最后一行仍然有错误 – user3346361

+0

'height1(i,j)'是一个函数调用,或许height1意味着是一个二维数组?在这种情况下,它应该是'height1 [i] [j]' – Zhewriix

+0

是的,正确的。 Height1是一维数组。所以,我可以修改最后一个脚本:height1 [i] =(D-A)。谢谢你们。 – user3346361