-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgif.ngjs
executable file
·36 lines (30 loc) · 1.08 KB
/
gif.ngjs
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
#!/usr/bin/env ngspicejs
// Show charts for tmp.json and save them as gifs
// linter: ngspicejs-lint
// global: load_all_data, simulate, config
"use strict";
// Load current model
var initial = file_read_json('tmp.json');
// Include all sources
include('src/all.js');
// Load measured data
var m = load_all_data(initial.name);
if (m.vto) {
echo('config.transistor', config.transistor, 'vto', m.vto.toFixed(3), 'idss', m.idss.toEng(3));
}
// simulate and show charts
var s = simulate(initial, m.data, true);
echo('// score', s.score.toEng(3));
s.show();
// save gifs
var today = (new Date()).toISOString().substr(0, 19).replace(/[T:\-]/g, '_');
beep();
read('Press ENTER to save .gif, .json and .spice, or press CTRL+C to exit: ');
echo();
s.charts.chart1.gif(m.name + '_' + today + '_chart1.gif');
s.charts.chart2.gif(m.name + '_' + today + '_chart2.gif');
file_write_json(m.name + '_' + today + '_tmp_' + s.score.toEng(3) + '.json', initial, 4);
// save spice model
var sp = jfet_model(initial);
file_write(m.name + '_' + today + '_tmp_' + s.score.toEng(3) + '.cir', sp.render());
exit(1);