Skip to content

Commit 0b7e3c5

Browse files
author
Daniel Ruprecht
committed
saved_iteration and steps_vs_iteration now in beautified pdf and correct size
1 parent e8e982e commit 0b7e3c5

8 files changed

+35
-28
lines changed
-96.3 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

examples/fault_tolerance/heatmaps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
axis_font = {'fontname':'Arial', 'size':'8', 'family':'serif'}
77
fs = 8
88

9-
# setup = 'HEAT'
10-
setup = 'ADVECTION'
9+
setup = 'HEAT'
10+
#setup = 'ADVECTION'
1111
fields = [(setup+'_results_hf_SPREAD.npz','SPREAD'),
1212
(setup+'_results_hf_INTERP.npz','INTERP'),
1313
(setup+'_results_hf_INTERP_PREDICT.npz','INTERP_PREDICT'),

examples/fault_tolerance/postproc_grayscott.py

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import numpy as np
22
import math
33
import os
4-
from matplotlib import rc
54
import matplotlib.pyplot as plt
5+
from pylab import rcParams
66

7+
axis_font = {'fontname':'Arial', 'size':'8', 'family':'serif'}
8+
fs = 8
9+
ms = 8
10+
lw = 2
711

812
if __name__ == "__main__":
913

10-
rc('font', family='sans-serif',size=30)
11-
rc('legend', fontsize='small')
12-
rc('xtick', labelsize='small')
13-
rc('ytick', labelsize='small')
14-
1514
# ref = 'PFASST_GRAYSCOTT_stats_hf_NOFAULT_new.npz'
1615
ref = 'PFASST_GRAYSCOTT_stats_hf_SPREAD_P32.npz'
1716

@@ -25,8 +24,6 @@
2524

2625
xtick_dist = 16
2726

28-
lw = 2
29-
3027
minstep = 288
3128
maxstep = 384
3229
# minstep = 0
@@ -52,9 +49,8 @@
5249
data = np.load(ref)
5350
ref_iter_count = data['iter_count'][minstep:maxstep]
5451

55-
fig, ax = plt.subplots(figsize=(20,7))
56-
57-
52+
rcParams['figure.figsize'] = 6.0, 2.5
53+
fig, ax = plt.subplots()
5854

5955
plt.plot(range(minstep,maxstep),[0]*nsteps,'k-',linewidth=2)
6056

@@ -69,22 +65,25 @@
6965
ymin = min(ymin,min(ref_iter_count-iter_count))
7066
ymax = max(ymax,max(ref_iter_count-iter_count))
7167

72-
plt.plot(range(minstep,maxstep),ref_iter_count-iter_count,color=color,label=label,marker=marker,linestyle='',linewidth=lw,markersize=12)
68+
plt.plot(range(minstep,maxstep),ref_iter_count-iter_count,color=color,label=label,marker=marker,linestyle='',linewidth=lw,markersize=ms)
7369

7470

75-
plt.xlabel('step')
76-
plt.ylabel('saved iterations')
71+
plt.xlabel('step', **axis_font)
72+
plt.ylabel('saved iterations', **axis_font)
7773
plt.xlim(-1+minstep,maxstep+1)
7874
plt.ylim(-1+ymin,ymax+1)
7975
ax.set_xticks(np.arange(minstep,maxstep,xtick_dist)+0.5, minor=False)
8076
ax.set_xticklabels(np.arange(minstep,maxstep,xtick_dist), minor=False)
81-
plt.legend(loc=2,numpoints=1)
82-
77+
plt.legend(loc=2,numpoints=1,fontsize=fs)
78+
plt.tick_params(axis='both', which='major', labelsize=fs)
79+
ax.xaxis.labelpad = -0.5
80+
ax.yaxis.labelpad = -1
8381
plt.tight_layout()
8482

8583
# fname = 'GRAYSCOTT_saved_iteration_vs_NOFAULT_hf.png'
86-
fname = 'GRAYSCOTT_saved_iteration_vs_SPREAD_hf.png'
87-
plt.savefig(fname, rasterized=True, transparent=True, bbox_inches='tight')
84+
fname = 'GRAYSCOTT_saved_iteration_vs_SPREAD_hf.pdf'
85+
plt.savefig(fname, bbox_inches='tight')
86+
os.system('pdfcrop '+fname+' '+fname)
8887

8988
for file,strategy,label,color,marker in list:
9089

@@ -96,10 +95,12 @@
9695

9796
residual = np.where(residual > 0, np.log10(residual), -99)
9897

99-
fig, ax = plt.subplots(figsize=(20,7))
98+
rcParams['figure.figsize'] = 6.0, 2.5
99+
fig, ax = plt.subplots()
100100

101101
cmap = plt.get_cmap('Reds',vmax-vmin+1)
102-
plt.pcolor(residual,cmap=cmap,vmin=vmin,vmax=vmax)
102+
pcol = plt.pcolor(residual,cmap=cmap,vmin=vmin,vmax=vmax)
103+
pcol.set_edgecolor('face')
103104

104105
if not "NOFAULT" in strategy:
105106
for item in stats:
@@ -110,12 +111,17 @@
110111

111112
ticks = np.arange(vmin,vmax+1,2)
112113
tickpos = np.linspace(ticks[0]+0.5, ticks[-1]-0.5, len(ticks))
113-
cax = plt.colorbar(ticks=tickpos)
114+
cax = plt.colorbar(pcol, ticks=tickpos, pad=0.02)
114115
cax.set_ticklabels(ticks)
115-
cax.set_label('log10(residual)')
116+
cax.ax.tick_params(labelsize=fs)
117+
118+
cax.set_label('log10(residual)', **axis_font)
119+
plt.tick_params(axis='both', which='major', labelsize=fs)
120+
ax.xaxis.labelpad = -0.5
121+
ax.yaxis.labelpad = -0.5
116122

117-
ax.set_xlabel('step')
118-
ax.set_ylabel('iteration')
123+
ax.set_xlabel('step', **axis_font)
124+
ax.set_ylabel('iteration', **axis_font)
119125

120126
ax.set_yticks(np.arange(1,maxiter,2)+0.5, minor=False)
121127
ax.set_xticks(np.arange(0,nsteps,xtick_dist)+0.5, minor=False)
@@ -124,8 +130,9 @@
124130

125131
plt.tight_layout()
126132

127-
fname = 'GRAYSCOTT_steps_vs_iteration_hf_'+strategy+'.png'
128-
plt.savefig(fname, rasterized=True, transparent=True, bbox_inches='tight')
133+
fname = 'GRAYSCOTT_steps_vs_iteration_hf_'+strategy+'.pdf'
134+
plt.savefig(fname, bbox_inches='tight')
135+
os.system('pdfcrop '+fname+' '+fname)
129136

130137
# exit()
131138

0 commit comments

Comments
 (0)