Exemplo n.º 1
0
    def remove_baseline(self,function="gaussian",redo=False):
        """
        Attempts to remove the baseline amplitude from the dynamic spectrum
        """
        if redo == False and self.baseline_removed == True:
            return self
        flatdata = self.data.flatten()
        interval = np.power(10,np.floor(np.log10(np.ptp(flatdata/100)))) #~100 divisions, but bins to an even power of 10
        center,hist = u.histogram(flatdata,interval=interval)

        if function == "gaussian":
            p1,err = ffit.gaussianfit(center,hist)
            y = ffit.funcgaussian(p1,center)
            peak = center[np.argmax(y)]
            
        elif function == "simple_DISS":
            area = np.trapz(hist,x=center)
            shift = -np.min(center)+1.0
            x = center + shift
            y = np.array(hist,dtype=np.float)/area
            p1,err = ffit.simpleDISSpdffit(x,y)
            y1 = ffit.funcsimpleDISSpdf(p1,x)*area
            peak = center[np.argmax(y1)]
        else:
            peak = 0.0

        self.data -= peak
        self.baseline_removed = True
        return self
Exemplo n.º 2
0
    def remove_baseline(self, function="gaussian", redo=False):
        """
        Attempts to remove the baseline amplitude from the dynamic spectrum
        """
        if redo == False and self.baseline_removed == True:
            return self
        flatdata = self.data.flatten()
        interval = np.power(10, np.floor(np.log10(
            np.ptp(flatdata /
                   100))))  #~100 divisions, but bins to an even power of 10
        center, hist = u.histogram(flatdata, interval=interval)

        if function == "gaussian":
            p1, err = ffit.gaussianfit(center, hist)
            y = ffit.funcgaussian(p1, center)
            peak = center[np.argmax(y)]

        elif function == "simple_DISS":
            area = np.trapz(hist, x=center)
            shift = -np.min(center) + 1.0
            x = center + shift
            y = np.array(hist, dtype=np.float) / area
            p1, err = ffit.simpleDISSpdffit(x, y)
            y1 = ffit.funcsimpleDISSpdf(p1, x) * area
            peak = center[np.argmax(y1)]
        else:
            peak = 0.0

        self.data -= peak
        self.baseline_removed = True
        return self