[英]repeat angular function python
def ang(theta1,theta2,x1,x2,r,dens):
theta = []
r1 = []
ds = []
#note x1,x2 is input data
theta = np.arctan2(x1,x2)
ang_deg = (theta*180)/(np.pi)
for i in range(len(ang_deg)):
if theta1 <= ang_deg[i]<= theta2:
r1.append(r[i])
ds.append(dens[i])
return
該函數正常工作,但是我想知道如何編碼它,而不是說僅計算theta1 = 0和theta2 = 10度,我如何優化它以使其能夠像從0開始一樣執行幾次,分別為10、10、20、20.30度,分別給出r1和ds。
謝謝
您始終可以創建其他函數:
def ang_multiple(theta1s, theta2s, x1, x2, r, dens):
results = []
for i, theta1 in enumerate(theta1s):
results.append(ang(theta1, theta2s[i], x1, x2, r dens))
return results
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.