Added proper closing of plots
Signed-off-by: Grzegorz Latosinski <glatosinski@antmicro.com>
This commit is contained in:
parent
222572af4d
commit
7c4d2fa0f3
|
@ -96,6 +96,11 @@ def gen_plots(gm_id, id_W, ft, gm_gds, vsweep, fet_W, fet_L, plts):
|
||||||
plts[3].plot(vsweep, gm_id, label=f'W {fet_W} x L {fet_L}')
|
plts[3].plot(vsweep, gm_id, label=f'W {fet_W} x L {fet_L}')
|
||||||
|
|
||||||
|
|
||||||
|
def close_plots(figs):
|
||||||
|
for f in figs:
|
||||||
|
plt.close(f)
|
||||||
|
|
||||||
|
|
||||||
def read_bins(fname):
|
def read_bins(fname):
|
||||||
with open(fname, 'r') as f:
|
with open(fname, 'r') as f:
|
||||||
r = csv.reader(f)
|
r = csv.reader(f)
|
||||||
|
@ -124,7 +129,8 @@ def generate_fet_plots(
|
||||||
for line in bins:
|
for line in bins:
|
||||||
bins_by_W[(line[0], float(line[2]))].append(line)
|
bins_by_W[(line[0], float(line[2]))].append(line)
|
||||||
|
|
||||||
Ws = [key for key in bins_by_W.keys() if only_W is None or key[1] in only_W]
|
Ws = [key for key in bins_by_W.keys()
|
||||||
|
if only_W is None or key[1] in only_W]
|
||||||
|
|
||||||
for fet_type, W in Ws:
|
for fet_type, W in Ws:
|
||||||
if outprefix is None:
|
if outprefix is None:
|
||||||
|
@ -136,14 +142,18 @@ def generate_fet_plots(
|
||||||
c = create_test_circuit(fet_type, iparam, 0.15, 1, corner_path)
|
c = create_test_circuit(fet_type, iparam, 0.15, 1, corner_path)
|
||||||
|
|
||||||
figs, plts = init_plots(fet_type, W)
|
figs, plts = init_plots(fet_type, W)
|
||||||
for dev, bin, fet_W, fet_L in bins_by_W[(fet_type, W)]:
|
try:
|
||||||
fet_W, fet_L = float(fet_W), float(fet_L)
|
for dev, bin, fet_W, fet_L in bins_by_W[(fet_type, W)]:
|
||||||
if only_W is not None and fet_W not in only_W:
|
fet_W, fet_L = float(fet_W), float(fet_L)
|
||||||
continue
|
if only_W is not None and fet_W not in only_W:
|
||||||
c.element('XM1').parameters['W'] = fet_W
|
continue
|
||||||
c.element('XM1').parameters['L'] = fet_L
|
c.element('XM1').parameters['W'] = fet_W
|
||||||
gm_id, ft, id_W, gm_gds, vsweep = run_sim(c, iparam, fet_W)
|
c.element('XM1').parameters['L'] = fet_L
|
||||||
gen_plots(gm_id, id_W, ft, gm_gds, vsweep, fet_W, fet_L, plts)
|
gm_id, ft, id_W, gm_gds, vsweep = run_sim(c, iparam, fet_W)
|
||||||
|
gen_plots(gm_id, id_W, ft, gm_gds, vsweep, fet_W, fet_L, plts)
|
||||||
|
except Exception:
|
||||||
|
close_plots(figs)
|
||||||
|
raise
|
||||||
|
|
||||||
figtitles = ['Id_w', 'fT', 'gm_gds', 'gm_id']
|
figtitles = ['Id_w', 'fT', 'gm_gds', 'gm_id']
|
||||||
for fg, name in zip(figs, figtitles):
|
for fg, name in zip(figs, figtitles):
|
||||||
|
@ -154,11 +164,12 @@ def generate_fet_plots(
|
||||||
fg.tight_layout()
|
fg.tight_layout()
|
||||||
fg.savefig(
|
fg.savefig(
|
||||||
Path(outdir) / (
|
Path(outdir) / (
|
||||||
outprefix + f'_{fet_type}_{name}_W{str(W).replace(".", "_")}.{ext}'),
|
outprefix +
|
||||||
|
f'_{fet_type}_{name}_W{str(W).replace(".", "_")}.{ext}'),
|
||||||
bbox_extra_artists=(lg,),
|
bbox_extra_artists=(lg,),
|
||||||
bbox_inches='tight'
|
bbox_inches='tight'
|
||||||
)
|
)
|
||||||
plt.close('all')
|
close_plots(figs)
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
|
|
@ -22,6 +22,7 @@ from pathlib import Path
|
||||||
import sys
|
import sys
|
||||||
import contextlib
|
import contextlib
|
||||||
import traceback
|
import traceback
|
||||||
|
import errno
|
||||||
|
|
||||||
from fet_simulator import generate_fet_plots
|
from fet_simulator import generate_fet_plots
|
||||||
|
|
||||||
|
@ -73,11 +74,13 @@ def main(argv):
|
||||||
with open(args.failed_inputs, 'w') if args.failed_inputs else nc as err:
|
with open(args.failed_inputs, 'w') if args.failed_inputs else nc as err:
|
||||||
for fetbin in fetbins:
|
for fetbin in fetbins:
|
||||||
outdir = (args.output_dir /
|
outdir = (args.output_dir /
|
||||||
fetbin.resolve()
|
fetbin.resolve()
|
||||||
.relative_to(args.libraries_dir.resolve()))
|
.relative_to(args.libraries_dir.resolve()))
|
||||||
if args.libname and args.libname != outdir.parts[0]:
|
library = outdir.relative_to(args.output_dir).parts[0]
|
||||||
|
ver = outdir.relative_to(args.output_dir).parts[1]
|
||||||
|
if args.libname and args.libname != library:
|
||||||
continue
|
continue
|
||||||
if args.version and args.version != outdir.parts[1]:
|
if args.version and args.version != ver:
|
||||||
continue
|
continue
|
||||||
print(f'===> {str(fetbin)}')
|
print(f'===> {str(fetbin)}')
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue