19 from pylab
import figure
26 SAVE_DIR =
'/home/fxm-mb/Scripts/Tests/ResultsFmt' 28 colors = (
'b',
'r', 'y', 'g', 'm', 'c', 'k', )
32 with open(filename)
as fp:
33 for line
in fp.readlines():
35 if line.startswith(
'[')
and line.endswith(
']'):
36 newData.append(eval(line))
37 if DO_REVERSE: newData.reverse()
42 if len(newData) < len(oldData):
47 for lv
in range(minLen):
51 for idx, newVal
in enumerate(tmpNew):
52 errorVal = abs(newVal - tmpOld[idx])
55 jointErrors.append(errorVal)
56 allErrors.append(jointErrors)
57 if DO_REVERSE: allErrors.reverse()
61 errorCnt = len(errorData)
62 fig = figure(figsize=(16.0, 10.0))
65 if len(errorData[0]) > 7:
70 for idx
in range(len(errorData[0])):
73 positions.append(position)
75 fig.add_subplot(position).stem([elem[idx]
for elem
in errorData], linefmt=colors[colorIdx] +
'-', markerfmt= colors[colorIdx] +
'o', label=
'joint %d' % idx)
77 for position
in positions:
78 fig.add_subplot(position).set_xlabel(
'data set number')
79 fig.add_subplot(position).set_ylabel(
'abs. error in rad/s')
80 fig.add_subplot(position).set_title(strTitle)
81 fig.add_subplot(position).grid(
True)
82 fig.add_subplot(position).legend()
84 fig.subplots_adjust(wspace = 0.2, hspace = 0.5)
86 if SAVE_DIR
is not None:
87 fig.savefig(os.path.join(SAVE_DIR, strTitle.replace(
'.txt',
'') +
'.eps'))
93 errorData =
evalData(oldData, newData)
97 baseTestDir = os.path.join(baseDir, testDir)
98 if not os.path.exists(baseTestDir):
99 raise IOError(
'Could not find directory "%s"' % baseTestDir)
102 for root, dirs, files
in os.walk(baseTestDir):
104 if '_new_' in file.lower():
105 testResults.append((file, file.replace(
'_new_',
'_old_'), ))
107 if len(files) != len(testResults) * 2:
108 print(
'<<<< WARN >>>>: Could not process all files in dir %s. Expected %d files but found %d' % (dirs, len(testResults) * 2, len(files)))
110 for testResultNewOld
in testResults:
111 filepathNew = os.path.join(baseTestDir, testResultNewOld[0])
112 filepathOld = os.path.join(baseTestDir, testResultNewOld[1])
113 if not os.path.exists(filepathNew):
114 print(
'Could not find path "%s" -> Trying next files for comparison' % filepathNew)
116 if not os.path.exists(filepathOld):
117 print(
'Could not find path "%s" -> Trying next files for comparison' % filepathOld)
120 doEvaluation(filepathNew, filepathOld, testDir +
'_' + testResultNewOld[0].replace(
'_new_',
''))
123 if __name__ ==
'__main__':
124 baseDir =
"/home/fxm-mb/Scripts/Tests/" 125 for root, dirs, files
in os.walk(baseDir):
128 print(
'Evaluating files in dir %s' % testDir)
def evalData(oldData, newData)
def plotErrors(errorData, strTitle)
def getMeasData(filename)
def evaluateFiles(basedir, testdir)
def doEvaluation(filenameNew, filenameOld, titleText)