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