Download research/make_figure.py from PureOne/CNISA-II: direct link, hf CLI and curl.
- Browser
- Download file 2.32 kB
-
https://huggingface.co/datasets/PureOne/CNISA-II/resolve/main/research/make_figure.py
- Command line
-
hf download hf://datasets/PureOne/CNISA-II/research/make_figure.py
-
curl -L -o make_figure.py https://huggingface.co/datasets/PureOne/CNISA-II/resolve/main/research/make_figure.py
2.32 kB
| """Render the manuscript figure from the executed checks and the proved FI bound.""" | |
| import argparse | |
| import json | |
| import math | |
| from pathlib import Path | |
| import matplotlib | |
| matplotlib.use('Agg') | |
| import matplotlib.pyplot as plt | |
| from matplotlib.ticker import NullFormatter | |
| import numpy as np | |
| def main(): | |
| parser=argparse.ArgumentParser() | |
| parser.add_argument('--results',type=Path,default=Path('results.json')) | |
| parser.add_argument('--output',type=Path,default=Path('figures/distance.pdf')) | |
| args=parser.parse_args() | |
| data=json.loads(args.results.read_text()) | |
| plt.rcParams.update({'font.family':'DejaVu Sans','font.size':8,'axes.spines.top':False, | |
| 'axes.spines.right':False,'pdf.fonttype':42,'axes.labelcolor':'#253b45', | |
| 'text.color':'#18323d','axes.edgecolor':'#87999d'}) | |
| fig,ax=plt.subplots(1,2,figsize=(7.05,2.86),layout='constrained') | |
| colors=['#174766','#138079','#bc632b','#7c558c'] | |
| for row,color in zip(data['passive_graph'],colors): | |
| d=row['distance'] | |
| ax[0].loglog(row['strengths'],row['offsets'],'o-',ms=2.4,lw=1.4,color=color, | |
| label=f'd = {d}') | |
| photons=np.logspace(2,9,200) | |
| a=.2 | |
| b=2*a**d/math.factorial(d) | |
| ax[1].semilogx(photons,(1-a*a)**2/(1+photons*b*b),color=color,lw=1.8) | |
| ax[0].set(xlabel='Adjacent coupling × length, gL',ylabel='Absolute signed null offset') | |
| ax[0].set_xticks([.015,.03,.06],labels=['0.015','0.030','0.060']) | |
| ax[0].xaxis.set_minor_formatter(NullFormatter()) | |
| ax[0].legend(frameon=False,ncol=2,fontsize=7,loc='lower right',columnspacing=.7) | |
| ax[1].set(xlabel='Photon budget, nτ',ylabel='Guaranteed fraction of clean information',ylim=(-.03,1.02)) | |
| ax[1].plot(1e6,data['information']['guarantees'][2]['fraction'],'o',color=colors[2],ms=5) | |
| ax[1].annotate('0.9055',xy=(1e6,.9055),xytext=(6e4,.65), | |
| arrowprops={'arrowstyle':'-','color':colors[2]},fontsize=8) | |
| for a,title in zip(ax,('Measured in the chain simulation','Lower bound for action a = 0.20')): | |
| a.set_title(title,loc='left',fontweight='bold',fontsize=9) | |
| a.grid(axis='y',alpha=.16) | |
| args.output.parent.mkdir(parents=True,exist_ok=True) | |
| fig.savefig(args.output,bbox_inches='tight') | |
| if __name__=='__main__': | |
| main() | |