source: trunk/anuga_work/development/mem_time_tests/scenarios/vel2/main.py @ 8328

Last change on this file since 8328 was 8328, checked in by pittj, 12 years ago

metalog and ex1 merge added, code is now correct across all major experiments

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1#------------------------------------------------------------------------------
2# Import necessary modules
3#------------------------------------------------------------------------------
4import anuga
5import subprocess
6import csv
7import os
8import time
9from anuga.abstract_2d_finite_volumes.util import add_directories
10from anuga.utilities.log_analyser import analyse_log
11
12#------------------------------------------------------------------------------
13# Set up variables for the correct directories to store the output
14#------------------------------------------------------------------------------
15home = os.getenv('INUNDATIONHOME')
16scenariodir = add_directories(home, ["data","mem_time_test", "scenarios",
17                                     "velocity"])
18file = 'ex1.csv'
19file_path = os.path.join(scenariodir, file)
20meta = 'metalog.csv'
21meta_path = os.path.join(scenariodir, meta)
22final = 'final.csv'
23final_path = os.path.join(scenariodir, final)
24store = 'store.txt'
25store_path = os.path.join(scenariodir, store)
26
27#set up needed files
28firstex1 = open(file_path, 'wb')
29spamWriter = csv.writer(firstex1)
30spamWriter.writerow(['Velocity(m/s)','Number Of Triangles','Extent(m^2)' , 'Time Taken(s)','Space Used'])
31storeopen = open(store_path,'a')
32storeopen.close
33
34# these are the main loops that give the velocity of inflow (m) and the map side length(n)
35for m in range(0,250,10):
36     for n in range(1,2000,300): 
37       
38        z = time.time() #time it
39        subprocess.call(['python2.5', 'ex1.py', str(m), str(n)])#run simulation script
40        y = time.time() #time it
41
42        # read the number of triangles from this text file
43        f = open(store_path,'r+')
44        h = float(f.readline())
45        f.close()
46       
47        spamWriter.writerow([m,h,(n*n),(y-z), 'b'])# record it
48print 'DONE' 
49
50analyse_log(scenariodir, os.path.join(scenariodir,'metalog.csv')) #get the memory usage from the log files
51
52#close ex1.csv so we can read from it for a different csv reader object
53firstex1.close()
54
55#merge the metalog useful memory info and the ex1 recorded info into one csv file named final
56ex1 = csv.reader(open(file_path,'rb'))
57metalog = csv.reader(open(meta_path,'rb'))
58final = csv.writer(open(final_path,'wb'))
59
60
61for row in ex1:
62    d = metalog.next()
63    final.writerow([row[0],row[1],d[0],d[3],d[6],d[9],d[12]])#,d[15],d[18]])
Note: See TracBrowser for help on using the repository browser.