I went through the
tutorial
and created the code and everthing worked except
the plotout command:
$ cat -n DC-AC-ratios.lk
1 ratios = csvread('/home/wink/prgs/solar/data/DC-AC-ratios.csv',
2 {'skip'=1, 'numeric'=true});
3 active_case('DC-AC-ratios');
4
5 for( i=0; i < #ratios; i++ ) {
6 r = ratios[i][0];
7 set('dc_ac_ratio', r);
8 simulate();
9
10 cf=get('capacity_factor');
11 outln('ratio[' + i + ']:' + r + '=' + cf);
12
13 x.DCACRatio[i] = r;
14 x.CapacityFactor[i] = cf;
15 x.Energy[i] = get('annual_energy');
16 x.LCOE[i] = get('lcoe_nom');
17 }
18
19 csvwrite('/home/wink/prgs/solar/data/DC-AC-ratios-results.csv', x);
20
21 newplot(true);
22 plot(x.DCACRatio, x.LCOE, { 'type'='line', 'color'='red', 'thick'='2' });
23
24 plotopt({'title'='Impact of DC/AC Ratio in Captiola', 'legend'=false});
25 axis('x1', {'label'='DC/AC ratio'});
26 axis('y1', {'label'='LCOE (cents/kwh)'});
27
28 file_name = '/home/wink/prgs/solar/data/DC-AC-ratios-results.png';
29 outln('file_name=' + file_name);
30
31 plotout(file_name);
Everything worked except the the contents of ploutout(file_name) was a 20x20 image. I looked at the
sources in the SAM/samples and found 'LK Scripts for SAM/plot_samples.lk' and uncommented the
test of plotout and it worked. There are obviously differerences but thought the biggest difference was
the test was using choose_dir:
19 // save plot as image file
20 f_path=choose_dir(homedir(),'Save Plot');
21 f_name = f_path + '/plot.pdf';
22 outln(f_name);
23 ok = plotout( f_name , 'pdf'); // png, pdf, bmp, or jpg. Defaults to png if file type not given.
So I changed line 20 to:
20 f_path='/home/wink/prgs/solar/data'; //choose_dir(homedir(),'Save Plot');
And now plot_samples.lk failed the same way, only a small image was created.
I then changed line 28 of DC-AC-ratios.lk to:
28 file_name = choose_dir('/home/wink/prgs/solar/data', 'Save Plot') + '/DC-AC-ratios-results.png';
And now I see the full image, so it looks like there is a bug and some side effect
of choose_dir allows plotout to work correctly.
Should I create an issue at
github.com/NREL/SAM/issues?