Make gsa compatible with octave;

time-shift
Marco Ratto 2011-10-25 18:00:54 +02:00
parent a6b704543c
commit b4fa7ef84e
5 changed files with 191 additions and 96 deletions

View File

@ -149,7 +149,7 @@ options_.opt_gsa = options_gsa;
if (options_gsa.load_stab || options_gsa.load_rmse || options_gsa.load_redform) ... if (options_gsa.load_stab || options_gsa.load_rmse || options_gsa.load_redform) ...
&& options_gsa.pprior, && options_gsa.pprior,
filetoload=[OutputDirectoryName '/' fname_ '_prior.mat']; filetoload=[OutputDirectoryName '/' fname_ '_prior.mat'];
if isempty(ls(filetoload)), if ~exist(filetoload),
disp([filetoload,' not found!']) disp([filetoload,' not found!'])
disp(['You asked to load a non existent analysis']) disp(['You asked to load a non existent analysis'])
%options_gsa.load_stab=0; %options_gsa.load_stab=0;

View File

@ -48,7 +48,7 @@ disp('Starting sensitivity analysis')
disp('for the fit of EACH observed series ...') disp('for the fit of EACH observed series ...')
disp(' ') disp(' ')
disp('Deleting old SA figures...') disp('Deleting old SA figures...')
a=dir([OutDir,'/*.*']); a=dir([OutDir,filesep,'*.*']);
tmp1='0'; tmp1='0';
if options_.opt_gsa.ppost, if options_.opt_gsa.ppost,
tmp=['_rmse_post']; tmp=['_rmse_post'];
@ -82,11 +82,11 @@ if ~isempty(options_.mode_file),
load(options_.mode_file,'xparam1'), load(options_.mode_file,'xparam1'),
end end
if options_.opt_gsa.ppost, if options_.opt_gsa.ppost,
c=load([fname_,'_mean'],'xparam1'); c=load([fname_,'_mean.mat'],'xparam1');
xparam1_mean=c.xparam1; xparam1_mean=c.xparam1;
clear c clear c
elseif ~isempty(options_.mode_file) & ~isempty(ls([fname_,'_mean.mat'])) elseif ~isempty(options_.mode_file) && exist([fname_,'_mean.mat'])==2,
c=load([fname_,'_mean'],'xparam1'); c=load([fname_,'_mean.mat'],'xparam1');
xparam1_mean=c.xparam1; xparam1_mean=c.xparam1;
clear c clear c
end end
@ -118,15 +118,16 @@ if ~loadSA,
obs = dat_fil_(options_.datafile); obs = dat_fil_(options_.datafile);
%stock_gend=data_info.gend; %stock_gend=data_info.gend;
%stock_data = data_info.data; %stock_data = data_info.data;
load([DirectoryName '/' M_.fname '_data.mat']); filfilt = dir([DirectoryName '/' M_.fname '_filter_step_ahead*.mat']); load([DirectoryName '/' M_.fname '_data.mat']);
filparam = dir([DirectoryName '/' M_.fname '_param*.mat']); filfilt = dir([DirectoryName filesep M_.fname '_filter_step_ahead*.mat']);
filparam = dir([DirectoryName filesep M_.fname '_param*.mat']);
x=[]; x=[];
logpo2=[]; logpo2=[];
sto_ys=[]; sto_ys=[];
for j=1:length(filparam), for j=1:length(filparam),
%load([DirectoryName '/' M_.fname '_param',int2str(j),'.mat']); %load([DirectoryName '/' M_.fname '_param',int2str(j),'.mat']);
if isempty(strmatch([M_.fname '_param_irf'],filparam(j).name)) if isempty(strmatch([M_.fname '_param_irf'],filparam(j).name))
load([DirectoryName '/' filparam(j).name]); load([DirectoryName filesep filparam(j).name]);
x=[x; stock]; x=[x; stock];
logpo2=[logpo2; stock_logpo]; logpo2=[logpo2; stock_logpo];
sto_ys=[sto_ys; stock_ys]; sto_ys=[sto_ys; stock_ys];
@ -166,7 +167,7 @@ if ~loadSA,
y0=zeros(nobs+1,nruns); y0=zeros(nobs+1,nruns);
nbb=0; nbb=0;
for j=1:length(filfilt), for j=1:length(filfilt),
load([DirectoryName '/' M_.fname '_filter_step_ahead',num2str(j),'.mat']); load([DirectoryName filesep M_.fname '_filter_step_ahead',num2str(j),'.mat']);
nb = size(stock,4); nb = size(stock,4);
% y0(:,nbb+1:nbb+nb)=squeeze(stock(1,js,:,:)) + ... % y0(:,nbb+1:nbb+nb)=squeeze(stock(1,js,:,:)) + ...
% kron(sto_ys(nbb+1:nbb+nb,js)',ones(size(stock,3),1)); % kron(sto_ys(nbb+1:nbb+nb,js)',ones(size(stock,3),1));
@ -199,25 +200,25 @@ if ~loadSA,
disp('... done!') disp('... done!')
if options_.opt_gsa.ppost if options_.opt_gsa.ppost
save([OutDir,'/',fnamtmp], 'x', 'logpo2', 'likelihood', 'rmse_MC', 'rmse_mode','rmse_pmean') save([OutDir,filesep,fnamtmp,'.mat'], 'x', 'logpo2', 'likelihood', 'rmse_MC', 'rmse_mode','rmse_pmean')
else else
if options_.opt_gsa.lik_only if options_.opt_gsa.lik_only
save([OutDir,'/',fnamtmp], 'likelihood', '-append') save([OutDir,filesep,fnamtmp, '.mat'], 'likelihood', '-append')
else else
save([OutDir,'/',fnamtmp], 'likelihood', 'rmse_MC','-append') save([OutDir,filesep,fnamtmp, '.mat'], 'likelihood', 'rmse_MC','-append')
if exist('xparam1_mean','var') if exist('xparam1_mean','var')
save([OutDir,'/',fnamtmp], 'rmse_pmean','-append') save([OutDir,filesep,fnamtmp, '.mat'], 'rmse_pmean','-append')
end end
if exist('xparam1','var') if exist('xparam1','var')
save([OutDir,'/',fnamtmp], 'rmse_mode','-append') save([OutDir,filesep,fnamtmp,'.mat'], 'rmse_mode','-append')
end end
end end
end end
else else
if options_.opt_gsa.lik_only & options_.opt_gsa.ppost==0 if options_.opt_gsa.lik_only & options_.opt_gsa.ppost==0
load([OutDir,'/',fnamtmp],'x','logpo2','likelihood'); load([OutDir,filesep,fnamtmp, '.mat'],'x','logpo2','likelihood');
else else
load([OutDir,'/',fnamtmp],'x','logpo2','likelihood','rmse_MC','rmse_mode','rmse_pmean'); load([OutDir,filesep,fnamtmp, '.mat'],'x','logpo2','likelihood','rmse_MC','rmse_mode','rmse_pmean');
end end
lnprior=logpo2(:)-likelihood(:); lnprior=logpo2(:)-likelihood(:);
nruns=size(x,1); nruns=size(x,1);
@ -289,21 +290,27 @@ else
hold on, cumplot(lnprior) hold on, cumplot(lnprior)
h=cumplot(lnprior(ixx(nfilt0(i)+1:end,i))); h=cumplot(lnprior(ixx(nfilt0(i)+1:end,i)));
set(h,'color','green') set(h,'color','green')
title(vvarvecm(i,:)) title(vvarvecm(i,:),'interpreter','none')
if mod(i,9)==0 | i==size(vvarvecm,1) if mod(i,9)==0 | i==size(vvarvecm,1)
if options_.opt_gsa.ppost if options_.opt_gsa.ppost
saveas(gcf,[OutDir,'/',fname_,'_rmse_post_lnprior',int2str(ifig)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_post_lnprior',int2str(ifig) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_post_lnprior',int2str(ifig)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_post_lnprior',int2str(ifig)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_post_lnprior',int2str(ifig)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_post_lnprior',int2str(ifig)]);
end
else else
if options_.opt_gsa.pprior if options_.opt_gsa.pprior
saveas(gcf,[OutDir,'/',fname_,'_rmse_prior_lnprior',int2str(ifig)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_prior_lnprior',int2str(ifig) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_prior_lnprior',int2str(ifig)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_prior_lnprior',int2str(ifig)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_prior_lnprior',int2str(ifig)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_prior_lnprior',int2str(ifig)]);
end
else else
saveas(gcf,[OutDir,'/',fname_,'_rmse_mc_lnprior',int2str(ifig)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_mc_lnprior',int2str(ifig) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_mc_lnprior',int2str(ifig)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_mc_lnprior',int2str(ifig)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_mc_lnprior',int2str(ifig)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_mc_lnprior',int2str(ifig)]);
end
end end
end end
close(gcf) close(gcf)
@ -321,24 +328,30 @@ else
hold on, h=cumplot(likelihood); hold on, h=cumplot(likelihood);
h=cumplot(likelihood(ixx(nfilt0(i)+1:end,i))); h=cumplot(likelihood(ixx(nfilt0(i)+1:end,i)));
set(h,'color','green') set(h,'color','green')
title(vvarvecm(i,:)) title(vvarvecm(i,:),'interpreter','none')
if options_.opt_gsa.ppost==0, if options_.opt_gsa.ppost==0,
set(gca,'xlim',[min( likelihood(ixx(1:nfilt0(i),i)) ) max( likelihood(ixx(1:nfilt0(i),i)) )]) set(gca,'xlim',[min( likelihood(ixx(1:nfilt0(i),i)) ) max( likelihood(ixx(1:nfilt0(i),i)) )])
end end
if mod(i,9)==0 | i==size(vvarvecm,1) if mod(i,9)==0 | i==size(vvarvecm,1)
if options_.opt_gsa.ppost if options_.opt_gsa.ppost
saveas(gcf,[OutDir,'/',fname_,'_rmse_post_lnlik',int2str(ifig)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_post_lnlik',int2str(ifig) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_post_lnlik',int2str(ifig)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_post_lnlik',int2str(ifig)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_post_lnlik',int2str(ifig)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_post_lnlik',int2str(ifig)]);
end
else else
if options_.opt_gsa.pprior if options_.opt_gsa.pprior
saveas(gcf,[OutDir,'/',fname_,'_rmse_prior_lnlik',int2str(ifig)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_prior_lnlik',int2str(ifig) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_prior_lnlik',int2str(ifig)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_prior_lnlik',int2str(ifig)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_prior_lnlik',int2str(ifig)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_prior_lnlik',int2str(ifig)]);
end
else else
saveas(gcf,[OutDir,'/',fname_,'_rmse_mc_lnlik',int2str(ifig)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_mc_lnlik',int2str(ifig) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_mc_lnlik',int2str(ifig)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_mc_lnlik',int2str(ifig)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_mc_lnlik',int2str(ifig)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_mc_lnlik',int2str(ifig)]);
end
end end
end end
close(gcf) close(gcf)
@ -356,24 +369,30 @@ else
hold on, h=cumplot(logpo2); hold on, h=cumplot(logpo2);
h=cumplot(logpo2(ixx(nfilt0(i)+1:end,i))); h=cumplot(logpo2(ixx(nfilt0(i)+1:end,i)));
set(h,'color','green') set(h,'color','green')
title(vvarvecm(i,:)) title(vvarvecm(i,:),'interpreter','none')
if options_.opt_gsa.ppost==0, if options_.opt_gsa.ppost==0,
set(gca,'xlim',[min( logpo2(ixx(1:nfilt0(i),i)) ) max( logpo2(ixx(1:nfilt0(i),i)) )]) set(gca,'xlim',[min( logpo2(ixx(1:nfilt0(i),i)) ) max( logpo2(ixx(1:nfilt0(i),i)) )])
end end
if mod(i,9)==0 | i==size(vvarvecm,1) if mod(i,9)==0 | i==size(vvarvecm,1)
if options_.opt_gsa.ppost if options_.opt_gsa.ppost
saveas(gcf,[OutDir,'/',fname_,'_rmse_post_lnpost',int2str(ifig)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_post_lnpost',int2str(ifig) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_post_lnpost',int2str(ifig)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_post_lnpost',int2str(ifig)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_post_lnpost',int2str(ifig)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_post_lnpost',int2str(ifig)]);
end
else else
if options_.opt_gsa.pprior if options_.opt_gsa.pprior
saveas(gcf,[OutDir,'/',fname_,'_rmse_prior_lnpost',int2str(ifig)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_prior_lnpost',int2str(ifig) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_prior_lnpost',int2str(ifig)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_prior_lnpost',int2str(ifig)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_prior_lnpost',int2str(ifig)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_prior_lnpost',int2str(ifig)]);
end
else else
saveas(gcf,[OutDir,'/',fname_,'_rmse_mc_lnpost',int2str(ifig)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_mc_lnpost',int2str(ifig) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_mc_lnpost',int2str(ifig)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_mc_lnpost',int2str(ifig)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_mc_lnpost',int2str(ifig)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_mc_lnpost',int2str(ifig)]);
end
end end
end end
close(gcf) close(gcf)
@ -501,23 +520,33 @@ else
title([pnam{nsnam(j)}],'interpreter','none') title([pnam{nsnam(j)}],'interpreter','none')
end end
%subplot(3,2,6) %subplot(3,2,6)
h0=legend(str2mat('base',vvarvecm(np,:)),0); if exist('OCTAVE_VERSION'),
set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3],'interpreter','none') legend(str2mat('base',vvarvecm(np,:)),'location','eastoutside');
else
h0=legend(str2mat('base',vvarvecm(np,:)),0);
set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3],'interpreter','none');
end
%h0=legend({'base',vnam{np}}',0); %h0=legend({'base',vnam{np}}',0);
%set(findobj(get(h0,'children'),'type','text'),'interpreter','none') %set(findobj(get(h0,'children'),'type','text'),'interpreter','none')
if options_.opt_gsa.ppost if options_.opt_gsa.ppost
saveas(gcf,[OutDir,'/',fname_,'_rmse_post_',num2str(ix)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_post_' int2str(ix) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_post_' int2str(ix)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_post_' int2str(ix)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_post_',num2str(ix)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_post_' int2str(ix)]);
end
else else
if options_.opt_gsa.pprior if options_.opt_gsa.pprior
saveas(gcf,[OutDir,'/',fname_,'_rmse_prior_',num2str(ix)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_prior_' int2str(ix) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_prior_' int2str(ix)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_prior_' int2str(ix)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_prior_',num2str(ix)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_prior_' int2str(ix)]);
end
else else
saveas(gcf,[OutDir,'/',fname_,'_rmse_mc_',num2str(ix)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_mc_' int2str(ix) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_mc_' int2str(ix)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_mc_' int2str(ix)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_mc_',num2str(ix)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_mc_' int2str(ix)]);
end
end end
end end
end end
@ -562,23 +591,33 @@ else
xlabel('') xlabel('')
title([pnam{nsnam(j)}],'interpreter','none') title([pnam{nsnam(j)}],'interpreter','none')
end end
h0=legend(str2mat('base',vvarvecm(np,:)),0); if exist('OCTAVE_VERSION'),
set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3],'interpreter','none') legend(str2mat('base',vvarvecm(np,:)),'location','eastoutside');
else
h0=legend(str2mat('base',vvarvecm(np,:)),0);
set(h0,'fontsize',6,'position',[0.7 0.1 0.2 0.3],'interpreter','none')
end
%h0=legend({'base',vnam{np}}',0); %h0=legend({'base',vnam{np}}',0);
%set(findobj(get(h0,'children'),'type','text'),'interpreter','none') %set(findobj(get(h0,'children'),'type','text'),'interpreter','none')
if options_.opt_gsa.ppost if options_.opt_gsa.ppost
saveas(gcf,[OutDir,'/',fname_,'_rmse_post_dens_',num2str(ix)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_post_dens_' int2str(ix) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_post_dens_' int2str(ix)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_post_dens_' int2str(ix)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_post_dens_',num2str(ix)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_post_dens_' int2str(ix)]);
end
else else
if options_.opt_gsa.pprior if options_.opt_gsa.pprior
saveas(gcf,[OutDir,'/',fname_,'_rmse_prior_dens_',num2str(ix)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_prior_dens_' int2str(ix) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_prior_dens_' int2str(ix)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_prior_dens_' int2str(ix)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_prior_dens_',num2str(ix)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_prior_dens_' int2str(ix)]);
end
else else
saveas(gcf,[OutDir,'/',fname_,'_rmse_mc_dens_',num2str(ix)]) eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_mc_dens_' int2str(ix) '.eps']);
eval(['print -depsc2 ' OutDir '/' fname_ '_rmse_mc_dens_' int2str(ix)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_mc_dens_' int2str(ix)]); saveas(gcf,[OutDir,'/',fname_,'_rmse_mc_dens_',num2str(ix)])
eval(['print -dpdf ' OutDir '/' fname_ '_rmse_mc_dens_' int2str(ix)]);
end
end end
end end
end end

View File

@ -208,7 +208,7 @@ if fload==0,
% end % end
% end % end
%load([fname_,'_mode']) %load([fname_,'_mode'])
eval(['load ' options_.mode_file ';']'); eval(['load ' options_.mode_file '.mat;']);
if neighborhood_width>0, if neighborhood_width>0,
for j=1:nshock, for j=1:nshock,
lpmat0(:,j) = randperm(Nsam)'./(Nsam+1); %latin hypercube lpmat0(:,j) = randperm(Nsam)'./(Nsam+1); %latin hypercube
@ -237,7 +237,17 @@ if fload==0,
end end
end end
% %
h = waitbar(0,'Please wait...'); if exist('OCTAVE_VERSION') || (options_.console_mode == 1),
diary off;
if exist('OCTAVE_VERSION'),
printf('Please wait ... \r')
else
newString = 'Please wait ...';
fprintf('%s',newString)
end
else
h = waitbar(0,'Please wait...');
end
istable=[1:Nsam]; istable=[1:Nsam];
jstab=0; jstab=0;
iunstable=[1:Nsam]; iunstable=[1:Nsam];
@ -308,9 +318,24 @@ if fload==0,
ys_=real(dr_.ys); ys_=real(dr_.ys);
yys(:,j) = ys_; yys(:,j) = ys_;
ys_=yys(:,1); ys_=yys(:,1);
waitbar(j/Nsam,h,['MC iteration ',int2str(j),'/',int2str(Nsam)]) if exist('OCTAVE_VERSION') || (options_.console_mode == 1),
if exist('OCTAVE_VERSION')
printf(['MC iteration %3.i / %3.i \r'], j,Nsam);
else
s0=repmat('\b',1,length(newString));
newString=sprintf('MC iteration %3.i / %3.i', j,Nsam);
fprintf([s0,'%s'],newString);
end
else
waitbar(j/Nsam,h,['MC iteration ',int2str(j),'/',int2str(Nsam)])
end
end
if (exist('OCTAVE_VERSION') || (options_.console_mode == 1)),
fprintf('\n'),
diary on,
else
close(h)
end end
close(h)
if prepSA, if prepSA,
T=T(:,:,1:jstab); T=T(:,:,1:jstab);
end end
@ -360,38 +385,48 @@ if fload==0,
bkpprior.p4=bayestopt_.p4; bkpprior.p4=bayestopt_.p4;
if pprior, if pprior,
if ~prepSA if ~prepSA
save([OutputDirectoryName '/' fname_ '_prior'], ... save([OutputDirectoryName '/' fname_ '_prior.mat'], ...
'bkpprior','lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ... 'bkpprior','lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ...
'egg','yys','nspred','nboth','nfwrd') 'egg','yys','nspred','nboth','nfwrd')
else else
save([OutputDirectoryName '/' fname_ '_prior'], ... save([OutputDirectoryName '/' fname_ '_prior.mat'], ...
'bkpprior','lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ... 'bkpprior','lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ...
'egg','yys','T','nspred','nboth','nfwrd') 'egg','yys','T','nspred','nboth','nfwrd')
end end
else else
if ~prepSA if ~prepSA
save([OutputDirectoryName '/' fname_ '_mc'], ... save([OutputDirectoryName '/' fname_ '_mc.mat'], ...
'lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ... 'lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ...
'egg','yys','nspred','nboth','nfwrd') 'egg','yys','nspred','nboth','nfwrd')
else else
save([OutputDirectoryName '/' fname_ '_mc'], ... save([OutputDirectoryName '/' fname_ '_mc.mat'], ...
'lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ... 'lpmat','lpmat0','iunstable','istable','iindeterm','iwrong', ...
'egg','yys','T','nspred','nboth','nfwrd') 'egg','yys','T','nspred','nboth','nfwrd')
end end
end end
else else
if pprior, if pprior,
filetoload=[OutputDirectoryName '/' fname_ '_prior']; filetoload=[OutputDirectoryName '/' fname_ '_prior.mat'];
else else
filetoload=[OutputDirectoryName '/' fname_ '_mc']; filetoload=[OutputDirectoryName '/' fname_ '_mc.mat'];
end end
load(filetoload,'lpmat','lpmat0','iunstable','istable','iindeterm','iwrong','egg','yys','nspred','nboth','nfwrd') load(filetoload,'lpmat','lpmat0','iunstable','istable','iindeterm','iwrong','egg','yys','nspred','nboth','nfwrd')
Nsam = size(lpmat,1); Nsam = size(lpmat,1);
if prepSA & isempty(strmatch('T',who('-file', filetoload),'exact')), if prepSA & isempty(strmatch('T',who('-file', filetoload),'exact')),
h = waitbar(0,'Please wait...'); if exist('OCTAVE_VERSION') || (options_.console_mode == 1),
diary off;
if exist('OCTAVE_VERSION'),
printf('Please wait ... \r')
else
newString = 'Please wait ...';
fprintf('%s',newString)
end
else
h = waitbar(0,'Please wait...');
end
options_.periods=0; options_.periods=0;
options_.nomoments=1; options_.nomoments=1;
options_.irf=0; options_.irf=0;
@ -420,9 +455,24 @@ else
ys_=real(dr_.ys); ys_=real(dr_.ys);
yys(:,j) = ys_; yys(:,j) = ys_;
ys_=yys(:,1); ys_=yys(:,1);
waitbar(j/ntrans,h,['MC iteration ',int2str(j),'/',int2str(ntrans)]) if exist('OCTAVE_VERSION') || (options_.console_mode == 1),
if exist('OCTAVE_VERSION')
printf(['MC iteration %3.i / %3.i \r'], j,ntrans);
else
s0=repmat('\b',1,length(newString));
newString=sprintf('MC iteration %3.i / %3.i', j,ntrans);
fprintf([s0,'%s'],newString);
end
else
waitbar(j/ntrans,h,['MC iteration ',int2str(j),'/',int2str(ntrans)])
end
end
if exist('OCTAVE_VERSION') || (options_.console_mode == 1),
fprintf('\n'),
diary on,
else
close(h);
end end
close(h)
save(filetoload,'T','-append') save(filetoload,'T','-append')
elseif prepSA elseif prepSA
load(filetoload,'T') load(filetoload,'T')

View File

@ -73,7 +73,7 @@ if iplot
ftit=bayestopt_.name(ipar+nshock*(1-ishock)); ftit=bayestopt_.name(ipar+nshock*(1-ishock));
for i=1:ceil(nparplot/12), for i=1:ceil(nparplot/12),
figure('name',aname), hh=figure('name',aname);
for j=1+12*(i-1):min(nparplot,12*i), for j=1+12*(i-1):min(nparplot,12*i),
subplot(3,4,j-12*(i-1)) subplot(3,4,j-12*(i-1))
if ~isempty(ibehaviour), if ~isempty(ibehaviour),
@ -88,9 +88,11 @@ for i=1:ceil(nparplot/12),
% title([ftit{j},'. D-stat ', num2str(dproba(ipar(j)),2)],'interpreter','none') % title([ftit{j},'. D-stat ', num2str(dproba(ipar(j)),2)],'interpreter','none')
title([ftit{j},'. p-value ', num2str(proba(ipar(j)),2)],'interpreter','none') title([ftit{j},'. p-value ', num2str(proba(ipar(j)),2)],'interpreter','none')
end end
saveas(gcf,[dirname,'/',fname_,'_',aname,'_SA_',int2str(i)]) eval(['print -depsc2 ' dirname '/' fname_ '_' aname '_SA_' int2str(i) '.eps']);
eval(['print -depsc2 ' dirname '/' fname_ '_' aname '_SA_' int2str(i)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' dirname '/' fname_ '_' aname '_SA_' int2str(i)]); saveas(hh,[dirname,'/',fname_,'_',aname,'_SA_',int2str(i)])
if options_.nograph, close(gcf), end eval(['print -dpdf ' dirname '/' fname_ '_' aname '_SA_' int2str(i)]);
end
if options_.nograph, close(hh), end
end end
end end

View File

@ -59,7 +59,7 @@ for j=1:npar,
j2=j2+1; j2=j2+1;
if mod(j2,12)==1, if mod(j2,12)==1,
ifig=ifig+1; ifig=ifig+1;
figure('name',['Correlations in the ',fnam,' sample ', num2str(ifig)]), hh=figure('name',['Correlations in the ',fnam,' sample ', num2str(ifig)]);
end end
subplot(3,4,j2-(ifig-1)*12) subplot(3,4,j2-(ifig-1)*12)
% bar(c0(i2,j)), % bar(c0(i2,j)),
@ -78,19 +78,23 @@ for j=1:npar,
ylabel(bayestopt_.name{i2(jx)+nshock},'interpreter','none'), ylabel(bayestopt_.name{i2(jx)+nshock},'interpreter','none'),
end end
title(['cc = ',num2str(c0(i2(jx),j))]) title(['cc = ',num2str(c0(i2(jx),j))])
if (mod(j2,12)==0) & j2>0, if (mod(j2,12)==0) && j2>0,
saveas(gcf,[dirname,'/',fig_nam_,int2str(ifig)]) eval(['print -depsc2 ' dirname '/' fig_nam_ int2str(ifig) '.eps']);
eval(['print -depsc2 ' dirname '/' fig_nam_ int2str(ifig)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' dirname '/' fig_nam_ int2str(ifig)]); saveas(hh,[dirname,'/',fig_nam_,int2str(ifig)])
if options_.nograph, close(gcf), end eval(['print -dpdf ' dirname '/' fig_nam_ int2str(ifig)]);
end
if options_.nograph, close(hh), end
end end
end end
end end
end end
if (j==(npar)) & j2>0, if (j==(npar)) && j2>0,
saveas(gcf,[dirname,'/',fig_nam_,int2str(ifig)]) eval(['print -depsc2 ' dirname '/' fig_nam_ int2str(ifig) '.eps']);
eval(['print -depsc2 ' dirname '/' fig_nam_ int2str(ifig)]); if ~exist('OCTAVE_VERSION'),
eval(['print -dpdf ' dirname '/' fig_nam_ int2str(ifig)]); saveas(gcf,[dirname,'/',fig_nam_,int2str(ifig)])
eval(['print -dpdf ' dirname '/' fig_nam_ int2str(ifig)]);
end
if options_.nograph, close(gcf), end if options_.nograph, close(gcf), end
end end