Пример #1
0
    def cleanSpectrum(self,x,y):
        ##=============== BB Fit to extend spectrum beyond 11000 Angstroms ==================
        fraction = 1.0/3.0
        nirX = np.arange(int(x[(1.0-fraction)*len(x)]),20000)
        T, nirY = fitBlackbody(x,y,fraction=fraction,newWvls=nirX,tempGuess=5600)
        
        if self.plots: plt.plot(nirX,nirY*1E15,linestyle='--',linewidth=2, color="black",alpha=0.5)

        extendedWvl = np.concatenate((x,nirX[nirX>max(x)]))
        extendedFlux = np.concatenate((y,nirY[nirX>max(x)]))
        ##======= Gaussian convolution to smooth std spectrum to MKIDs median resolution ========
        newX, newY = gaussianConvolution(extendedWvl,extendedFlux,xEnMin=0.005,xEnMax=6.0,xdE=0.001,fluxUnits = "lambda",r=self.r,plots=False)
        return newX, newY
fig = plt.figure()
ax = fig.add_subplot(111)
ax.set_xlim(3000,12000)

std = MKIDStd.MKIDStd()
a = std.load(objectName)
a = std.countsToErgs(a)
x = a[:,0]
y = np.array(a[:,1]) #std object spectrum in counts/s/Angs/cm^2
#End MKIDStd loading

plt.plot(x,y*1E15,linewidth=1,color='grey',alpha=0.75)

fraction = 0.65 # set to 1 to fit BB to whole spectrum. 0.2 fits BB to only last 20% of spectrum
fitx = x[(1.0-fraction)*len(x)::]
fity = y[(1.0-fraction)*len(x)::]
plt.plot(fitx, fity*1E15,color='black')

Temp = utils.fitBlackbody(x,y)

newwl = np.arange(4000,20000,100)
Temp, newflux = utils.fitBlackbody(x,y,fraction=fraction,newWvls=newwl)

plt.plot(newwl,newflux*1E15,color = 'blue')
plt.legend(['G158-100 Spectrum','Section used to fit', 'BB Fit'],'upper right', numpoints=1)
plt.xlabel(ur"Wavelength [\AA]")
plt.ylabel(ur"Flux [10$^{-15}$ ergs/s/cm$^{2}$/\AA]")
plt.show()