Exemplo n.º 1
0
    def analyseTemp(self, fileName):
        print 'analyse Temp for "%s"' % fileName
        # duration = 0
        # temp = 0
        # tempError = 0
        # tempMin = 0
        # tempMax = 0
        # timeMin = 0
        # timeMax = 0
        name = fileName.split('/')[-1].split('.')[0]
        name.strip()
        # varlist = 'time:temp'
        if Helper.fileExists(fileName):
            this_file = open(fileName)
            lines = this_file.readlines()
            lines = [i for i in lines if not i.startswith('#')]
            tuples = [i.strip().split('\t') for i in lines]
            times = [int(i[0]) for i in tuples]
            temps = [float(i[1]) for i in tuples]
            if len(temps) > 0:
                temp = sum(temps) / len(temps)
                temp2 = sum([i * i for i in temps]) / len(temps)
            else:
                temp = 0
                temp2 = 0
                # tempMin = 0
                # tempMax = 0
                timeMin = 0
                timeMax = 0
            #
            # # get RMS Temp
            # tempError = math.sqrt(temp2 - temp * temp)
            # ROOT.TMath.RMS(tuple.GetSelectedRows(),tuple.GetV1())
            #
            if len(temps) > 0:
                #             # get Min Temp
                tempMin = min(temps)
                #             #get Max Temp
                tempMax = max(temps)
                #calculate time difference
                timeMin = min(times)
                timeMax = max(times)
            #
            # duration = timeMax - timeMin
            temp_List = array.array('d', temps)
            time_List = array.array('d', times)
            if not self.ResultData['Plot'].has_key('ROOTObjects'):
                self.ResultData['Plot']['ROOTObjects'] = {}
            # name = '%02d_%s' % (len(self.ResultData['Plot']['ROOTObjects']), name)
            if len(temps):
                graph = ROOT.TGraph(len(temp_List), time_List, temp_List)
                self.ResultData['Plot']['ROOTObject'] = ROOT.TMultiGraph()
            else:
                graph = ROOT.TGraph()

            canvas = self.TestResultEnvironmentObject.Canvas
            self.CanvasSize(canvas)
            canvas.cd()

            graph.SetTitle('')
            graph.Draw("APL")
            graph.SetLineColor(4)
            graph.SetLineWidth(2)
            graph.SetMarkerSize(.2)
            graph.SetMarkerColor(1)
            graph.SetMarkerStyle(8)

            graph.GetXaxis().SetTitle("Time")
            graph.GetXaxis().SetTimeDisplay(1)
            graph.GetYaxis().SetTitle("Temperature [#circ C]")

            graph.GetYaxis().SetDecimals()
            graph.GetYaxis().SetTitleOffset(1.5)
            graph.GetYaxis().CenterTitle()
            graph.Draw("APL")
            canvas.Clear()
            if self.ResultData['Plot']['ROOTObject']:
                if graph:
                    self.ResultData['Plot']['ROOTObject'].Add(graph, "L")
                self.ResultData['Plot']['ROOTObject'].Draw("a")
                self.ResultData['Plot']['ROOTObject'].SetTitle(';Time; Temp [#circ C]')
                self.ResultData['Plot']['ROOTObject'].GetXaxis().SetTimeDisplay(1)
                self.ResultData['Plot']['ROOTObject'].GetYaxis().SetDecimals()
                self.ResultData['Plot']['ROOTObject'].GetYaxis().SetTitleOffset(1.5)
                self.ResultData['Plot']['ROOTObject'].GetYaxis().CenterTitle()
            self.Canvas = canvas
