示例#1
0
    def testFitExponRealData(self):
        """
        Read timestamps from part of one data file where there was an event.
        """

        # We imported FileName at the top of this file.  Use this to
        # locate the file for this specific observation.          
        # on turk, the file with the observation is this one:
        # /ScienceData/PAL2012/20121211/obs_20121212-1333303.h5
        run = 'PAL2012'
        sundownDate = '20121211'
        obsDate = '20121212'
        seq = '133303'
        fn = FileName(run, sundownDate, obsDate+"-"+seq)
        # The class Cosmic is in ARCONS-pipeline/cosmic/Cosmic.py
        cosmic = Cosmic(fn)
        t0 = 138595526
        t1 = 138595666
        dictionary = cosmic.fitExpon(t0,t1)
        
        hist = dictionary['timeHgValues']
        bins = np.arange(len(hist))
        width = 0.7*(bins[1]-bins[0])
        center = (bins[:-1]+bins[1:])/2
        #plt.step(center, hist, where = 'post')       
        plt.plot(bins,hist, label='data')

        xFit = np.linspace(0,len(hist),10*len(hist))
        pFit = dictionary['pExponFit']        
        yFit = Cosmic.funcExpon(xFit,*pFit)
        plt.plot(xFit,yFit, label='Exponential Fit')

        xFit = np.linspace(0,len(hist),10*len(hist))
        pFit = dictionary['pGaussFit']        
        print "pFit=",pFit
        yFit = Cosmic.funcGauss(xFit,*pFit)
        plt.plot(xFit,yFit, label='Gaussian Fit')
        plt.legend()

        xLimit = dictionary['xLimit']
        plt.axvline(x=xLimit[0], color='magenta', linestyle='-.')
        plt.axvline(x=xLimit[1], color='magenta', linestyle='-.')
        plt.savefig(inspect.stack()[0][3]+".png")