def convolveFilter2D(cube,wl,filter):
xaxis = len(cube[0,0,0:])
yaxis = len(cube[0,0:,0])
zaxis = len(cube[0:,0,0])
input = np.loadtxt(filter)
response_wl = input[:,0] * 1.e-4
response_trans = input[:,1]
minwl = response_wl[0]
maxwl = response_wl[len(response_wl)-1]
intwl = np.copy(wl)
intwl[intwl > maxwl] = -1
intwl[intwl < minwl] = -1
wlrange = intwl > 0
intwl = intwl[wlrange]
transmission = np.zeros(len(wl))
interpfunc = interpolate.interp1d(response_wl,response_trans, kind='linear')
transmission[wlrange] = interpfunc(intwl)
tot_trans = integrate.simps(transmission,wl)
slice = np.zeros((yaxis,xaxis))
for i in range(0,yaxis):
for j in range(0,xaxis):
sed = cube[0:,i,j]
slice[i,j] = integrate.simps(transmission*sed,wl)
return slice/tot_trans
#plt.plot(wl,transmission,'bo')
#plt.plot(wl,transmission,'k-')
#plt.plot(response_wl,response_trans,'r+')
#plt.xscale('log')
#plt.show()
评论列表
文章目录