From be11c0f8c972f7cbbebdf3bf37c797f6ebabba01 Mon Sep 17 00:00:00 2001 From: Amelia Drew Date: Mon, 17 May 2021 13:16:57 +0100 Subject: [PATCH 1/4] Add MPI box count tools --- PythonTools/extractboxes.py | 38 +++++++++++++++++++++++++++++++++++++ PythonTools/processing.sh | 9 +++++++++ 2 files changed, 47 insertions(+) create mode 100644 PythonTools/extractboxes.py create mode 100755 PythonTools/processing.sh diff --git a/PythonTools/extractboxes.py b/PythonTools/extractboxes.py new file mode 100644 index 0000000..30c7996 --- /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..eb858ba --- /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 -e 's/\(.\{1\}\)/\1,/' ./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 From 5d6a11b1a7956b98d83bd9a0380cda1054478ff3 Mon Sep 17 00:00:00 2001 From: Amelia Drew Date: Mon, 17 May 2021 13:26:06 +0100 Subject: [PATCH 2/4] Minor typo --- PythonTools/extractboxes.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/PythonTools/extractboxes.py b/PythonTools/extractboxes.py index 30c7996..7360183 100644 --- a/PythonTools/extractboxes.py +++ b/PythonTools/extractboxes.py @@ -17,9 +17,9 @@ 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])) + # if float(row[1]) < 300: + timelist.append(float(row[1])) + totalboxlist.append(int(row[3])) plt.plot(timelist, totalboxlist, label='%s' % i) plt.legend() From 2dc6d6b6ea9d2a8d8c8bc6c8184b66161d7ac5ac Mon Sep 17 00:00:00 2001 From: Amelia Drew Date: Wed, 2 Jun 2021 16:44:15 +0100 Subject: [PATCH 3/4] Fixed typo in processing.sh so that any number of levels is read correctly. Put into directory Boxcounter with README --- PythonTools/Boxcounter/README | 3 ++ PythonTools/Boxcounter/extractboxes.py | 38 ++++++++++++++++++++++++++ PythonTools/Boxcounter/processing.sh | 9 ++++++ PythonTools/processing.sh | 2 +- 4 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 PythonTools/Boxcounter/README create mode 100644 PythonTools/Boxcounter/extractboxes.py create mode 100755 PythonTools/Boxcounter/processing.sh 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/processing.sh b/PythonTools/processing.sh index eb858ba..d139224 100755 --- a/PythonTools/processing.sh +++ b/PythonTools/processing.sh @@ -2,7 +2,7 @@ sed -n '/GRAMRLevel::/,$p' ./pout.0 > ./pout.0_temp sed -e 's!GRAMRLevel::advance level !!' ./pout.0_temp > ./pout.0_temp2 -sed -e 's/\(.\{1\}\)/\1,/' ./pout.0_temp2 > ./pout.0_temp +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 From 1b88d469049970c030f0c57a30ea9aebbec5915c Mon Sep 17 00:00:00 2001 From: Amelia Drew Date: Thu, 10 Jun 2021 14:36:43 +0100 Subject: [PATCH 4/4] Fixed typo to add comma in pout.0_parsed and removed old scripts from PythonTools/ so just in PythonTools/Boxcounter --- PythonTools/Boxcounter/processing.sh | 2 +- PythonTools/extractboxes.py | 38 ---------------------------- PythonTools/processing.sh | 9 ------- 3 files changed, 1 insertion(+), 48 deletions(-) delete mode 100644 PythonTools/extractboxes.py delete mode 100755 PythonTools/processing.sh diff --git a/PythonTools/Boxcounter/processing.sh b/PythonTools/Boxcounter/processing.sh index d139224..1f9fa06 100755 --- a/PythonTools/Boxcounter/processing.sh +++ b/PythonTools/Boxcounter/processing.sh @@ -2,7 +2,7 @@ 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 -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 diff --git a/PythonTools/extractboxes.py b/PythonTools/extractboxes.py deleted file mode 100644 index 7360183..0000000 --- a/PythonTools/extractboxes.py +++ /dev/null @@ -1,38 +0,0 @@ -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 deleted file mode 100755 index d139224..0000000 --- a/PythonTools/processing.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/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