diff --git a/PythonTools/Boxcounter/README b/PythonTools/Boxcounter/README new file mode 100644 index 0000000..de64d7f --- /dev/null +++ b/PythonTools/Boxcounter/README @@ -0,0 +1,3 @@ +The bash script processing.sh takes a pout.0 from a run and parses it so that it is in a format that reads 'level, time, boxes on this proc, total boxes'. Run using './processing.sh' in the same directory as the pout.0 and it outputs pout.0_parsed + +This pout.0_parsed can then be processed by running 'python extractboxes.py' to plot the total number of boxes per refinement level. Must manually set max refinement level to plot in L16. Outputs a graph for each level i which includes all levels < i, easily modifiable. \ No newline at end of file diff --git a/PythonTools/Boxcounter/extractboxes.py b/PythonTools/Boxcounter/extractboxes.py new file mode 100644 index 0000000..7360183 --- /dev/null +++ b/PythonTools/Boxcounter/extractboxes.py @@ -0,0 +1,38 @@ +import csv +import matplotlib.pyplot as plt + +'''Run processing.sh with pout.0 - outputs level, time, boxes on proc 0, total boxes''' +'''Only works on output with verbosity 0''' + +i=0 + +data = open('pout.0_parsed') +with data as csvfile: + filereader = csv.reader(csvfile, delimiter=',') + timelist = [] #col 1 + totalboxlist = [] #col 3 + + '''Hardcoded max level to plot''' + while i < 10: + for row in filereader: + if int(row[0]) == i: + '''Can input max time''' + # if float(row[1]) < 300: + timelist.append(float(row[1])) + totalboxlist.append(int(row[3])) + + plt.plot(timelist, totalboxlist, label='%s' % i) + plt.legend() + plt.savefig('boxplot_level_%s.png' % i) + + timelist.clear() + totalboxlist.clear() + + '''Resets file loop''' + data.seek(0) + + i+=1 + + print('%s' % i) + + diff --git a/PythonTools/Boxcounter/processing.sh b/PythonTools/Boxcounter/processing.sh new file mode 100755 index 0000000..d139224 --- /dev/null +++ b/PythonTools/Boxcounter/processing.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +sed -n '/GRAMRLevel::/,$p' ./pout.0 > ./pout.0_temp +sed -e 's!GRAMRLevel::advance level !!' ./pout.0_temp > ./pout.0_temp2 +sed -r 's/\s+/, /' ./pout.0_temp2 > ./pout.0_temp +sed -e 's!at time !!' ./pout.0_temp > ./pout.0_temp2 +sed -e 's/ (.*:/,/' ./pout.0_temp2 > ./pout.0_temp +sed -e 's/ \//,/' ./pout.0_temp > ./pout.0_parsed +rm ./pout.0_temp ./pout.0_temp2 diff --git a/PythonTools/extractboxes.py b/PythonTools/extractboxes.py new file mode 100644 index 0000000..7360183 --- /dev/null +++ b/PythonTools/extractboxes.py @@ -0,0 +1,38 @@ +import csv +import matplotlib.pyplot as plt + +'''Run processing.sh with pout.0 - outputs level, time, boxes on proc 0, total boxes''' +'''Only works on output with verbosity 0''' + +i=0 + +data = open('pout.0_parsed') +with data as csvfile: + filereader = csv.reader(csvfile, delimiter=',') + timelist = [] #col 1 + totalboxlist = [] #col 3 + + '''Hardcoded max level to plot''' + while i < 10: + for row in filereader: + if int(row[0]) == i: + '''Can input max time''' + # if float(row[1]) < 300: + timelist.append(float(row[1])) + totalboxlist.append(int(row[3])) + + plt.plot(timelist, totalboxlist, label='%s' % i) + plt.legend() + plt.savefig('boxplot_level_%s.png' % i) + + timelist.clear() + totalboxlist.clear() + + '''Resets file loop''' + data.seek(0) + + i+=1 + + print('%s' % i) + + diff --git a/PythonTools/processing.sh b/PythonTools/processing.sh new file mode 100755 index 0000000..d139224 --- /dev/null +++ b/PythonTools/processing.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +sed -n '/GRAMRLevel::/,$p' ./pout.0 > ./pout.0_temp +sed -e 's!GRAMRLevel::advance level !!' ./pout.0_temp > ./pout.0_temp2 +sed -r 's/\s+/, /' ./pout.0_temp2 > ./pout.0_temp +sed -e 's!at time !!' ./pout.0_temp > ./pout.0_temp2 +sed -e 's/ (.*:/,/' ./pout.0_temp2 > ./pout.0_temp +sed -e 's/ \//,/' ./pout.0_temp > ./pout.0_parsed +rm ./pout.0_temp ./pout.0_temp2