Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions PythonTools/Boxcounter/README
Original file line number Diff line number Diff line change
@@ -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.
38 changes: 38 additions & 0 deletions PythonTools/Boxcounter/extractboxes.py
Original file line number Diff line number Diff line change
@@ -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)


9 changes: 9 additions & 0 deletions PythonTools/Boxcounter/processing.sh
Original file line number Diff line number Diff line change
@@ -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/ +/, /' ./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