Exemplo n.º 2
0
    def analyseHum(self, fileName):
        print 'analyse Humidity for "%s"' % fileName
        name = fileName.split('/')[-1].split('.')[0]
        name.strip()
        if Helper.fileExists(fileName):
            this_file = open(fileName)
            lines = this_file.readlines()
            lines = [i for i in lines if not i.startswith('#')]
            tuples = [i.strip().split('\t') for i in lines]
            times = [int(i[0]) for i in tuples]
            temps = [float(i[1]) for i in tuples]
            if len(temps) > 0:
                temp = sum(temps) / len(temps)
                temp2 = sum([i * i for i in temps]) / len(temps)
            else:
                temp = 0
                temp2 = 0
                # tempMin = 0
                # tempMax = 0
                timeMin = 0
                timeMax = 0
            #
            # # get RMS Temp
            # tempError = math.sqrt(temp2 - temp * temp)
            # ROOT.TMath.RMS(tuple.GetSelectedRows(),tuple.GetV1())
            #
            if len(temps) > 0:
                #             # get Min Temp
                tempMin = min(temps)
                #             #get Max Temp
                tempMax = max(temps)
                #calculate time difference
                timeMin = min(times)
                timeMax = max(times)
            #
            # duration = timeMax - timeMin
            temp_List = array.array('d', temps)
            time_List = array.array('d', times)
            if not self.ResultData['Plot'].has_key('ROOTObjects'):
                self.ResultData['Plot']['ROOTObjects'] = {}
            # name = '%02d_%s' % (len(self.ResultData['Plot']['ROOTObjects']), name)
            if len(temps):
                graph = ROOT.TGraph(len(temp_List), time_List, temp_List)
                self.ResultData['Plot']['ROOTObject'] = ROOT.TMultiGraph()
            else:
                graph = ROOT.TGraph()

            canvas = self.TestResultEnvironmentObject.Canvas
            self.CanvasSize(canvas)
            canvas.cd()

            graph.SetTitle('')
            graph.Draw("APL")
            graph.SetLineColor(ROOT.kRed + 1)
            graph.SetLineWidth(2)
            graph.SetMarkerSize(.2)
            graph.SetMarkerColor(ROOT.kRed)
            graph.SetMarkerStyle(8)

            graph.GetXaxis().SetTitle("Time")
            graph.GetXaxis().SetTimeDisplay(1)
            graph.GetYaxis().SetTitle("Rel. Humidity [%]")

            graph.GetYaxis().SetDecimals()
            graph.GetYaxis().SetTitleOffset(1.5)
            graph.GetYaxis().CenterTitle()
            graph.Draw("APL")
            canvas.Clear()
            if self.ResultData['Plot']['ROOTObject']:
                if graph:
                    self.ResultData['Plot']['ROOTObject'].Add(graph, "L")
                self.ResultData['Plot']['ROOTObject'].Draw("a")
                self.ResultData['Plot']['ROOTObject'].SetTitle(';Time; RH [%]')
                self.ResultData['Plot']['ROOTObject'].GetXaxis(
                ).SetTimeDisplay(1)
                self.ResultData['Plot']['ROOTObject'].GetYaxis().SetDecimals()
                self.ResultData['Plot']['ROOTObject'].GetYaxis(
                ).SetTitleOffset(1.5)
                self.ResultData['Plot']['ROOTObject'].GetYaxis().CenterTitle()
            self.Canvas = canvas
            this_file.close()
