예제 #1
0
 def save(self, collectionNumber=None):
     voltages=[]
     electrometers=[]
     if collectionNumber == None:
         filename = self.filename+"_"+self.getName()+".dat"
         print "concatenating data points to produce P-E data..."
         for each in self.voltages:
             voltages += each
             voltages += []
         for each in self.electrometers:
             electrometers += each
             electrometers += []
     else:
         filename = self.filename+"_"+self.getName()+"_"+str(collectionNumber)+".dat"
         print "summing data points to produce P-E data..."
         voltages = sum_datasets(self.voltages)
         electrometers = sum_datasets(self.electrometers)
     print "%s: saving data to %s" % (self.getName(), filename)
     if len(voltages) != len(electrometers):
         print "***Warning: voltage nord: %d, electrometer nord: %d" % (len(voltages),len(electrometers))
     self.file=open(filename, "w")
     for voltage, electrometer in zip(voltages, electrometers):
         self.file.write("%f\t%f\n"%(voltage, electrometer))
     self.file.close()
     print "%s: save data to %s completed." % (self.getName(), filename)
     voltagearray=scisoftpy.array(voltages)
     electrometerarray=scisoftpy.array(electrometers)
     vds=scisoftpy.toDS(voltagearray)
     eds=scisoftpy.toDS(electrometerarray)
     print "plotting PE-loop in 'DataPlot' panel..."
     if self.firstData:
         Plotter.plot("DataPlot", vds, eds)
         self.firstData=False
     else:
         Plotter.plotOver("DataPlot", vds, eds)
 def plotPEdata(self, *args, **kwargs):
         xarray=scisoftpy.array(kwargs[self.hv][args[0]])
         yrarray=scisoftpy.array(kwargs[self.el][args[0]])
         vds=scisoftpy.toDS(xarray)
         eds=scisoftpy.toDS(yrarray)
         print "plotting PE-loop in 'DataPlot' panel..."
         if self.firstData:
             Plotter.plot("DataPlot", vds, eds)
             self.firstData=False
         else:
             Plotter.plotOver("DataPlot", vds, eds)
예제 #3
0
	def _process(self,xDataSet, yDataSet):
		if yDataSet.max()-yDataSet.min() == 0:
			raise ValueError("There is no peak")
		xDataSet = np.Sciwrap(xDataSet) 
		yDataSet = np.Sciwrap(yDataSet) * self.scale
		funcs = [ holefunc ]
		initparams = [ xDataSet.mean(), (xDataSet.max() - xDataSet.min())* 0.90, yDataSet.min(), yDataSet.max()]
		
		fr = np.fit.fit(funcs, xDataSet, yDataSet, initparams, ptol=1e-4, optimizer='local')
		if self.plotPanel != None:
			fr.plot(self.plotPanel)

		initparams = [ p for p in fr.func.getParameterValues() ]
		
		start = initparams[0] - 0.5 * initparams[1]
		length = initparams[1]
	
		truncx = []
		truncy = []

		for i in range(xDataSet.size):
			val = xDataSet[i]
			if val >= start and val <= start+length:
				truncx.append(val)
				truncy.append(yDataSet[i])
				
		lala = Generic1DFitter.fitPeaks(np.toDS(np.array(truncx)), np.toDS(np.array(truncy)), Gaussian(1,1,1,1), NelderMead(self.accuracy), 2, self.gaussians, 0.05, True, False)
		print lala
		if lala == None or len(lala) == 0:
			print "no peaks found"
			return [0, []]
		positions = []
		cff = np.fit.fitcore.cfitfunc()
		for f in lala:
			print f.getParameter(1), f.getParameter(2)
			if f.getParameter(1).getValue() <= self.maxfwhm and f.getParameter(2).getValue() >= self.minarea:
				positions.append(f.getParameter(0).getValue())
				cff.addFunction(f)
			else:
				print "removed one"
		if len(positions) == 0:
			print "too bad nothing found within threshold"
		else:
			print "plotting remaining found positions"
			if self.plotPanel != None:
				fire = np.fit.fitcore.fitresult(cff, [np.toDS(np.array(truncx))], np.array(truncy))
				fire.plot(self.plotPanel)

		return [len(positions), positions]
예제 #4
0
    def _process(self, xDataSet, yDataSet):
        if yDataSet.max() - yDataSet.min() == 0:
            raise ValueError("There is no peak")
        xDataSet = np.Sciwrap(xDataSet)
        yDataSet = np.Sciwrap(yDataSet) * self.scale
        funcs = [holefunc]
        initparams = [
            xDataSet.mean(), (xDataSet.max() - xDataSet.min()) * 0.90,
            yDataSet.min(),
            yDataSet.max()
        ]

        fr = np.fit.fit(funcs,
                        xDataSet,
                        yDataSet,
                        initparams,
                        ptol=1e-4,
                        optimizer='local')
        if self.plotPanel != None:
            fr.plot(self.plotPanel)

        initparams = [p for p in fr.func.getParameterValues()]

        start = initparams[0] - 0.5 * initparams[1]
        length = initparams[1]

        truncx = []
        truncy = []

        for i in range(xDataSet.size):
            val = xDataSet[i]
            if val >= start and val <= start + length:
                truncx.append(val)
                truncy.append(yDataSet[i])

        lala = Generic1DFitter.fitPeaks(np.toDS(np.array(truncx)),
                                        np.toDS(np.array(truncy)),
                                        Gaussian(1, 1, 1, 1),
                                        NelderMead(self.accuracy), 2,
                                        self.gaussians, 0.05, True, False)
        print lala
        if lala == None or len(lala) == 0:
            print "no peaks found"
            return [0, []]
        positions = []
        cff = np.fit.fitcore.cfitfunc()
        for f in lala:
            print f.getParameter(1), f.getParameter(2)
            if f.getParameter(1).getValue() <= self.maxfwhm and f.getParameter(
                    2).getValue() >= self.minarea:
                positions.append(f.getParameter(0).getValue())
                cff.addFunction(f)
            else:
                print "removed one"
        if len(positions) == 0:
            print "too bad nothing found within threshold"
        else:
            print "plotting remaining found positions"
            if self.plotPanel != None:
                fire = np.fit.fitcore.fitresult(cff,
                                                [np.toDS(np.array(truncx))],
                                                np.array(truncy))
                fire.plot(self.plotPanel)

        return [len(positions), positions]