Ejemplo n.º 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)
Ejemplo n.º 2
0
 def plotAxisToDataVectorPlot(self, plotName, xColumnName, yColumnName):
     print "plotAxisToDataVectorPlot", plotName, xColumnName, yColumnName
     xdataset = DatasetFactory.createFromObject(self.getColumn(xColumnName))
     xdataset.setName(xColumnName)
     ydataset = DatasetFactory.createFromObject(self.getColumn(yColumnName))
     ydataset.setName(yColumnName)
     if plotName is not None:
         Plotter.plot(plotName, xdataset, [ydataset])
 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)
Ejemplo n.º 4
0
	def plotResult(self, result):
		if self.plotPanel is not None:
			try:
				if Plotter is not None:
					#swing
					Plotter.plot(self.plotPanel, *result.makeplotdata)
				else:
					#rcp
					dnp.plot.clear(self.plotPanel)
					result.plot(name=self.plotPanel, title=self.plotPanel)
			except Exception, e:
				print "Could not plot two gaussian fit"
				print e.message
Ejemplo n.º 5
0
 def plotResult(self, result):
     if self.plotPanel is not None:
         try:
             if Plotter is not None:
                 #swing
                 Plotter.plot(self.plotPanel, *result.makeplotdata)
             else:
                 #rcp
                 dnp.plot.clear(self.plotPanel)
                 result.plot(name=self.plotPanel, title=self.plotPanel)
         except Exception, e:
             print "Could not plot two gaussian fit"
             print e.message
Ejemplo n.º 6
0
    def plotData(self):
        newHead = self.getDataNumbers()
        if self.arrayHead >= newHead:
            print "No new data added for plotting"
            return
        self.arrayHead = newHead

        #to get new data
        arrayEnergyPGM = self.energyPGM.cagetArrayDouble()
        arrayEnergyIDGAP = self.energyIDGAP.cagetArrayDouble()
        arrayChannel01 = self.channel01.cagetArrayDouble()
        arrayChannel02 = self.channel02.cagetArrayDouble()
        arrayChannel03 = self.channel03.cagetArrayDouble()
        arrayChannel04 = self.channel04.cagetArrayDouble()

        dataSetEnergyPGM = dnp.zeros([newHead])
        dataSetEnergyPGM.setName("PGM Energy")

        dataSetEnergyIDGAP = dnp.zeros([newHead])
        dataSetEnergyIDGAP.setName("ID Gap Energy")

        dataSetChannel01 = dnp.zeros([newHead])
        dataSetChannel01.setName("Channel 1")

        dataSetChannel02 = dnp.zeros([newHead])
        dataSetChannel02.setName("Channel 2")

        dataSetChannel03 = dnp.zeros([newHead])
        dataSetChannel03.setName("Channel 3")

        dataSetChannel04 = dnp.zeros([newHead])
        dataSetChannel04.setName("Channel 4")

        for i in range(0, newHead):
            #print i, arrayEnergyPGM[i], arrayEnergyIDGAP[i], arrayChannel01[i], arrayChannel02[i], arrayChannel03[i], arrayChannel04[i];
            dataSetEnergyPGM[i] = arrayEnergyPGM[i]
            dataSetEnergyIDGAP[i] = arrayEnergyIDGAP[i]
            dataSetChannel01[i] = arrayChannel01[i]
            dataSetChannel02[i] = arrayChannel02[i]
            dataSetChannel03[i] = arrayChannel03[i]
            dataSetChannel04[i] = arrayChannel04[i]
            #print i, arrayEnergyPGM[i], arrayEnergyIDGAP[i], arrayChannel01[i], arrayChannel02[i], arrayChannel03[i], arrayChannel04[i];

        dvp = Plotter()
        indexDataSet = dataSetEnergyPGM.getIndexDataSet()
        #dvp.plot("Data Vector", indexDataSet, [dataSetChannel01, dataSetChannel02, dataSetChannel03, dataSetChannel04]);
        dvp.plot("Fast Scan Panel", dataSetEnergyPGM, [
            dataSetChannel01, dataSetChannel02, dataSetChannel03,
            dataSetChannel04
        ])
