ATLAS Offline Software
parseDir.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
2 
3 
4 from fancyTab import *
5 
6 def findMin(path):
7  minimum=10000
8  epochWithMinimum=-1
9 
10  import os
11  command = "cp "+path+" ."
12  os.system(command)
13  os.system('source cleanFile.sh')
14 
15 
16  for line in file('chron.txt'):
17  line = line.split()
18  epoch = int(line[0])
19  trainingError = float(line[1])
20  testError = float(line[2])
21  if testError < minimum:
22  minimum = testError
23  epochWithMinimum = epoch
24 
25  return epochWithMinimum , minimum
26 
27 
28 
29 path="/afs/cern.ch/user/g/giacinto/scratch0/Athena/rel_2/InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NnClusteringCalibration/"
30 
31 test_table = []
32 
33 
34 import os
35 print ("-----------------------------------------------------------------------------------------------------------")
36 
37 print ("Now looking for the best current minimum of the training in directory: ")
38 print (path)
39 print ("-----------------------------------------------------------------------------------------------------------")
40 print (" ")
41 #print ("Network type | \t parameters | \t epoch | \t minimum ")
42 test_table.append(["Network Type", "Parameters", "Epoch", "Minimum"])
43 
44 for dir in [ "number", "positions" , "errors" ]:
45  wh = path+dir
46  listed = [ name for name in os.listdir(wh) if os.path.isdir(os.path.join(wh, name)) ]
47 
48  resDir = filter( lambda dirname: dirname[0]!="L" and dirname[0]!="." , listed)
49 
50  for weightsDir in resDir:
51  weightPath = wh+"/"+weightsDir
52  listedWeights = [ name for name in os.listdir(weightPath) if os.path.isdir(os.path.join(weightPath , name)) ]
53  filteredListW= filter( lambda dirname: dirname[0]!="L" and dirname[0]!="." , listedWeights)
54  for w in filteredListW:
55  chronFile = weightPath+"/"+w+"/trainingCronology.txt"
56  epochAtMin =-1
57  min =-1
58  if os.path.exists(chronFile):
59  epochAtMin , min = findMin(chronFile)
60  test_table.append([dir,weightsDir ,str(epochAtMin) ,str(min) ])
61 
62  test_table.append(["------------","---------------------" ,"------" ,"----------"])
63 
64 # print (dir+"\t"+weightsDir+"\t"+w+"\t"+str(epochAtMin)+"\t"+str(min))
65 # print (dir+" |\t| "+weightsDir+" \t \t "+str(epochAtMin)+" \t "+str(min))
66 
67 
68 print_table(test_table)
69 
70 
fancyTab.print_table
def print_table(rows)
Definition: fancyTab.py:43
covarianceTool.filter
filter
Definition: covarianceTool.py:514
file
TFile * file
Definition: tile_monitor.h:29
parseDir.findMin
def findMin(path)
Definition: parseDir.py:6
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
str
Definition: BTagTrackIpAccessor.cxx:11
python.LArMinBiasAlgConfig.float
float
Definition: LArMinBiasAlgConfig.py:65