Skip to content

Commit 9fe60d0

Browse files
committed
add humidity plot
1 parent 3b61ad3 commit 9fe60d0

File tree

2 files changed

+113
-0
lines changed

2 files changed

+113
-0
lines changed
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# -*- coding: utf-8 -*-
2+
import AbstractClasses
3+
import ROOT
4+
import os
5+
import ConfigParser
6+
import AbstractClasses.Helper.helper as Helper
7+
import math
8+
import array
9+
from AbstractClasses.GeneralTestResult import GeneralTestResult
10+
11+
12+
class TestResult(GeneralTestResult):
13+
def CustomInit(self):
14+
self.Name = 'CMSPixel_QualificationGroup_Humidity_TestResult'
15+
self.NameSingle = 'Humidity'
16+
17+
self.Title = str(self.Attributes['ModuleID']) + ' ' + self.Attributes['StorageKey']
18+
self.Attributes['TestedObjectType'] = 'CMSPixel_Module'
19+
20+
def OpenFileHandle(self):
21+
pass
22+
23+
def analyseHum(self, fileName):
24+
print 'analyse Humidity for "%s"' % fileName
25+
name = fileName.split('/')[-1].split('.')[0]
26+
name.strip()
27+
if Helper.fileExists(fileName):
28+
this_file = open(fileName)
29+
lines = this_file.readlines()
30+
lines = [i for i in lines if not i.startswith('#')]
31+
tuples = [i.strip().split('\t') for i in lines]
32+
times = [int(i[0]) for i in tuples]
33+
temps = [float(i[1]) for i in tuples]
34+
if len(temps) > 0:
35+
temp = sum(temps) / len(temps)
36+
temp2 = sum([i * i for i in temps]) / len(temps)
37+
else:
38+
temp = 0
39+
temp2 = 0
40+
# tempMin = 0
41+
# tempMax = 0
42+
timeMin = 0
43+
timeMax = 0
44+
#
45+
# # get RMS Temp
46+
# tempError = math.sqrt(temp2 - temp * temp)
47+
# ROOT.TMath.RMS(tuple.GetSelectedRows(),tuple.GetV1())
48+
#
49+
if len(temps) > 0:
50+
# # get Min Temp
51+
tempMin = min(temps)
52+
# #get Max Temp
53+
tempMax = max(temps)
54+
#calculate time difference
55+
timeMin = min(times)
56+
timeMax = max(times)
57+
#
58+
# duration = timeMax - timeMin
59+
temp_List = array.array('d', temps)
60+
time_List = array.array('d', times)
61+
if not self.ResultData['Plot'].has_key('ROOTObjects'):
62+
self.ResultData['Plot']['ROOTObjects'] = {}
63+
# name = '%02d_%s' % (len(self.ResultData['Plot']['ROOTObjects']), name)
64+
if len(temps):
65+
graph = ROOT.TGraph(len(temp_List), time_List, temp_List)
66+
self.ResultData['Plot']['ROOTObject'] = ROOT.TMultiGraph()
67+
else:
68+
graph = ROOT.TGraph()
69+
70+
canvas = self.TestResultEnvironmentObject.Canvas
71+
self.CanvasSize(canvas)
72+
canvas.cd()
73+
74+
graph.SetTitle('')
75+
graph.Draw("APL")
76+
graph.SetLineColor(ROOT.kRed+1)
77+
graph.SetLineWidth(2)
78+
graph.SetMarkerSize(.2)
79+
graph.SetMarkerColor(ROOT.kRed)
80+
graph.SetMarkerStyle(8)
81+
82+
graph.GetXaxis().SetTitle("Time")
83+
graph.GetXaxis().SetTimeDisplay(1)
84+
graph.GetYaxis().SetTitle("Rel. Humidity [%]")
85+
86+
graph.GetYaxis().SetDecimals()
87+
graph.GetYaxis().SetTitleOffset(1.5)
88+
graph.GetYaxis().CenterTitle()
89+
graph.Draw("APL")
90+
canvas.Clear()
91+
if self.ResultData['Plot']['ROOTObject']:
92+
if graph:
93+
self.ResultData['Plot']['ROOTObject'].Add(graph, "L")
94+
self.ResultData['Plot']['ROOTObject'].Draw("a")
95+
self.ResultData['Plot']['ROOTObject'].SetTitle(';Time; RH [%]')
96+
self.ResultData['Plot']['ROOTObject'].GetXaxis().SetTimeDisplay(1)
97+
self.ResultData['Plot']['ROOTObject'].GetYaxis().SetDecimals()
98+
self.ResultData['Plot']['ROOTObject'].GetYaxis().SetTitleOffset(1.5)
99+
self.ResultData['Plot']['ROOTObject'].GetYaxis().CenterTitle()
100+
self.Canvas = canvas
101+
this_file.close()
102+
103+
def PopulateResultData(self):
104+
LogFileName = self.Attributes['LogFileName']
105+
if LogFileName is not None:
106+
print LogFileName
107+
self.analyseHum(LogFileName)
108+
109+
if self.verbose: raw_input('Press enter')
110+
self.ResultData['Plot']['Caption'] = 'Rel. Humidity'
111+
self.SaveCanvas()
112+
def CustomWriteToDatabase(self, ParentID):
113+
pass

Analyse/TestResultClasses/CMSPixel/QualificationGroup/Humidity/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)