Exemplo n.º 3
0
    def analyseTemp(self, fileName):
        print 'analyse Temp for "%s"' % fileName
        duration = 0
        temp = 0
        tempError = 0
        tempMin = 0
        tempMax = 0
        timeMin = 0
        timeMax = 0
        name = fileName.split("/")[-1].split(".")[0]
        name.strip()
        # varlist = 'time:temp'
        if not self.ResultData["Plot"].has_key("ObjectCanvas"):
            self.ResultData["Plot"]["ObjectCanvas"] = {}
        if Helper.fileExists(fileName):
            this_file = open(fileName)
            lines = this_file.readlines()
            lines = [i for i in lines if not i.startswith("#")]
            tuples = [i.strip().split("\t") for i in lines]
            times = [int(i[0]) for i in tuples]
            temps = [float(i[1]) for i in tuples]
            if len(temps) > 0:
                temp = sum(temps) / len(temps)
                temp2 = sum([i * i for i in temps]) / len(temps)
            else:
                temp = 0
                temp2 = 0
                tempMin = 0
                tempMax = 0
                timeMin = 0
                timeMax = 0
            #
            # # get RMS Temp
            tempError = math.sqrt(temp2 - temp * temp)
            # ROOT.TMath.RMS(tuple.GetSelectedRows(),tuple.GetV1())
            #
            if len(temps) > 0:
                # # get Min Temp
                tempMin = min(temps)
                # #get Max Temp
                tempMax = max(temps)
                # calculate time difference
                timeMin = min(times)
                timeMax = max(times)
            #
            duration = timeMax - timeMin
            temp_List = array.array("d", temps)
            time_List = array.array("d", times)
            if not self.ResultData["Plot"].has_key("ROOTObjects"):
                self.ResultData["Plot"]["ROOTObjects"] = {}
            name = "%02d_%s" % (len(self.ResultData["Plot"]["ROOTObjects"]), name)
            if len(temps):
                graph = ROOT.TGraph(len(temp_List), time_List, temp_List)
                self.ResultData["Plot"]["ROOTObjects"][name] = ROOT.TMultiGraph()
            else:
                graph = ROOT.TGraph()
                self.ResultData["Plot"]["ROOTObjects"][name] = ROOT.TGraph()

            canvas = self.TestResultEnvironmentObject.Canvas
            self.CanvasSize(canvas)
            canvas.cd()

            graph.SetTitle("")
            graph.Draw("APL")
            graph.SetLineColor(4)
            graph.SetLineWidth(2)

            graph.GetXaxis().SetTitle("Time")
            graph.GetXaxis().SetTimeDisplay(1)
            graph.GetYaxis().SetTitle("Temperature [#circ C]")

            graph.GetYaxis().SetDecimals()
            graph.GetYaxis().SetTitleOffset(1.5)
            graph.GetYaxis().CenterTitle()
            graph.Draw("APL")
            # print self.ParentObject.Attributes['TestTemperature']
            setPoint = self.ParentObject.Attributes["TestTemperature"]

            if len(temps):
                avrgGraph = ROOT.TGraphErrors(2)
                avrgGraph.SetTitle("")
                avrgGraph.SetLineColor(ROOT.kRed)
                avrgGraph.SetLineWidth(2)
                avrgGraph.SetPoint(0, timeMin, temp)
                avrgGraph.SetPoint(1, timeMax, temp)
                avrgGraph.SetPointError(0, 0, tempError)
                avrgGraph.SetPointError(1, 0, tempError)
                avrgGraph.SetFillColor(ROOT.kRed)
                avrgGraph.SetFillStyle(0)
                setPointGraph = ROOT.TGraphErrors(2)
                setPointGraph.SetTitle("")
                setPointGraph.SetLineColor(ROOT.kBlack)
                setPointGraph.SetLineWidth(2)
                setPointGraph.SetPoint(0, timeMin, setPoint)
                setPointGraph.SetPoint(1, timeMax, setPoint)
                setPointGraph.SetPointError(0, 0, 0.5)
                setPointGraph.SetPointError(1, 0, 0.5)
                setPointGraph.SetFillColor(ROOT.kGreen)
                setPointGraph.SetFillStyle(0)
                self.ResultData["Plot"]["ROOTObjects"][name].Add(setPointGraph, "3L")
                self.ResultData["Plot"]["ROOTObjects"][name].Add(avrgGraph, "3L")
                self.ResultData["Plot"]["ROOTObjects"][name].Add(graph, "L")
                self.ResultData["Plot"]["ROOTObjects"][name].Draw("a")
                self.ResultData["Plot"]["ROOTObjects"][name].SetTitle(";Time; Temp [#circ C]")
                self.ResultData["Plot"]["ROOTObjects"][name].GetXaxis().SetTimeDisplay(1)
                self.ResultData["Plot"]["ROOTObjects"][name].GetYaxis().SetDecimals()
                self.ResultData["Plot"]["ROOTObjects"][name].GetYaxis().SetTitleOffset(1.5)
                self.ResultData["Plot"]["ROOTObjects"][name].GetYaxis().CenterTitle()

            self.ResultData["Plot"]["ObjectCanvas"][name] = canvas

            # tuple.Draw("time:temp","","APL")
            # get
        # print 'Analysed "%s"' % fileName
        # print 'Temp: %2.2f +/- %2.2f °C, Min: %2.2f, Max %2.2f' % (temp, tempError, tempMin, tempMax)
        # print 'duration: %s - %s, %s, %s' % (
        #    str(datetime.timedelta(seconds=duration)), timeMax - timeMin, timeMax, timeMin)
        return duration, temp, tempError, tempMin, tempMax
