2010-02-12 17:35:53 +01:00
|
|
|
function myoutput=pm3_core(myinputs,fpar,nvar,whoiam, ThisMatlab)
|
|
|
|
|
2010-05-31 11:49:24 +02:00
|
|
|
% PARALLEL CONTEXT
|
|
|
|
% Core functionality for pm3.m function, which can be parallelized.
|
2011-02-04 17:17:48 +01:00
|
|
|
|
2017-05-16 15:10:20 +02:00
|
|
|
% INPUTS
|
2016-05-19 17:13:39 +02:00
|
|
|
% See the comment in posterior_sampler_core.m funtion.
|
2010-05-31 11:49:24 +02:00
|
|
|
|
|
|
|
% OUTPUTS
|
|
|
|
% o myoutput [struc]
|
|
|
|
%
|
|
|
|
%
|
|
|
|
% SPECIAL REQUIREMENTS.
|
|
|
|
% None.
|
|
|
|
|
2022-04-13 13:15:19 +02:00
|
|
|
% Copyright © 2007-2018 Dynare Team
|
2010-02-15 16:52:36 +01:00
|
|
|
%
|
|
|
|
% This file is part of Dynare.
|
|
|
|
%
|
|
|
|
% Dynare is free software: you can redistribute it and/or modify
|
|
|
|
% it under the terms of the GNU General Public License as published by
|
|
|
|
% the Free Software Foundation, either version 3 of the License, or
|
|
|
|
% (at your option) any later version.
|
|
|
|
%
|
|
|
|
% Dynare is distributed in the hope that it will be useful,
|
|
|
|
% but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
% GNU General Public License for more details.
|
|
|
|
%
|
|
|
|
% You should have received a copy of the GNU General Public License
|
2021-06-09 17:33:48 +02:00
|
|
|
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2010-02-12 17:35:53 +01:00
|
|
|
|
2017-05-16 12:42:01 +02:00
|
|
|
if nargin<4
|
2010-02-12 17:35:53 +01:00
|
|
|
whoiam=0;
|
|
|
|
end
|
2010-05-31 11:49:24 +02:00
|
|
|
|
|
|
|
% Reshape 'myinputs' for local computation.
|
|
|
|
% In order to avoid confusion in the name space, the instruction struct2local(myinputs) is replaced by:
|
|
|
|
|
|
|
|
tit1=myinputs.tit1;
|
|
|
|
nn=myinputs.nn;
|
|
|
|
n2=myinputs.n2;
|
|
|
|
Distrib=myinputs.Distrib;
|
|
|
|
varlist=myinputs.varlist;
|
2020-06-17 20:23:49 +02:00
|
|
|
|
2010-05-31 11:49:24 +02:00
|
|
|
MaxNumberOfPlotsPerFigure=myinputs.MaxNumberOfPlotsPerFigure;
|
|
|
|
name3=myinputs.name3;
|
|
|
|
tit3=myinputs.tit3;
|
|
|
|
Mean=myinputs.Mean;
|
|
|
|
|
|
|
|
if whoiam
|
|
|
|
Parallel=myinputs.Parallel;
|
|
|
|
end
|
2010-02-12 17:35:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
global options_ M_ oo_
|
|
|
|
|
2020-06-17 20:23:49 +02:00
|
|
|
if options_.TeX
|
|
|
|
varlist_TeX=myinputs.varlist_TeX;
|
|
|
|
end
|
2010-02-12 17:35:53 +01:00
|
|
|
|
|
|
|
if whoiam
|
2011-12-13 18:32:57 +01:00
|
|
|
prct0={0,whoiam,Parallel(ThisMatlab)};
|
|
|
|
h = dyn_waitbar(prct0,'Parallel plots pm3 ...');
|
2011-02-04 17:17:48 +01:00
|
|
|
end
|
2010-02-12 17:35:53 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
figunumber = 0;
|
|
|
|
subplotnum = 0;
|
2017-03-22 16:54:11 +01:00
|
|
|
hh = dyn_figure(options_.nodisplay,'Name',[tit1 ' ' int2str(figunumber+1)]);
|
2010-02-12 17:35:53 +01:00
|
|
|
RemoteFlag = 0;
|
2017-05-16 12:42:01 +02:00
|
|
|
if whoiam
|
2010-02-12 17:35:53 +01:00
|
|
|
if Parallel(ThisMatlab).Local ==0
|
|
|
|
RemoteFlag=1;
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
OutputFileName = {};
|
|
|
|
|
|
|
|
for i=fpar:nvar
|
|
|
|
if max(abs(Mean(:,i))) > 10^(-6)
|
|
|
|
subplotnum = subplotnum+1;
|
2010-10-08 16:19:03 +02:00
|
|
|
set(0,'CurrentFigure',hh);
|
2010-02-12 17:35:53 +01:00
|
|
|
subplot(nn,nn,subplotnum);
|
2016-06-18 14:31:16 +02:00
|
|
|
if ~(all(all(Distrib(:,:,i)))>0 || ~all(all(Distrib(:,:,i)))<0)
|
|
|
|
plot([1 n2],[0 0],'-r','linewidth',0.5);
|
|
|
|
end
|
2010-02-12 17:35:53 +01:00
|
|
|
hold on
|
|
|
|
for k = 1:9
|
2010-10-08 16:19:03 +02:00
|
|
|
plot(1:n2,squeeze(Distrib(k,:,i)),'-g','linewidth',0.5);
|
2010-02-12 17:35:53 +01:00
|
|
|
end
|
2010-10-08 16:19:03 +02:00
|
|
|
plot(1:n2,Mean(:,i),'-k','linewidth',1);
|
2010-02-12 17:35:53 +01:00
|
|
|
xlim([1 n2]);
|
2010-10-08 16:19:03 +02:00
|
|
|
hold off;
|
2020-06-17 20:23:49 +02:00
|
|
|
if options_.TeX
|
|
|
|
title(['$' varlist_TeX{i,:} '$'],'Interpreter','latex')
|
|
|
|
else
|
|
|
|
title(varlist(i,:),'Interpreter','none')
|
|
|
|
end
|
2016-06-18 14:31:16 +02:00
|
|
|
yticklabels=get(gca,'yticklabel');
|
|
|
|
if size(char(yticklabels),2)>5 %make sure yticks do not screw up figure
|
|
|
|
yticks=get(gca,'ytick');
|
|
|
|
for ii=1:length(yticks)
|
|
|
|
yticklabels_new{ii,1}=sprintf('%4.3f',yticks(ii));
|
|
|
|
end
|
|
|
|
set(gca,'yticklabel',yticklabels_new)
|
|
|
|
end
|
2010-02-12 17:35:53 +01:00
|
|
|
end
|
2017-05-16 15:10:20 +02:00
|
|
|
|
2017-05-16 12:42:01 +02:00
|
|
|
if whoiam
|
2010-10-08 19:12:55 +02:00
|
|
|
if Parallel(ThisMatlab).Local==0
|
2011-12-15 11:56:23 +01:00
|
|
|
DirectoryName = CheckPath('Output',M_.dname);
|
2010-05-31 11:49:24 +02:00
|
|
|
end
|
|
|
|
end
|
2017-05-16 15:10:20 +02:00
|
|
|
|
2011-02-10 17:23:22 +01:00
|
|
|
if subplotnum == MaxNumberOfPlotsPerFigure || i == nvar
|
2017-10-10 10:05:59 +02:00
|
|
|
dyn_saveas(hh,[M_.dname '/Output/' M_.fname '_' name3 '_' tit3{i}],options_.nodisplay,options_.graph_format);
|
2017-05-16 12:42:01 +02:00
|
|
|
if RemoteFlag==1
|
2010-02-12 17:35:53 +01:00
|
|
|
OutputFileName = [OutputFileName; {[M_.dname, filesep, 'Output',filesep], [M_.fname '_' name3 '_' deblank(tit3(i,:)) '.*']}];
|
|
|
|
end
|
|
|
|
subplotnum = 0;
|
|
|
|
figunumber = figunumber+1;
|
|
|
|
if (i ~= nvar)
|
2017-03-22 16:54:11 +01:00
|
|
|
hh = dyn_figure(options_.nodisplay,'Name',[name3 ' ' int2str(figunumber+1)]);
|
2010-02-12 17:35:53 +01:00
|
|
|
end
|
|
|
|
end
|
2017-05-16 15:10:20 +02:00
|
|
|
|
2017-05-16 12:42:01 +02:00
|
|
|
if whoiam
|
2017-05-16 15:10:20 +02:00
|
|
|
% waitbarString = [ 'Variable ' int2str(i) '/' int2str(nvar) ' done.'];
|
|
|
|
% fMessageStatus((i-fpar+1)/(nvar-fpar+1),whoiam,waitbarString, waitbarTitle, Parallel(ThisMatlab));
|
2011-12-13 18:32:57 +01:00
|
|
|
dyn_waitbar((i-fpar+1)/(nvar-fpar+1),h);
|
2010-02-12 17:35:53 +01:00
|
|
|
end
|
2017-05-16 15:10:20 +02:00
|
|
|
|
|
|
|
|
2010-02-12 17:35:53 +01:00
|
|
|
end
|
|
|
|
|
2017-05-16 12:42:01 +02:00
|
|
|
if whoiam
|
2011-12-13 18:32:57 +01:00
|
|
|
dyn_waitbar_close(h);
|
|
|
|
end
|
2010-02-12 17:35:53 +01:00
|
|
|
myoutput.OutputFileName=OutputFileName;
|