Ejemplo n.º 7
0
def plot(filename, Overlay=True):
    '''Plot collected, rebinned MAC data on "MAC" Panel.
    
       syntax: plot(name,[True|False])
       
          where:
                name is the file name or file number
                True means clear old plot data from the graph (Default)
                False means plot over the exist data on the graph
                Negative file number refers to the past data collected relative to the current one (0). 
                        
          e.g.  plot(0)               --> plot current data just collected
                plot(-1)              --> plot the last data collected
                plot(1121)            --> plot data with file number 1121
                plot(0,False)         --> clear graph before plotting current data
        
    '''
    sfh = loadMacData(filename)
    print("Data plotting, please wait ...")
    if Overlay:
        Plotter.plotOver("MAC", sfh.getAxis(0), sfh.getAxis(1))
    else:
        Plotter.plot("MAC", sfh.getAxis(0), sfh.getAxis(1))
Ejemplo n.º 8
0
def plotdata(filename, dataType=MAC, plotPane="DataPlot", Overlay=True):
    '''Plot existing data on "MAC, PSD", or "SRS" (if any) Panel, the default is MAC data on DataPlot panel and overlay is True.
       
       syntax:
               plotdata(filename,[MAC|SRS|PSD],["MAC"|"Mythen"|"DataPlot"],[True|False])
       
               where:
                    filename: the filename string in quote. 
                
                    dataType: the input data types or formats available
		                MAC - plot MAC data on MAC panel
		                PSD - plot PSD data on Mythen panel
		                SRS - plot SRS data on SRS panel
		            
		            plotPane: the graph panel to display the plot
		        
		            Overlay:
                        'True': plot over the exist data on the graph (Default) 
                        'False': clear existing plot data from the graph before plotting new data
                         
    '''
    print("Data plotting to " + plotPane + " panel, please wait ...")
    if dataType == MAC:
        sfh = loadMacData(filename)
        dataset=sfh.getAxis(1)
        dataset.setName(filename)
        if Overlay:
            Plotter.plotOver(plotPane, sfh.getAxis(0), dataset)
        else:
            Plotter.plot(plotPane, sfh.getAxis(0), dataset)
    elif dataType == SRS:
        sfh = loadSRSData(filename)
        if Overlay:
            Plotter.plotOver(plotPane, sfh.getAxis(0), sfh.getAxis(1))
        else:
            Plotter.plot(plotPane, sfh.getAxis(0), sfh.getAxis(1))
    elif dataType == PSD:
        if not str(filename).find("mythen") == -1:
            # mythen data file
            dataset = loadMythenData(filename)
            data=dataset.getCountDataSet()
            data.setName(filename)
            if Overlay:
                Plotter.plotOver(plotPane, dataset.getAngleDataSet(), data)
            else:
                Plotter.plot(plotPane, dataset.getAngleDataSet(), data)
        else:
            parts = str(filename).split(File.separator)
            name=parts[-1]
            names=str(name).split(".")
            if representsInt(names[0]):
                # Mythen SRS file
                for each in loadMythenSRSFile(filename):
                    dataset = loadMythenData(str(each) + ".dat")
                    data=dataset.getCountDataSet()
                    data.setName(each)
                    if Overlay:
                        Plotter.plotOver(plotPane, dataset.getAngleDataSet(), data)
                    else:
                        Plotter.plot(plotPane, dataset.getAngleDataSet(), data)
            else:
                dataset = loadMythenData(filename)
                data=dataset.getCountDataSet()
                data.setName(filename)
                if Overlay:
                    Plotter.plotOver(plotPane, dataset.getAngleDataSet(), data)
                else:
                    Plotter.plot(plotPane, dataset.getAngleDataSet(), data)
    elif dataType == RAW:
            # mythen raw data file
            dataset = loadMythenRawData(filename)
            data=DoubleDataset(dataset.getCountArray(), dataset.getCountArray().length)
            channeldata=DoubleDataset(dataset.getChannelArray(),dataset.getChannelArray().length)
            data.setName(filename)
            if Overlay:
                Plotter.plotOver(plotPane, channeldata, data)
                SDAPlotter.addPlot(plotPane, "", channeldata, data, "delta", "counts")
            else:
                Plotter.plot(plotPane, channeldata, data)
                SDAPlotter.plot(plotPane, "", channeldata, data, "delta", "counts")
    else:
        print "Data Type is not recognised or supported."
    print "Plotting completed."