# Plot Response vs Frequency for 1st and 2nd stages def f(fig, ax): ax.plot(freqListMHz, freqResponsePfbDb, label="FFT bin") # ax.plot(freqListMHz,freqResponseFftDb) # ax.plot(freqListMHz,freqResponseLpfDb) ax.plot(freqListMHz, freqResponseDb, label="final channel") ax.axvline(resFreq / 1.0e6, color=".5", label="resonant freq") ax.axvline(resFreq2 / 1.0e6, color=".8") ax.axvline(resFreq3 / 1.0e6, color=".8") ax.set_ylim(-50, 0) ax.set_ylabel("response (dB)") ax.set_xlabel("frequency (MHz)") ax.legend(loc="lower left") pop(plotFunc=lambda fig, axes: f(fig=fig, ax=axes)) # Plot Response vs Phase for 1st and 2nd stages def f(fig, ax): ax.plot(freqListMHz, phaseResponse, label="overall") ax.plot(freqListMHz, phaseResponseLpf, label="LPF") ax.plot(freqListMHz, phaseResponsePfb, label="FFT") ax.axvline(resFreq / 1.0e6, color=".5", label="resonant freq") ax.axvline(resFreq2 / 1.0e6, color=".8") ax.axvline(resFreq3 / 1.0e6, color=".8") ax.set_ylabel("phase response ($^\circ$)") ax.set_xlabel("frequency (MHz)") ax.legend(loc="best") pop(plotFunc=lambda fig, axes: f(fig=fig, ax=axes))
print 'illumination corrected sigma', illumFwhm['sigma'], print '{:.1f}%'.format(illumFwhmPercent) print 'flatfield corrected sigma', flatFwhm['sigma'], print '{:.1f}%'.format(flatFwhmPercent) print 'shot noise sigma',shotNoiseSigma,'{:.1f}%'.format(shotPercent) print 'noise ratio',flatToShotNoiseRatio # Plot def plotFunc(fig,axes): axes.set_title('Distribution of pixel counts') axes.plot(rawHistEdges[0:-1],rawHist,color='k',label='raw') axes.plot(illumHistEdges[0:-1],illumHist,color='b',label='illum') axes.plot(flatHistEdges[0:-1],flatHist,'r',label='flatfield') axes.set_xlabel('Counts') axes.set_ylabel('Num of Pixels') axes.legend() pop(plotFunc=plotFunc) plotDict = {'rawHistEdges':rawHistEdges,'rawHist':rawHist,'illumHistEdges':illumHistEdges,'illumHist':illumHist,'flatHistEdges':flatHistEdges,'flatHist':flatHist,'flatLabel':flatLabel,'lowerWvlCut':lowerWvlCut,'upperWvlCut':upperWvlCut,'imgFilename':outfilename,'obsDate':date,'obsTimestamp':obsTimestamp,'bClippedImgs':bClipData,'nBins':nBins} pickle.dump(plotDict,open( 'flatHist.pickle', 'wb' )) #outfile.write('{}\t{}\t{:.1f}\t{:.1f}\t{:.1f}\t{:.1f}\t{:.2f}\t{}\n'.format(obsTimestamp,avgCounts,rawFwhmPercent,illumFwhmPercent,flatFwhmPercent,shotPercent,flatToShotNoiseRatio,exptime))