Skip to content

Commit 16fc201

Browse files
committed
bugfix for plotting residuals
1 parent e56e3ae commit 16fc201

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

examples/fault_tolerance/postproc_boussinesq.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
list = [ ('PFASST_BOUSSINESQ_stats_hf_SPREAD_P16.npz','SPREAD','1-sided','red','s'),
1616
('PFASST_BOUSSINESQ_stats_hf_INTERP_P16.npz','INTERP','2-sided','orange','o'),
1717
('PFASST_BOUSSINESQ_stats_hf_SPREAD_PREDICT_P16.npz','SPREAD_PREDICT','1-sided+corr','blue','^'),
18-
('PFASST_BOUSSINESQ_stats_hf_INTERP_PREDICT_P16.npz','INTERP_PREDICT','2-sided+corr','green','d') ]
18+
('PFASST_BOUSSINESQ_stats_hf_INTERP_PREDICT_P16.npz','INTERP_PREDICT','2-sided+corr','green','d'),
19+
('PFASST_BOUSSINESQ_stats_hf_NOFAULT_P16.npz','NOFAULT','no fault','black','v')]
1920

2021
nprocs = 16
2122

@@ -31,20 +32,23 @@
3132
# maxiter = 14
3233
nsteps = 0
3334
maxiter = 0
35+
vmax = -99
36+
vmin = -8
3437
for file,strategy,label,color,marker in list:
3538

3639
data = np.load(file)
3740

3841
iter_count = data['iter_count'][minstep:maxstep]
3942
residual = data['residual'][:,minstep:maxstep]
4043

41-
residual = np.where(residual > 0, np.log10(residual), -99)
42-
vmin = -9
43-
vmax = int(np.amax(residual))
44+
residual[residual <= 0] = 1E-99
45+
residual = np.log10(residual)
46+
vmax = max(vmax,int(np.amax(residual)))
4447

4548
maxiter = max(maxiter,int(max(iter_count)))
4649
nsteps = max(nsteps,len(iter_count))
4750

51+
print(vmin,vmax)
4852
data = np.load(ref)
4953
ref_iter_count = data['iter_count'][nprocs-1::nprocs]
5054

@@ -90,7 +94,8 @@
9094
residual = data['residual'][:,minstep:maxstep]
9195
stats = data['hard_stats']
9296

93-
residual = np.where(residual > 0, np.log10(residual), -99)
97+
residual[residual <= 0] = 1E-99
98+
residual = np.log10(residual)
9499

95100
rcParams['figure.figsize'] = 6.0, 2.5
96101
fig, ax = plt.subplots()
@@ -99,13 +104,14 @@
99104
pcol = plt.pcolor(residual,cmap=cmap,vmin=vmin,vmax=vmax)
100105
pcol.set_edgecolor('face')
101106

102-
for item in stats:
103-
if item[0] in range(minstep,maxstep):
104-
plt.text(item[0]+0.5-(maxstep-nsteps),item[1]-1+0.5,'x',horizontalalignment='center',verticalalignment='center')
107+
if not file is ref:
108+
for item in stats:
109+
if item[0] in range(minstep,maxstep):
110+
plt.text(item[0]+0.5-(maxstep-nsteps),item[1]-1+0.5,'x',horizontalalignment='center',verticalalignment='center')
105111

106112
plt.axis([0,nsteps,0,maxiter])
107113

108-
ticks = np.arange(vmin,vmax+1,2)
114+
ticks = np.arange(vmin,vmax+1)
109115
tickpos = np.linspace(ticks[0]+0.5, ticks[-1]-0.5, len(ticks))
110116
cax = plt.colorbar(pcol, ticks=tickpos, pad=0.02)
111117
cax.set_ticklabels(ticks)

examples/fault_tolerance/postproc_grayscott.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
list = [ ('PFASST_GRAYSCOTT_stats_hf_SPREAD_P32.npz','SPREAD','1-sided','red','s'),
1616
('PFASST_GRAYSCOTT_stats_hf_INTERP_P32.npz','INTERP','2-sided','orange','o'),
1717
('PFASST_GRAYSCOTT_stats_hf_SPREAD_PREDICT_P32.npz','SPREAD_PREDICT','1-sided+corr','blue','^'),
18-
('PFASST_GRAYSCOTT_stats_hf_INTERP_PREDICT_P32.npz','INTERP_PREDICT','2-sided+corr','green','d') ]
18+
('PFASST_GRAYSCOTT_stats_hf_INTERP_PREDICT_P32.npz','INTERP_PREDICT','2-sided+corr','green','d'),
19+
('PFASST_GRAYSCOTT_stats_hf_NOFAULT_P32.npz','NOFAULT','no fault','black','v')]
1920

2021
nprocs = 32
2122

@@ -31,16 +32,18 @@
3132
# maxiter = 14
3233
nsteps = 0
3334
maxiter = 0
35+
vmax = -99
3436
for file,strategy,label,color,marker in list:
3537

3638
data = np.load(file)
3739

3840
iter_count = data['iter_count'][minstep:maxstep]
3941
residual = data['residual'][:,minstep:maxstep]
4042

41-
residual = np.where(residual > 0, np.log10(residual), -99)
43+
residual[residual <= 0] = 1E-99
44+
residual = np.log10(residual)
4245
vmin = -9
43-
vmax = int(np.amax(residual))
46+
vmax = max(vmax,int(np.amax(residual)))
4447

4548
maxiter = max(maxiter,int(max(iter_count)))
4649
nsteps = max(nsteps,len(iter_count))
@@ -90,7 +93,8 @@
9093
residual = data['residual'][:,minstep:maxstep]
9194
stats = data['hard_stats']
9295

93-
residual = np.where(residual > 0, np.log10(residual), -99)
96+
residual[residual <= 0] = 1E-99
97+
residual = np.log10(residual)
9498

9599
rcParams['figure.figsize'] = 6.0, 2.5
96100
fig, ax = plt.subplots()
@@ -99,9 +103,10 @@
99103
pcol = plt.pcolor(residual,cmap=cmap,vmin=vmin,vmax=vmax)
100104
pcol.set_edgecolor('face')
101105

102-
for item in stats:
103-
if item[0] in range(minstep,maxstep):
104-
plt.text(item[0]+0.5-(maxstep-nsteps),item[1]-1+0.5,'x',horizontalalignment='center',verticalalignment='center')
106+
if file is not ref:
107+
for item in stats:
108+
if item[0] in range(minstep,maxstep):
109+
plt.text(item[0]+0.5-(maxstep-nsteps),item[1]-1+0.5,'x',horizontalalignment='center',verticalalignment='center')
105110

106111
plt.axis([0,nsteps,0,maxiter])
107112

0 commit comments

Comments
 (0)