Exemplo n.º 4
0
    def analyseTemp(self, fileName):
        print 'analyse Temp for "%s"' % fileName
        duration = 0
        temp = 0
        tempError = 0
        tempMin = 0
        tempMax = 0
        timeMin = 0
        timeMax = 0
        name = fileName.split('/')[-1].split('.')[0]
        name.strip()
        # varlist = 'time:temp'
        if not self.ResultData['Plot'].has_key('ObjectCanvas'):
            self.ResultData['Plot']['ObjectCanvas'] = {}
        if Helper.fileExists(fileName):
            this_file = open(fileName)
            lines = this_file.readlines()
            lines = [i for i in lines if not i.startswith('#')]
            tuples = [i.strip().split('\t') for i in lines]
            times = [int(i[0]) for i in tuples]
            temps = [float(i[1]) for i in tuples]
            if len(temps) > 0:
                temp = sum(temps) / len(temps)
                temp2 = sum([i * i for i in temps]) / len(temps)
            else:
                temp = 0
                temp2 = 0
                tempMin = 0
                tempMax = 0
                timeMin = 0
                timeMax = 0
            #
            # # get RMS Temp
            tempError = math.sqrt(temp2 - temp * temp)
            # ROOT.TMath.RMS(tuple.GetSelectedRows(),tuple.GetV1())
            #
            if len(temps) > 0:
                # # get Min Temp
                tempMin = min(temps)
                # #get Max Temp
                tempMax = max(temps)
                # calculate time difference
                timeMin = min(times)
                timeMax = max(times)
            #
            duration = timeMax - timeMin
            temp_List = array.array('d', temps)
            time_List = array.array('d', times)
            if not self.ResultData['Plot'].has_key('ROOTObjects'):
                self.ResultData['Plot']['ROOTObjects'] = {}
            name = '%02d_%s' % (len(
                self.ResultData['Plot']['ROOTObjects']), name)
            if len(temps):
                graph = ROOT.TGraph(len(temp_List), time_List, temp_List)
                self.ResultData['Plot']['ROOTObjects'][
                    name] = ROOT.TMultiGraph()
            else:
                graph = ROOT.TGraph()
                self.ResultData['Plot']['ROOTObjects'][name] = ROOT.TGraph()

            canvas = self.TestResultEnvironmentObject.Canvas
            self.CanvasSize(canvas)
            canvas.cd()

            graph.SetTitle('')
            graph.Draw("APL")
            graph.SetLineColor(4)
            graph.SetLineWidth(2)

            graph.GetXaxis().SetTitle("Time")
            graph.GetXaxis().SetTimeDisplay(1)
            graph.GetYaxis().SetTitle("Temperature [#circ C]")

            graph.GetYaxis().SetDecimals()
            graph.GetYaxis().SetTitleOffset(1.5)
            graph.GetYaxis().CenterTitle()
            graph.Draw("APL")
            #print self.ParentObject.Attributes['TestTemperature']
            setPoint = \
                self.ParentObject.Attributes['TestTemperature']

            if len(temps):
                avrgGraph = ROOT.TGraphErrors(2)
                avrgGraph.SetTitle('')
                avrgGraph.SetLineColor(ROOT.kRed)
                avrgGraph.SetLineWidth(2)
                avrgGraph.SetPoint(0, timeMin, temp)
                avrgGraph.SetPoint(1, timeMax, temp)
                avrgGraph.SetPointError(0, 0, tempError)
                avrgGraph.SetPointError(1, 0, tempError)
                avrgGraph.SetFillColor(ROOT.kRed)
                avrgGraph.SetFillStyle(0)
                setPointGraph = ROOT.TGraphErrors(2)
                setPointGraph.SetTitle('')
                setPointGraph.SetLineColor(ROOT.kBlack)
                setPointGraph.SetLineWidth(2)
                setPointGraph.SetPoint(0, timeMin, setPoint)
                setPointGraph.SetPoint(1, timeMax, setPoint)
                setPointGraph.SetPointError(0, 0, .5)
                setPointGraph.SetPointError(1, 0, .5)
                setPointGraph.SetFillColor(ROOT.kGreen)
                setPointGraph.SetFillStyle(0)
                self.ResultData['Plot']['ROOTObjects'][name].Add(
                    setPointGraph, '3L')
                self.ResultData['Plot']['ROOTObjects'][name].Add(
                    avrgGraph, '3L')
                self.ResultData['Plot']['ROOTObjects'][name].Add(graph, "L")
                self.ResultData['Plot']['ROOTObjects'][name].Draw("a")
                self.ResultData['Plot']['ROOTObjects'][name].SetTitle(
                    ';Time; Temp [#circ C]')
                self.ResultData['Plot']['ROOTObjects'][name].GetXaxis(
                ).SetTimeDisplay(1)
                self.ResultData['Plot']['ROOTObjects'][name].GetYaxis(
                ).SetDecimals()
                self.ResultData['Plot']['ROOTObjects'][name].GetYaxis(
                ).SetTitleOffset(1.5)
                self.ResultData['Plot']['ROOTObjects'][name].GetYaxis(
                ).CenterTitle()

            self.ResultData['Plot']['ObjectCanvas'][name] = canvas

            # tuple.Draw("time:temp","","APL")
            # get
        #print 'Analysed "%s"' % fileName
        #print 'Temp: %2.2f +/- %2.2f °C, Min: %2.2f, Max %2.2f' % (temp, tempError, tempMin, tempMax)
        #print 'duration: %s - %s, %s, %s' % (
        #    str(datetime.timedelta(seconds=duration)), timeMax - timeMin, timeMax, timeMin)
        return duration, temp, tempError, tempMin, tempMax