File size: 2,724 Bytes
bee08ba | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | from pathlib import Path
import json
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import numpy as np
root=Path(__file__).resolve().parent
m=json.loads((root/'results/metrics.json').read_text())
plt.rcParams.update({
'font.family':'DejaVu Sans','font.size':10.5,
'axes.labelsize':10.5,'axes.titlesize':11,
'xtick.labelsize':9.5,'ytick.labelsize':9.5,
'axes.spines.top':False,'axes.spines.right':False,
'figure.facecolor':'white','pdf.fonttype':42})
# Designed for a six-inch manuscript column: the minimum 9.5-point source
# type remains about 8.8 points after scaling from this 6.5-inch figure.
# Two upper panels and one spanning lower panel avoid tiny three-across text.
fig=plt.figure(figsize=(6.5,6.6),layout='constrained')
grid=fig.add_gridspec(2,2,height_ratios=[1.12,.88])
axs=[fig.add_subplot(grid[0,0]),fig.add_subplot(grid[0,1]),
fig.add_subplot(grid[1,:])]
colors=['#233954','#a94960','#6a9e9b']
labels=['Raw int16','zlib','WAV']
x=np.arange(2)
for j,key in enumerate(['raw_bytes','compressed_bytes','wav_bytes']):
axs[0].bar(x+(j-1)*.24,[r[key]/1024 for r in m['codec']],width=.23,label=labels[j],color=colors[j])
axs[0].set_xticks(x,['Structured','Uniform\nrandom'])
axs[0].set_ylabel('Size (KiB)');axs[0].set_title('A. Lossless file sizes',loc='left')
axs[0].set_ylim(0,65)
axs[0].legend(frameon=False,fontsize=9.5,loc='upper left',handlelength=1.2)
axs[0].grid(axis='y',alpha=.15);axs[0].set_axisbelow(True)
for order,color in zip([1,2,5],colors):
rows=[r for r in m['jet']['finite_difference_controls'] if r['order']==order]
axs[1].loglog([r['step'] for r in rows],[r['absolute_error'] for r in rows],'-o',color=color,markersize=4,label=f'FD order {order}')
axs[1].axhline(m['jet']['max_absolute_error'],ls='--',color='#756b96',label='Jet max (32)')
axs[1].set_xlabel('Step size h');axs[1].set_ylabel('Absolute derivative error')
axs[1].set_title('B. Mixed derivatives',loc='left')
axs[1].legend(frameon=False,fontsize=9.5,loc='lower right',
bbox_to_anchor=(1,.08),handlelength=1.2)
axs[1].grid(alpha=.15)
rows=m['heat']['progression'];base=rows[0]['centered_l2_norm']
axs[2].plot([r['time'] for r in rows],[r['centered_l2_norm']/base for r in rows],'-o',color='#a94960',lw=1.8,markersize=5)
axs[2].set_xlabel('Heat evolution parameter t');axs[2].set_ylabel('Centered L2 norm ratio')
axs[2].set_title('C. Five-axis smoothing',loc='left')
axs[2].set_ylim(0,1.05)
axs[2].grid(alpha=.15)
axs[2].text(.97,.95,'Axis rates: 0.4, 0.8, 1.2, 1.6, 2.0',
transform=axs[2].transAxes,ha='right',va='top',fontsize=9.5)
fig.savefig(root/'results/codec_checks.png',dpi=200)
fig.savefig(root/'results/codec_checks.pdf')
plt.close(fig)
|