TypeError
Traceback (most recent call last)
<ipython-input-86-57daa474841c> in <module>()
1 SNRb=[]
2 for i in range(len(fb)): #set up our function to find all values of SNR for the corresponding B values in flux, sky, and r
----> 3 SNRb=SNR1(fb[i],skyb[i],rb[i]) #time= 1/60 minutes because the image was from a 1 second capture
4 SNRb.append(SNRb)
5 print(SNRb)
<ipython-input-85-b4e9ec515c0d> in SNR1(f, sky, r)
28 fs=F+S #adding the background to the flux/n for simplicity
29 fst=[(10/x)/60 for x in fs] #the factors inside the square root, simplified into 1 term
---> 30 return(ft*math.sqrt(fst))
TypeError: a float is required
In [ ]:
答案 0 :(得分:3)
您的问题似乎是您正在通过math.sqrt
list
一个无法使用的对象。
您可能要做的是获取该列表中每个元素的平方根。您可以使用numpy
来完成此操作并简化代码,但假设您没有安装代码,则可以使用以下列表理解:
return [ft * math.sqrt(fst_i) for fst_i in fst]