source: trunk/anuga_work/development/mem_time_tests/parameters/nothing/main.py @ 9334

Last change on this file since 9334 was 8427, checked in by davies, 13 years ago

Adding the trapezoidal channel validation test, and editing the ANUGA manual

File size: 2.9 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import anuga
5import time
6import subprocess
7import csv
8import os
9from anuga.utilities import system_tools, log
10from anuga.abstract_2d_finite_volumes.util import add_directories
11from anuga.utilities.log_analyser import analyse_log
12
13#--------------------------------------------------------------------------------------
14# Set up variables for the correct directories to store the output
15#--------------------------------------------------------------------------------------
16home = os.getenv('INUNDATIONHOME')
17scenariodir = add_directories(home, ["data","mem_time_test", "parameters","nothing"])
18meta = 'metalog.csv'
19meta_path = os.path.join(scenariodir, meta)
20final = 'final.csv'
21final_path = os.path.join(scenariodir, final)
22
23#main loop, that stores the current run number so that unique folders exist for the information
24for n in range(0,100,1):
25    subprocess.call(['python2.5', 'ex1.py' ,str(n)]) #run script
26print "DONE"
27
28#get the important data for the experiments from the anuga experiments
29analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) 
30
31#open files to read from and write to
32metalog = csv.reader(open(meta_path,'rb'))
33final = csv.writer(open(final_path,'wb'))
34
35#list stores the index of the values requird
36indexlist = []
37
38#read in the first row
39firstrow = metalog.next()
40
41#get the indices of the values we want, so that the data can be condensed
42indexlist.append(firstrow.index("beforetime"))
43indexlist.append(firstrow.index("aftertime"))
44indexlist.append(firstrow.index("aftermeshtime"))
45indexlist.append(firstrow.index("beforesimulationmemory"))
46indexlist.append(firstrow.index("aftermeshmemory"))
47indexlist.append(firstrow.index("afterinitialconditionsmemory"))
48indexlist.append(firstrow.index("afterboundarymemory"))
49indexlist.append(firstrow.index("aftersimulationmemory"))
50indexlist.append(firstrow.index("runnumber"))
51
52#write the header for the final csv
53final.writerow(["TimeTaken(s)","MeshTime(s)",
54                firstrow[(indexlist[3])],firstrow[(indexlist[4])],
55                firstrow[(indexlist[5])],firstrow[(indexlist[6])],
56                firstrow[(indexlist[7])],firstrow[(indexlist[8])]])
57
58#write the data for each column in the final csv
59for row in metalog:
60
61    #manipulate the beginning and end time to get the time taken
62    begin = time.strptime(row[(indexlist[0])],'%Y%m%d_%H%M%S')
63    end = time.strptime(row[(indexlist[1])],'%Y%m%d_%H%M%S')
64    mesh = time.strptime(row[(indexlist[2])],'%Y%m%d_%H%M%S')
65    taken = time.mktime(end) - time.mktime(begin)
66    meshtime = time.mktime(mesh) - time.mktime(begin)
67
68    #write to file
69    final.writerow([str(taken),str(meshtime),
70                    row[(indexlist[3])],row[(indexlist[4])],
71                    row[(indexlist[5])],row[(indexlist[6])],
72                    row[(indexlist[7])],row[(indexlist[8])]])
73
Note: See TracBrowser for help on using the repository browser.