Commit 5fe49585 authored by Marco Ratto's avatar Marco Ratto

Intregrate full list of options to initial_condition_decompositions, including defaults.

Adapt figure names when initial conditions are ploteed instead of shocks
parent e9607d09
......@@ -70,6 +70,11 @@ if differentiate_decomp
fig_mode1 = [fig_mode1 '_diff'];
fig_mode = [fig_mode 'diff_'];
end
if isfield(opts_decomp,'init_cond_decomp')
init_cond_decomp = opts_decomp.init_cond_decomp ;
else
init_cond_decomp = 0;
end
fig_name_long = opts_decomp.fig_name;
......@@ -117,10 +122,16 @@ if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp
fprintf(fidTeX,' \n');
end
if opts_decomp.vintage && opts_decomp.realtime>1
preamble_txt = 'Shock decomposition';
if init_cond_decomp
preamble_txt = 'Initial condition decomposition';
preamble_figname = '_initval_decomposition_';
else
preamble_txt = 'Historical shock decomposition';
preamble_figname = '_shock_decomposition_';
if opts_decomp.vintage && opts_decomp.realtime>1
preamble_txt = 'Shock decomposition';
else
preamble_txt = 'Historical shock decomposition';
end
end
if ~(screen_shocks && comp_nbr>18)
......@@ -244,18 +255,18 @@ for j=1:nvar
hold off
if ~DynareOptions.plot_shock_decomp.expand
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname,'_shock_decomposition_',endo_names{i_var(j)},fig_mode1,fig_name],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname,preamble_figname,endo_names{i_var(j)},fig_mode1,fig_name],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[endo_names{i_var(j)} fig_mode1 fig_name]);
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s%s}\n',DynareModel.fname,DynareModel.fname,[preamble_figname endo_names{i_var(j)} fig_mode1 fig_name]);
fprintf(fidTeX,'\\label{Fig:shock_decomp:%s}\n',[fig_mode endo_names{i_var(j)} fig_name]);
fprintf(fidTeX,['\\caption{' preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': $ %s $.}\n'],DynareModel.endo_names_tex{i_var(j)});
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
end
else
dyn_saveas(fhandle,[DynareOptions.plot_shock_decomp.filepath, filesep, DynareModel.fname,'_shock_decomposition_',endo_names{i_var(j)},fig_mode1,fig_name],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
dyn_saveas(fhandle,[DynareOptions.plot_shock_decomp.filepath, filesep, DynareModel.fname,preamble_figname,endo_names{i_var(j)},fig_mode1,fig_name],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
end
end
......
......@@ -72,6 +72,11 @@ if differentiate_decomp
fig_mode1 = [fig_mode1 '_diff'];
fig_mode = [fig_mode 'diff_'];
end
if isfield(opts_decomp,'init_cond_decomp')
init_cond_decomp = opts_decomp.init_cond_decomp ;
else
init_cond_decomp = 0;
end
screen_shocks = opts_decomp.screen_shocks;
if ~isempty(DynareOptions.plot_shock_decomp.use_shock_groups) || comp_nbr<=18
screen_shocks=0;
......@@ -136,10 +141,16 @@ if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp
fprintf(fidTeX,' \n');
end
if opts_decomp.vintage && opts_decomp.realtime>1
preamble_txt = 'Shock decomposition';
if init_cond_decomp
preamble_txt = 'Initial condition decomposition';
preamble_figname = '_initval_decomposition_';
else
preamble_txt = 'Historical shock decomposition';
preamble_figname = '_shock_decomposition_';
if opts_decomp.vintage && opts_decomp.realtime>1
preamble_txt = 'Shock decomposition';
else
preamble_txt = 'Historical shock decomposition';
end
end
ncol=3;
......@@ -267,18 +278,18 @@ for j=1:nvar
end
if ~DynareOptions.plot_shock_decomp.expand
dyn_saveas(fhandle,[GraphDirectoryName, filesep, DynareModel.fname, ...
'_shock_decomposition_', endo_names{i_var(j)}, fig_mode1,fig_name suffix],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
preamble_figname, endo_names{i_var(j)}, fig_mode1,fig_name suffix],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
if DynareOptions.TeX && any(strcmp('eps',cellstr(DynareOptions.plot_shock_decomp.graph_format)))
fprintf(fidTeX,'\\begin{figure}[H]\n');
fprintf(fidTeX,'\\centering \n');
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s_shock_decomposition_%s}\n',DynareModel.fname,DynareModel.fname,[endo_names{i_var(j)} fig_mode1 fig_name suffix]);
fprintf(fidTeX,'\\includegraphics[width=0.8\\textwidth]{%s/graphs/%s%s}\n',DynareModel.fname,DynareModel.fname,[preamble_figname endo_names{i_var(j)} fig_mode1 fig_name suffix]);
fprintf(fidTeX,'\\label{Fig:shock_decomp_detail:%s}\n',[fig_mode endo_names{i_var(j)} fig_name suffix]);
fprintf(fidTeX,['\\caption{' preamble_txt fig_name_long strrep(fig_mode1, '_', ' ') ': $ %s $ (detail).}\n'], DynareModel.endo_names_tex{i_var(j)});
fprintf(fidTeX,'\\end{figure}\n');
fprintf(fidTeX,' \n');
end
else
dyn_saveas(fhandle,[DynareOptions.plot_shock_decomp.filepath, filesep, DynareModel.fname,'_shock_decomposition_',endo_names{i_var(j)},fig_mode1,fig_name suffix],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
dyn_saveas(fhandle,[DynareOptions.plot_shock_decomp.filepath, filesep, DynareModel.fname,preamble_figname,endo_names{i_var(j)},fig_mode1,fig_name suffix],DynareOptions.plot_shock_decomp.nodisplay,DynareOptions.plot_shock_decomp.graph_format);
end
end
......
......@@ -38,12 +38,18 @@ function oo_ = initial_condition_decomposition(M_,oo_,options_,varlist,bayestopt
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
options_.plot_shock_decomp.colormap = options_.initial_condition_decomp.colormap;
options_.plot_shock_decomp.nodisplay = options_.initial_condition_decomp.nodisplay;
options_.plot_shock_decomp.graph_format = options_.initial_condition_decomp.graph_format;
options_.plot_shock_decomp.fig_name = options_.initial_condition_decomp.fig_name;
options_.plot_shock_decomp.detail_plot = options_.initial_condition_decomp.detail_plot;
options_.plot_shock_decomp.steadystate = options_.initial_condition_decomp.steadystate;
options_.plot_shock_decomp.write_xls = options_.initial_condition_decomp.write_xls;
options_.plot_shock_decomp.type = options_.initial_condition_decomp.type;
options_.plot_shock_decomp.plot_init_date = options_.initial_condition_decomp.plot_init_date;
options_.plot_shock_decomp.plot_end_date = options_.initial_condition_decomp.plot_end_date;
options_.plot_shock_decomp.diff = options_.initial_condition_decomp.diff;
options_.plot_shock_decomp.flip = options_.initial_condition_decomp.flip;
% indices of endogenous variables
if isempty(varlist)
......@@ -128,11 +134,7 @@ M_.exo_nbr = M_.endo_nbr;
options_.plot_shock_decomp.realtime=0;
options_.plot_shock_decomp.screen_shocks=1;
options_.plot_shock_decomp.use_shock_groups = '';
fig_name = options_.plot_shock_decomp.fig_name;
if ~isempty(fig_name)
options_.plot_shock_decomp.fig_name=[fig_name '_initval'];
else
options_.plot_shock_decomp.fig_name='initval';
end
options_.plot_shock_decomp.init_cond_decomp = 1; % private flag to plotting utilities
plot_shock_decomposition(M_,oo,options_,varlist);
% end
\ No newline at end of file
......@@ -62,6 +62,9 @@ else
expand=0;
options_.plot_shock_decomp.expand=0;
end
if ~isfield(options_.plot_shock_decomp,'init_cond_decomp')
options_.plot_shock_decomp.init_cond_decomp=0;
end
if ~isempty(options_.plot_shock_decomp.fig_name)
fig_name=[' ' options_.plot_shock_decomp.fig_name];
......
......@@ -28,9 +28,13 @@ function options = set_default_initial_condition_decomposition_options(options)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
options.initial_condition_decomp.detail_plot = 0;
options.initial_condition_decomp.steadystate = 0;
options.initial_condition_decomp.write_xls = 0;
options.initial_condition_decomp.colormap = '';
options.initial_condition_decomp.nodisplay = false;
options.initial_condition_decomp.graph_format = 'eps';
options.initial_condition_decomp.fig_name = '';
options.initial_condition_decomp.detail_plot = false;
options.initial_condition_decomp.steadystate = false;
options.initial_condition_decomp.write_xls = false;
options.initial_condition_decomp.type = '';
options.initial_condition_decomp.plot_init_date = [];
options.initial_condition_decomp.plot_end_date = [];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment