Merge rewritten history of reporting submodule
commit
50a53a22ee
|
@ -0,0 +1,12 @@
|
|||
*~
|
||||
\#*\#
|
||||
*.pdf
|
||||
*.aux
|
||||
*.log
|
||||
*.out
|
||||
*.tex
|
||||
*.csv
|
||||
*.toc
|
||||
*synctex.gz
|
||||
.DS_Store
|
||||
test/tmpRepDir
|
|
@ -0,0 +1,30 @@
|
|||
variables:
|
||||
MATLAB_VERSION: R2023b
|
||||
OLD_MATLAB_VERSION: R2014a
|
||||
|
||||
before_script:
|
||||
- git clone https://git.dynare.org/Dynare/dseries.git
|
||||
|
||||
test_matlab:
|
||||
stage: test
|
||||
script:
|
||||
- make check-matlab MATLAB=/opt/MATLAB/$MATLAB_VERSION/bin/matlab
|
||||
artifacts:
|
||||
paths:
|
||||
- test/my/report/dir/report.pdf
|
||||
|
||||
test_old_matlab:
|
||||
stage: test
|
||||
script:
|
||||
- make check-matlab MATLAB=/opt/MATLAB/$OLD_MATLAB_VERSION/bin/matlab
|
||||
artifacts:
|
||||
paths:
|
||||
- test/my/report/dir/report.pdf
|
||||
|
||||
test_octave:
|
||||
stage: test
|
||||
script:
|
||||
- make check-octave
|
||||
artifacts:
|
||||
paths:
|
||||
- test/my/report/dir/report.pdf
|
|
@ -0,0 +1,15 @@
|
|||
> Copyright © 2013-2017 Dynare Team
|
||||
>
|
||||
> License: GPL-3+
|
||||
> Dynare Reporting 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.
|
||||
>
|
||||
> This code 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.
|
||||
|
||||
> A copy of the GNU General Public License is available here
|
||||
> <https://www.gnu.org/licenses/>.
|
|
@ -0,0 +1,11 @@
|
|||
OCTAVE ?= octave-cli
|
||||
MATLAB ?= matlab
|
||||
|
||||
all: check-octave check-matlab
|
||||
|
||||
check-octave:
|
||||
@cd test ;\
|
||||
$(OCTAVE) --no-init-file --silent --no-history --eval "addpath([pwd() '/../dseries/src']); addpath([pwd() '/../src']); runtest;" && [ -f my/report/dir/report.pdf ]
|
||||
|
||||
check-matlab:
|
||||
@$(MATLAB) -nosplash -nodisplay -r "addpath([pwd '/dseries/src']); addpath([pwd '/src']); cd test; runtest; quit" && [ -f test/my/report/dir/report.pdf ]
|
|
@ -0,0 +1,38 @@
|
|||
# Dynare Reporting
|
||||
|
||||
Originally designed to provide reporting functionality for
|
||||
[Dynare](https://www.dynare.org), it has been moved to its own repository in the
|
||||
hopes that it can be used without obliging the user to download Dynare in its
|
||||
entirety.
|
||||
|
||||
# License
|
||||
|
||||
Dynare Reporting is covered by the GNU General Public Licence version 3 or
|
||||
later (see [LICENSE.md](LICENSE.md) in the Dynare Reporting distribution for
|
||||
specifics).
|
||||
|
||||
# Obtain the code that Dynare Reporting depends on
|
||||
|
||||
Dynare ```reporting``` depends on the Dynare
|
||||
[```dseries```](https://git.dynare.org/Dynare/dseries) repository and on
|
||||
utility functions from the [```dynare```](https://git.dynare.org/Dynare/dynare)
|
||||
repository, located in ```dynare/matlab/utilities/general```
|
||||
|
||||
# Use the Dynare Reporting code
|
||||
|
||||
- Open MATLAB/Octave
|
||||
- Change into the ```reporting``` directory
|
||||
- Ensure that the [```dseries```](https://git.dynare.org/Dynare/dseries)
|
||||
directory is in your path and initialized correctly (follow the directions on
|
||||
the repository site)
|
||||
- Add ```<<dynare>>/matlab/utilities/general``` to your path where
|
||||
```<<dynare>>``` refers to the base of your Dynare installation
|
||||
- Run ```initialize_reporting_toolbox```
|
||||
- Use the reporting code as outlined in the Dynare documentation
|
||||
|
||||
# Run the example code
|
||||
|
||||
- Follow the steps above
|
||||
- Change into the ```reporting/test``` directory
|
||||
- Modify the paths in ```reporting/test/runtest.m``` appropriately
|
||||
- Run the ```runtest``` matlab script
|
|
@ -0,0 +1,106 @@
|
|||
function make_report_irfs(M_, oo_, ticks_every, showOutput)
|
||||
% Builds canned IRF report
|
||||
%
|
||||
% INPUTS
|
||||
% M_ [struct]
|
||||
% oo_ [struct]
|
||||
% ticks_every [int] number of spaces between ticks. Default 5.
|
||||
% showOutput [bool] showOutput the report. Default true
|
||||
%
|
||||
% OUTPUTS
|
||||
% None
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% None
|
||||
|
||||
% Copyright © 2015-2023 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
if ~isfield(oo_, 'irfs')
|
||||
disp('make_report_irfs: oo_.irfs does not exist');
|
||||
return
|
||||
end
|
||||
fields = fieldnames(oo_.irfs);
|
||||
if isempty(fields)
|
||||
disp('make_report_irfs: oo_.irfs is empty');
|
||||
return
|
||||
end
|
||||
if ~isfield(M_, 'exo_names')
|
||||
disp('make_report_irfs: M_.exo_names does not exist');
|
||||
return
|
||||
end
|
||||
if ~isfield(M_, 'endo_names')
|
||||
disp('make_report_irfs: M_.endo_names does not exist');
|
||||
return
|
||||
end
|
||||
if ~isfield(M_, 'fname')
|
||||
disp('make_report_irfs: M_.fname does not exist');
|
||||
return
|
||||
end
|
||||
|
||||
if nargin < 3
|
||||
ticks_every = 5;
|
||||
else
|
||||
assert(isint(ticks_every));
|
||||
end
|
||||
if nargin < 4
|
||||
showOutput = true;
|
||||
else
|
||||
assert(islogical(showOutput));
|
||||
end
|
||||
n6 = 1;
|
||||
justAddedPage = 0;
|
||||
calcxticks = false;
|
||||
r = report('filename', [M_.fname '_canned_irf_report.tex'], 'showOutput', showOutput);
|
||||
for i = 1:length(M_.exo_names)
|
||||
newexo = 1;
|
||||
for j = 1:length(M_.endo_names)
|
||||
idx = ismember(fields, [M_.endo_names{j} '_' M_.exo_names{i}]);
|
||||
if (mod(n6 - 1, 6) == 0 && ~justAddedPage) || ...
|
||||
(newexo && any(idx))
|
||||
r = r.addPage('title', {'Canned Irf Report'; ['shock ' ...
|
||||
strrep(M_.exo_names{i},'_','\_')]});
|
||||
r = r.addSection('cols', 2);
|
||||
n6 = 1;
|
||||
justAddedPage = 1;
|
||||
newexo = 0;
|
||||
end
|
||||
if any(idx)
|
||||
if ~calcxticks
|
||||
data = dseries(oo_.irfs.(fields{idx})');
|
||||
xTicks = 1:ticks_every:floor(data.nobs/ticks_every)*ticks_every+1;
|
||||
xTickLabels = regexp(num2str(xTicks-1), '(?:\s)+', 'split');
|
||||
calcxticks = true;
|
||||
end
|
||||
r = r.addGraph('data', dseries(oo_.irfs.(fields{idx})'), ...
|
||||
'title', M_.endo_names{j}, '_', '\_'), ...
|
||||
'titleFormat', '\Huge', ...
|
||||
'showGrid', false, ...
|
||||
'yTickLabelZeroFill', false, ...
|
||||
'yTickLabelPrecision', 1, ...
|
||||
'showZeroLine', true, ...
|
||||
'zeroLineColor', 'red', ...
|
||||
'xTicks', xTicks, ...
|
||||
'xTickLabels', xTickLabels);
|
||||
n6 = n6 + 1;
|
||||
justAddedPage = 0;
|
||||
end
|
||||
end
|
||||
end
|
||||
r.write();
|
||||
r.compile();
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function o = addData(o, varargin)
|
||||
%function o = addData(o, varargin)
|
||||
% Add a series
|
||||
%
|
||||
% INPUTS
|
||||
% o [page] page object
|
||||
% varargin arguments to report_data()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.sections), ...
|
||||
'@page.addData: Before adding data, you must add a section.');
|
||||
o.sections{end}.addData(varargin{:});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function o = addGraph(o, varargin)
|
||||
%function o = addGraph(o, varargin)
|
||||
% Add a report_table
|
||||
%
|
||||
% INPUTS
|
||||
% o [page] page object
|
||||
% varargin arguments to graph()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.sections), ...
|
||||
'@page.addGraph: Before adding a graph, you must add a section.');
|
||||
o.sections{end}.addGraph(varargin{:});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function o = addParagraph(o, varargin)
|
||||
%function o = addParagraph(o, varargin)
|
||||
% Add a series
|
||||
%
|
||||
% INPUTS
|
||||
% o [page] page object
|
||||
% varargin arguments to paragraph()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.sections), ...
|
||||
'@page.addParagraph: Before adding a paragraph, you must add a section.');
|
||||
o.sections{end}.addParagraph(varargin{:});
|
||||
end
|
|
@ -0,0 +1,33 @@
|
|||
function o = addSection(o, varargin)
|
||||
%function o = addSection(o, varargin)
|
||||
% Add a section
|
||||
%
|
||||
% INPUTS
|
||||
% o [page] page object
|
||||
% varargin arguments to section()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated page object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
o.sections{end+1} = section(varargin{:});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function o = addSeries(o, varargin)
|
||||
%function o = addSeries(o, varargin)
|
||||
% Add a series
|
||||
%
|
||||
% INPUTS
|
||||
% o [page] page object
|
||||
% varargin arguments to report_series()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.sections), ...
|
||||
'@page.addSeries: Before adding a series, you must add a section.');
|
||||
o.sections{end}.addSeries(varargin{:});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function o = addTable(o, varargin)
|
||||
%function o = addTable(o, varargin)
|
||||
% Add a report_table
|
||||
%
|
||||
% INPUTS
|
||||
% o [page] page object
|
||||
% varargin arguments to report_table()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.sections), ...
|
||||
'@page.addTable: Before adding a table, you must add a section.');
|
||||
o.sections{end}.addTable(varargin{:});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function o = addVspace(o, varargin)
|
||||
%function o = addVspace(o, varargin)
|
||||
% Add a vspace
|
||||
%
|
||||
% INPUTS
|
||||
% o [page] page object
|
||||
% varargin arguments to vspace()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.sections), ...
|
||||
'@page.addVspace: Before adding a vspace, you must add a section.');
|
||||
o.sections{end}.addVspace(varargin{:});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function lastIndex = end(o, k, n)
|
||||
% function lastIndex = end(o, k, n)
|
||||
% End keyword
|
||||
%
|
||||
% INPUTS
|
||||
% o [page] page object
|
||||
% k [integer] index where end appears
|
||||
% n [integer] number of indices
|
||||
%
|
||||
% OUTPUTS
|
||||
% lastIndex [integer] last sections index
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(k==1 && n==1, '@page/end: page only has one dimension');
|
||||
lastIndex = numSections(o);
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
function ns = numSections(p)
|
||||
%function ns = numSections(p)
|
||||
% return the number of sections currently in the page
|
||||
%
|
||||
% INPUTS
|
||||
% none
|
||||
%
|
||||
% OUTPUTS
|
||||
% none
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
ns = length(p.sections);
|
||||
end
|
|
@ -0,0 +1,134 @@
|
|||
classdef page < handle
|
||||
% page Class
|
||||
%
|
||||
% Copyright © 2013-2022 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
properties (Access = private, Constant = true)
|
||||
titleFormatDefalut = {'\large\bfseries'}
|
||||
end
|
||||
properties (Access = private)
|
||||
sections = {}
|
||||
end
|
||||
properties (SetAccess = private)
|
||||
paper = '' % Paper size. Default: `a4'.
|
||||
title = {''} % With one entry (a STRING), the title of the page. With more than one entry (a CELL_ARRAY_STRINGS), the title and subtitle(s) of the page. Values passed must be valid LATEX code (e.g., % must be \%). Default: none.
|
||||
titleFormat = '' % A string representing the valid LATEX markup to use on title. The number of cell array entries must be equal to that of the title option if you do not want to use the default value for the title (and subtitles). Default: \large\bfseries.
|
||||
titleTruncate = '' % Useful when automatically generating page titles that may become too long, titleTruncate can be used to truncate a title (and subsequent subtitles) when they pass the specified number of characters. Default: .off.
|
||||
orientation = '' % Paper orientation: Default: `portrait'.
|
||||
footnote = {} % A footnote to be included at the bottom of this page. Default: none.
|
||||
pageDirName = 'tmpRepDir' % The name of the folder in which to store this page. Only used when the latex command is passed. Default: tmpRepDir.
|
||||
latex = '' % The valid LATEX code to be used for this page. Alows the user to create a page to be included in the report by passing LATEX code directly. Default: empty.
|
||||
setPageNumber = '' % If true, reset the page number counter. Default: false.
|
||||
removeHeaderAndFooter = false % Removes the header and footer from this page. Default: false.
|
||||
end
|
||||
methods
|
||||
function o = page(varargin)
|
||||
%function o = page(varargin)
|
||||
% Page Class Constructor
|
||||
%
|
||||
% INPUTS
|
||||
% varargin 0 args : empty page object
|
||||
% 1 arg : must be page object (return a copy of arg)
|
||||
% > 1 args: option/value pairs (see structure below for options)
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [page] page object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
o.titleFormat = o.titleFormatDefalut;
|
||||
if nargin == 0
|
||||
return
|
||||
elseif nargin == 1
|
||||
assert(isa(varargin{1}, 'page'), ...
|
||||
'@page.page: with one arg to Page constructor, you must pass a page object');
|
||||
o = varargin{1};
|
||||
return
|
||||
end
|
||||
|
||||
if round(nargin/2) ~= nargin/2
|
||||
error('@page.page: options must be supplied in name/value pairs.');
|
||||
end
|
||||
|
||||
% Octave 5.1.0 has not implemented `properties` and issues a warning when using `fieldnames`
|
||||
if isoctave
|
||||
warnstate = warning('off', 'Octave:classdef-to-struct');
|
||||
end
|
||||
optNames = fieldnames(o);
|
||||
if isoctave
|
||||
warning(warnstate);
|
||||
end
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
ind = find(strcmpi(optNames, pair{1}));
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@page.page: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
|
||||
% Check input
|
||||
if ischar(o.title)
|
||||
o.title = {o.title};
|
||||
end
|
||||
if ischar(o.titleFormat)
|
||||
o.titleFormat = {o.titleFormat};
|
||||
end
|
||||
if length(o.title) ~= length(o.titleFormat)
|
||||
o.titleFormat = repmat(o.titleFormatDefalut, 1, length(o.title));
|
||||
end
|
||||
assert(iscellstr(o.title), ...
|
||||
'@page.page: title must be a cell array of strings');
|
||||
assert(iscellstr(o.titleFormat), ...
|
||||
'@page.page: titleFormat must be a cell array of strings');
|
||||
assert((ischar(o.titleTruncate) && isempty(o.titleTruncate)) || ...
|
||||
isint(o.titleTruncate), ...
|
||||
'@page.page: titleTruncate must be empty or an integer.');
|
||||
assert(ischar(o.pageDirName), '@page.page: pageDirName must be a string');
|
||||
assert(ischar(o.latex), ...
|
||||
'@page.page: latex must be a string');
|
||||
valid_paper = {'a4', 'letter'};
|
||||
assert(any(strcmp(o.paper, valid_paper)), ...
|
||||
['@page.page: paper must be one of ' addCommasToCellStr(valid_paper)]);
|
||||
valid_orientation = {'portrait', 'landscape'};
|
||||
assert(any(strcmp(o.orientation, valid_orientation)), ...
|
||||
['@page.page: orientation must be one of ' addCommasToCellStr(valid_orientation)]);
|
||||
if ischar(o.footnote)
|
||||
o.footnote = {o.footnote};
|
||||
end
|
||||
assert(iscellstr(o.footnote), ...
|
||||
'@page.page: footnote must be a cell array of string(s)');
|
||||
assert(isempty(o.sections), ...
|
||||
'@page.page: sections is not a valid option');
|
||||
assert(isempty(o.setPageNumber) || isint(o.setPageNumber), ...
|
||||
'@page.page: setPageNumber must be an integer');
|
||||
assert(islogical(o.removeHeaderAndFooter), ...
|
||||
'@page.page: removeHeaderAndFooter must be boolean');
|
||||
end
|
||||
end
|
||||
methods (Hidden = true)
|
||||
o = addSection(o, varargin)
|
||||
o = addVspace(o, varargin)
|
||||
o = addTable(o, varargin)
|
||||
write(o, fid, pg, rep_dir)
|
||||
lastIndex = end(o, k, n)
|
||||
ns = numSections(p)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,90 @@
|
|||
function write(o, fid, pg, rep_dir)
|
||||
%function write(o, fid, pg, rep_dir)
|
||||
% Write a Page object
|
||||
%
|
||||
% INPUTS
|
||||
% o [page] page object
|
||||
% fid [integer] file id
|
||||
% pg [integer] this page number
|
||||
% rep_dir [string] directory containing report.tex
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [page] page object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
fprintf(fid, '\n%% Page Number %d written %s\n', pg, datestr(now));
|
||||
if ~isempty(o.setPageNumber)
|
||||
fprintf(fid, '\\setcounter{page}{%d}\n', o.setPageNumber);
|
||||
end
|
||||
if o.removeHeaderAndFooter
|
||||
fprintf(fid, '\\thispagestyle{empty}\n');
|
||||
end
|
||||
if strcmpi(o.orientation, 'landscape')
|
||||
fprintf(fid, '\\begin{landscape}\n');
|
||||
end
|
||||
|
||||
for i=1:length(o.footnote)
|
||||
fprintf(fid, '\\blfootnote{\\tiny %d. %s}', i, o.footnote{i});
|
||||
end
|
||||
fprintf(fid, '\n');
|
||||
|
||||
if ~isempty(o.latex)
|
||||
dir = [rep_dir '/' o.pageDirName];
|
||||
if exist(dir, 'dir') ~= 7
|
||||
mkdir(dir);
|
||||
end
|
||||
pagename = [dir '/page_' num2str(pg) '.tex'];
|
||||
[fidp, msg] = fopen(pagename, 'w');
|
||||
if fidp == -1
|
||||
error(['@page.write: ' msg]);
|
||||
end
|
||||
fprintf(fidp, '%s', o.latex);
|
||||
if fclose(fidp) == -1
|
||||
error('@page.write: closing %s\n', pagename);
|
||||
end
|
||||
fprintf(fid, '\\input{%s}', pagename);
|
||||
else
|
||||
if ~isempty(o.title)
|
||||
fprintf(fid, '\\addcontentsline{toc}{subsection}{%s}\n', o.title{1});
|
||||
end
|
||||
fprintf(fid, '\\begin{tabular}[t]{c}\n');
|
||||
for i = 1:length(o.title)
|
||||
if isint(o.titleTruncate)
|
||||
if length(o.title{i}) > o.titleTruncate
|
||||
o.title{i} = o.title{i}(1:o.titleTruncate);
|
||||
end
|
||||
end
|
||||
fprintf(fid, '\\multicolumn{1}{c}{%s %s}\\\\\n', o.titleFormat{i}, o.title{i});
|
||||
end
|
||||
|
||||
for i = 1:length(o.sections)
|
||||
o.sections{i}.write(fid, pg, i, rep_dir);
|
||||
end
|
||||
fprintf(fid, '\\end{tabular}\n');
|
||||
end
|
||||
|
||||
if strcmpi(o.orientation, 'landscape')
|
||||
fprintf(fid, '\\end{landscape}\n');
|
||||
end
|
||||
fprintf(fid, '\\clearpage\n');
|
||||
fprintf(fid, '%% End Page Object\n\n');
|
||||
end
|
|
@ -0,0 +1,86 @@
|
|||
classdef paragraph < handle
|
||||
% paragraph Class
|
||||
%
|
||||
% Copyright © 2014-2022 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
properties (SetAccess = private)
|
||||
balancedCols = true % Determines whether the text is spread out evenly across the columns when the Paragraph has more than one column. Default: true.
|
||||
cols = 1 % The number of columns for the Paragraph. Default: 1.
|
||||
heading = '' % The heading for the Paragraph (like a section heading). The string must be valid LATEX code. Default: empty.
|
||||
indent = true % Whether or not to indent the paragraph. Default: true.
|
||||
text = '' % The paragraph itself. The string must be valid LATEX code. Default: empty.
|
||||
end
|
||||
methods
|
||||
function o = paragraph(varargin)
|
||||
%function o = paragraph(varargin)
|
||||
% Paragraph Class Constructor
|
||||
%
|
||||
% INPUTS
|
||||
% varargin 0 args : empty paragraph object
|
||||
% 1 arg : must be paragraph object (return a copy of arg)
|
||||
% > 1 args: option/value pairs (see structure below for options)
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [paragraph] paragraph object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
if nargin == 0
|
||||
return
|
||||
elseif nargin == 1
|
||||
assert(isa(varargin{1}, 'paragraph'), ...
|
||||
'With one arg to Paragraph constructor, you must pass a paragraph object');
|
||||
o = varargin{1};
|
||||
return
|
||||
end
|
||||
|
||||
if round(nargin/2) ~= nargin/2
|
||||
error(['@paragraph.paragraph: options must be ' ...
|
||||
'supplied in name/value pairs.']);
|
||||
end
|
||||
|
||||
% Octave 5.1.0 has not implemented `properties` and issues a warning when using `fieldnames`
|
||||
if isoctave
|
||||
warnstate = warning('off', 'Octave:classdef-to-struct');
|
||||
end
|
||||
optNames = fieldnames(o);
|
||||
if isoctave
|
||||
warning(warnstate);
|
||||
end
|
||||
|
||||
for pair = reshape(varargin, 2, [])
|
||||
ind = find(strcmpi(optNames, pair{1}));
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@paragraph.paragraph: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
% Check input
|
||||
assert(islogical(o.indent), '@paragraph.paragraph: indent must be either true or false');
|
||||
assert(islogical(o.balancedCols), '@paragraph.paragraph: balancedCols must be either true or false');
|
||||
assert(isint(o.cols), '@paragraph.paragraph: cols must be an integer');
|
||||
assert(ischar(o.text), '@paragraph.paragraph: text must be a string');
|
||||
assert(ischar(o.heading), '@paragraph.paragraph: heading must be a string');
|
||||
end
|
||||
end
|
||||
methods (Hidden = true)
|
||||
% Methods defined in separate files
|
||||
write(o, fid);
|
||||
end
|
||||
end
|
|
@ -0,0 +1,60 @@
|
|||
function write(o, fid)
|
||||
%function write(o, fid)
|
||||
% Write Paragraph object
|
||||
%
|
||||
% INPUTS
|
||||
% o [paragraph] paragraph object
|
||||
% fid [integer] file id
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [paragraph] paragraph object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2014-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
fprintf(fid, '%% Paragraph Object written %s\n', datestr(now));
|
||||
fprintf(fid, '\\multicolumn{1}{p{\\linewidth}}{%%\n');
|
||||
if o.cols ~= 1
|
||||
bc = '';
|
||||
if o.balancedCols
|
||||
bc = '*';
|
||||
end
|
||||
fprintf(fid, '\\begin{multicols%s}{%d}%%\n', bc, o.cols);
|
||||
end
|
||||
|
||||
if ~isempty(o.heading)
|
||||
if o.cols ~= 1
|
||||
fprintf(fid, '[%s\n]\n', o.heading);
|
||||
else
|
||||
fprintf(fid, '%s\\newline \\newline\n', o.heading);
|
||||
end
|
||||
end
|
||||
|
||||
if o.indent
|
||||
fprintf(fid, '\\hspace{4ex}');
|
||||
end
|
||||
|
||||
fprintf(fid, '%s', o.text);
|
||||
|
||||
if o.cols ~= 1
|
||||
fprintf(fid, '\\end{multicols%s}\n', bc);
|
||||
end
|
||||
fprintf(fid, '}\n%% End Paragraph Object\n\n');
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function o = addData(o, varargin)
|
||||
%function o = addData(o, varargin)
|
||||
% Add data
|
||||
%
|
||||
% INPUTS
|
||||
% o [report] report object
|
||||
% varargin arguments to report_data()
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report] updated report object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.pages), ...
|
||||
'@report.addData: Before adding data, you must add a page, section, and a table.');
|
||||
o.pages{end}.addData(varargin{:});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function o = addGraph(o, varargin)
|
||||
%function o = addGraph(o, varargin)
|
||||
% Add a graph
|
||||
%
|
||||
% INPUTS
|
||||
% o [report] report object
|
||||
% varargin arguments to graph()
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report] updated report object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.pages) > 0, ...
|
||||
'@report.addGraph: Before adding a graph, you must add a page and a section.');
|
||||
o.pages{end}.addGraph(varargin{:});
|
||||
end
|
|
@ -0,0 +1,37 @@
|
|||
function o = addPage(o, varargin)
|
||||
%function o = addPage(o, varargin)
|
||||
% Add a page
|
||||
%
|
||||
% INPUTS
|
||||
% o [report] report object
|
||||
% varargin arguments to @section/addGraph.m
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report] updated report object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
np = length(o.pages) + 1;
|
||||
if o.showOutput
|
||||
fprintf(1, 'Adding Page: %d\n', np);
|
||||
end
|
||||
o.pages{np} = page('orientation', o.orientation, 'paper', o.paper, varargin{:});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function o = addParagraph(o, varargin)
|
||||
%function o = addParagraph(o, varargin)
|
||||
% Add a paragraph
|
||||
%
|
||||
% INPUTS
|
||||
% o [report] report object
|
||||
% varargin arguments to paragraph()
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report] updated report object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.pages) > 0, ...
|
||||
'@report.addParagraph: Before adding a paragraph, you must add a page and a section.');
|
||||
o.pages{end}.addParagraph(varargin{:});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function o = addSection(o, varargin)
|
||||
%function o = addSection(o, varargin)
|
||||
% Add a section
|
||||
%
|
||||
% INPUTS
|
||||
% o [report] report object
|
||||
% varargin arguments to section()
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report] updated report object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.pages) > 0, ...
|
||||
'@report.addSection: Before adding a section, you must add a page.');
|
||||
o.pages{end}.addSection(varargin{:});
|
||||
end
|
|
@ -0,0 +1,36 @@
|
|||
function o = addSeries(o, varargin)
|
||||
%function o = addSeries(o, varargin)
|
||||
% Add a graph to the current section of the current page in the report
|
||||
%
|
||||
% INPUTS
|
||||
% o [report] report object
|
||||
% varargin arguments to report_series()
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report] updated report object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.pages), ...
|
||||
['@report.addSeries: Before adding a series, you must add a page, ' ...
|
||||
'section, and either a graph or a table.']);
|
||||
o.pages{end}.addSeries(varargin{:});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function o = addTable(o, varargin)
|
||||
%function o = addTable(o, varargin)
|
||||
% Add a table to the current section of the current page in the report
|
||||
%
|
||||
% INPUTS
|
||||
% o [report] report object
|
||||
% varargin arguments to report_table()
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report] updated report object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.pages), ...
|
||||
'@report.addTable: Before adding a table, you must add a page and a section.');
|
||||
o.pages{end}.addTable(varargin{:});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function o = addVspace(o, varargin)
|
||||
%function o = addVspace(o, varargin)
|
||||
% Add a vspace to the current section of the current page in the report
|
||||
%
|
||||
% INPUTS
|
||||
% o [report] report object
|
||||
% varargin arguments to @section/addVspace.m
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report] updated report object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.pages), ...
|
||||
'@report.addVspace: Before adding a vspace, you must add a page and a section.');
|
||||
o.pages{end}.addVspace(varargin{:});
|
||||
end
|
|
@ -0,0 +1,136 @@
|
|||
function o = compile(o, varargin)
|
||||
%function o = compile(o)
|
||||
% Compile Report Object
|
||||
%
|
||||
% INPUTS
|
||||
% o [report] report object
|
||||
% varargin [char] allows user to change report compiler for a
|
||||
% given run of compile.
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report] report object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
opts.compiler = o.compiler;
|
||||
opts.showReport = true;
|
||||
opts.showOutput = o.showOutput;
|
||||
|
||||
if nargin > 1
|
||||
if round((nargin-1)/2) ~= (nargin-1)/2
|
||||
error('@report.compile: options must be supplied in name/value pairs');
|
||||
end
|
||||
|
||||
optNames = fieldnames(opts);
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
ind = find(strcmpi(optNames, pair{1}));
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
opts.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@report.compile: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
assert(ischar(opts.compiler), '@report.compile: compiler file must be a string');
|
||||
assert(islogical(opts.showReport), '@report.compile: showReport must be either true or false');
|
||||
assert(islogical(opts.showOutput), '@report.compile: showOutput must be either true or false');
|
||||
|
||||
if exist([o.directory '/' o.fileName], 'file') ~= 2
|
||||
o.write();
|
||||
end
|
||||
|
||||
middle = ' ./';
|
||||
if isempty(opts.compiler)
|
||||
status = 1;
|
||||
if ismac
|
||||
% Add most likely places for pdflatex to exist outside of default $PATH
|
||||
[status, opts.compiler] = ...
|
||||
system('PATH=$PATH:/usr/texbin:/usr/local/bin:/usr/local/sbin:/Library/TeX/texbin;which pdflatex');
|
||||
elseif ispc
|
||||
[status, opts.compiler] = system('findtexmf --file-type=exe pdflatex');
|
||||
if status == 1
|
||||
[status] = system('pdflatex.exe --version');
|
||||
if status == 0
|
||||
opts.compiler = 'pdflatex.exe';
|
||||
end
|
||||
end
|
||||
middle = ' ';
|
||||
opts.compiler = ['"' strtrim(opts.compiler) '"'];
|
||||
elseif isunix
|
||||
% “which” has been deprecated in Debian Bookworm; rather use “command -v”
|
||||
% which should work with any reasonably recent GNU/Linux shell
|
||||
[status, opts.compiler] = system('command -v pdflatex');
|
||||
end
|
||||
assert(status == 0, ...
|
||||
'@report.compile: Could not find a tex compiler on your system');
|
||||
opts.compiler = strtrim(opts.compiler);
|
||||
o.compiler = opts.compiler;
|
||||
if opts.showOutput
|
||||
disp(['Using compiler: ' o.compiler]);
|
||||
end
|
||||
end
|
||||
|
||||
orig_dir = pwd;
|
||||
cd(o.directory)
|
||||
options = '-synctex=1 -halt-on-error';
|
||||
[~, rfn] = fileparts(o.fileName);
|
||||
if ~isempty(o.maketoc)
|
||||
% TOC compilation requires two passes
|
||||
compile_tex(o, orig_dir, opts, [options ' -draftmode'], middle, rfn);
|
||||
end
|
||||
if status ~= 0
|
||||
cd(orig_dir)
|
||||
error(['@report.compile: There was an error in compiling ' rfn '.pdf.' ...
|
||||
' ' opts.compiler ' returned the error code: ' num2str(status)]);
|
||||
end
|
||||
compile_tex(o, orig_dir, opts, options, middle, rfn);
|
||||
|
||||
if o.showOutput || opts.showOutput
|
||||
fprintf('Done.\n\nYour compiled report is located here:\n %s.pdf\n\n\n', [pwd '/' rfn])
|
||||
end
|
||||
if opts.showReport && ~isoctave
|
||||
open([rfn '.pdf']);
|
||||
end
|
||||
cd(orig_dir)
|
||||
end
|
||||
|
||||
function compile_tex(o, orig_dir, opts, options, middle, rfn)
|
||||
if opts.showOutput
|
||||
if isoctave
|
||||
system([opts.compiler ' ' options middle o.fileName]);
|
||||
status = 0;
|
||||
else
|
||||
status = system([opts.compiler ' ' options middle o.fileName], '-echo');
|
||||
end
|
||||
else
|
||||
status = system([opts.compiler ' -interaction=batchmode ' options middle o.fileName]);
|
||||
end
|
||||
|
||||
if status ~= 0
|
||||
cd(orig_dir)
|
||||
error(['@report.compile: There was an error in compiling ' rfn '.pdf.' ...
|
||||
' ' opts.compiler ' returned the error code: ' num2str(status)]);
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
function n = numPages(o)
|
||||
%function n = numPages(o)
|
||||
% return the number of pages currently in the report
|
||||
%
|
||||
% INPUTS
|
||||
% o [report] report object
|
||||
%
|
||||
% OUTPUTS
|
||||
% n [integer] number of pages in the report object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
n = length(o.pages);
|
||||
end
|
|
@ -0,0 +1,123 @@
|
|||
classdef report < handle
|
||||
% report Class
|
||||
%
|
||||
% Copyright © 2013-2022 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
properties (Access = private)
|
||||
pages = {}
|
||||
end
|
||||
properties (SetAccess = private)
|
||||
directory = '.' % Directory in which to write/compile the report. Default: '.'
|
||||
title = '' % Report Title. Default: none.
|
||||
orientation = 'portrait' % Paper orientation: Default: `portrait'.
|
||||
paper = 'a4' % Paper size. Default: `a4'.
|
||||
margin = 2.5 % The margin size. Default: 2.5.
|
||||
marginUnit = 'cm' % Units associated with the margin. Default: `cm'.
|
||||
fileName = 'report' % The file name to use when saving this report. Default: report.tex.
|
||||
showDate = true % Display the date and time when the report was compiled. Default: true.
|
||||
compiler = '' % The full path to the LATEX compiler on your system
|
||||
showOutput = true % Print report creation progress to screen. Shows you the page number as it is created and as it is written. This is useful to see where a potential error occurs in report creation. Default: true.
|
||||
header = '' % The valid LATEX code to be included in the report before \begin{document}. Default: empty.
|
||||
reportDirName = 'tmpRepDir' % The name of the folder in which to store the component parts of the report (preamble, document, end). Default: tmpRepDir.
|
||||
maketoc = false % Whether or not to make a table of contents. Default: false.
|
||||
end
|
||||
methods
|
||||
function o = report(varargin)
|
||||
%function o = report(varargin)
|
||||
% Report Class Constructor
|
||||
%
|
||||
% INPUTS
|
||||
% varargin 0 args : empty report object
|
||||
% 1 arg : must be report object (return a copy of arg)
|
||||
% > 1 args: option/value pairs (see structure below for options)
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report] report object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
if nargin == 0
|
||||
return
|
||||
elseif nargin == 1
|
||||
assert(isa(varargin{1}, 'report'), ...
|
||||
'@report.report: with one arg, you must pass a report object');
|
||||
o = varargin{1};
|
||||
return
|
||||
end
|
||||
|
||||
if round(nargin/2) ~= nargin/2
|
||||
error('@report.report: options must be supplied in name/value pairs');
|
||||
end
|
||||
|
||||
% Octave 5.1.0 has not implemented `properties` and issues a warning when using `fieldnames`
|
||||
if isoctave
|
||||
warnstate = warning('off', 'Octave:classdef-to-struct');
|
||||
end
|
||||
optNames = fieldnames(o);
|
||||
if isoctave
|
||||
warning(warnstate);
|
||||
end
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
ind = find(strcmpi(optNames, pair{1}));
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@report.report: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
|
||||
% Check options provided by user
|
||||
assert(ischar(o.directory), '@report.report: directory must be a string');
|
||||
assert(ischar(o.title), '@report.report: title must be a string');
|
||||
assert(ischar(o.fileName), '@report.report: fileName must be a string');
|
||||
assert(ischar(o.compiler), '@report.report: compiler file must be a string');
|
||||
assert(islogical(o.showDate), '@report.report: showDate must be either true or false');
|
||||
assert(islogical(o.showOutput), '@report.report: showOutput must be either true or false');
|
||||
assert(isfloat(o.margin) && o.margin > 0, '@report.report: margin must be a float > 0.');
|
||||
assert(ischar(o.header), '@report.report: header must be a string');
|
||||
assert(ischar(o.reportDirName), '@report.report: reportDirName must be a string');
|
||||
valid_margin_unit = {'cm', 'in'};
|
||||
assert(any(strcmp(o.marginUnit, valid_margin_unit)), ...
|
||||
['@report.report: marginUnit must be one of ' addCommasToCellStr(valid_margin_unit)]);
|
||||
|
||||
valid_paper = {'a4', 'letter'};
|
||||
assert(any(strcmp(o.paper, valid_paper)), ...
|
||||
['@report.report: paper must be one of ' addCommasToCellStr(valid_paper)]);
|
||||
|
||||
valid_orientation = {'portrait', 'landscape'};
|
||||
assert(any(strcmp(o.orientation, valid_orientation)), ...
|
||||
['@report.report: orientation must be one of ' addCommasToCellStr(valid_orientation)]);
|
||||
assert(islogical(o.maketoc), '@report.report: maketock must be logical');
|
||||
end
|
||||
o = addPage(o, varargin)
|
||||
o = addSection(o, varargin)
|
||||
o = addGraph(o, varargin)
|
||||
o = addTable(o, varargin)
|
||||
o = addVspace(o, varargin)
|
||||
o = addParagraph(o, varargin)
|
||||
o = addSeries(o, varargin)
|
||||
o = addData(o, varargin)
|
||||
o = compile(o, varargin)
|
||||
o = write(o)
|
||||
end
|
||||
methods (Hidden = true)
|
||||
n = numPages(o)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,182 @@
|
|||
function o = write(o)
|
||||
%function o = write(o)
|
||||
% Write Report object
|
||||
%
|
||||
% INPUTS
|
||||
% o [report] report object
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report] report object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
if exist(o.directory, 'dir') ~= 7
|
||||
mkdir(o.directory);
|
||||
end
|
||||
if exist([o.directory '/' o.reportDirName], 'dir') ~= 7
|
||||
mkdir([o.directory '/' o.reportDirName]);
|
||||
end
|
||||
idx = strfind(o.fileName, '.tex');
|
||||
if isempty(idx) || ~strcmp(o.fileName(idx:end), '.tex')
|
||||
preamble_file_name = [o.reportDirName '/' o.fileName '_preamble.tex'];
|
||||
document_file_name = [o.reportDirName '/' o.fileName '_document.tex'];
|
||||
page_file_name_root = [o.reportDirName '/' o.fileName '_pg'];
|
||||
o.fileName = [o.fileName '.tex'];
|
||||
else
|
||||
preamble_file_name = [o.reportDirName '/' o.fileName(1:idx-1) '_preamble.tex'];
|
||||
document_file_name = [o.reportDirName '/' o.fileName(1:idx-1) '_document.tex'];
|
||||
page_file_name_root = [o.reportDirName '/' o.fileName(1:idx-1) '_pg'];
|
||||
end
|
||||
|
||||
%% Create preamble
|
||||
[fid_preamble, msg] = fopen([o.directory '/' preamble_file_name], 'w');
|
||||
if fid_preamble == -1
|
||||
error(['@report.write: ' msg]);
|
||||
end
|
||||
|
||||
fprintf(fid_preamble, '%% Report Object written %s\n', datestr(now));
|
||||
fprintf(fid_preamble, '\\documentclass[11pt,notitlepage]{article}\n');
|
||||
|
||||
fprintf(fid_preamble, '\\usepackage[%spaper,margin=%f%s', o.paper, o.margin, o.marginUnit);
|
||||
if strcmpi(o.orientation, 'landscape')
|
||||
fprintf(fid_preamble, ',landscape');
|
||||
end
|
||||
fprintf(fid_preamble, ']{geometry}\n');
|
||||
fprintf(fid_preamble, '\\usepackage{pdflscape, booktabs, pgfplots, colortbl, adjustbox, multicol}\n');
|
||||
fprintf(fid_preamble, '\\pgfplotsset{compat=1.5.1}');
|
||||
fprintf(fid_preamble, ['\\makeatletter\n' ...
|
||||
'\\def\\blfootnote{\\gdef\\@thefnmark{}\\@footnotetext}\n' ...
|
||||
'\\makeatother\n']);
|
||||
|
||||
if isoctave && isempty(regexpi(computer, '.*apple.*', 'once'))
|
||||
fprintf(fid_preamble, '\\usepackage[T1]{fontenc}\n');
|
||||
fprintf(fid_preamble, '\\usepackage[utf8x]{inputenc}\n');
|
||||
end
|
||||
if ispc || ismac
|
||||
fprintf(fid_preamble, '\\usepgfplotslibrary{fillbetween}\n');
|
||||
end
|
||||
fprintf(fid_preamble, '\\definecolor{LightCyan}{rgb}{0.88,1,1}\n');
|
||||
fprintf(fid_preamble, '\\definecolor{Gray}{gray}{0.9}\n');
|
||||
|
||||
if o.showDate
|
||||
fprintf(fid_preamble, '\\usepackage{fancyhdr, datetime}\n');
|
||||
fprintf(fid_preamble, '\\newdateformat{reportdate}{\\THEDAY\\ \\shortmonthname\\ \\THEYEAR}\n');
|
||||
fprintf(fid_preamble, '\\pagestyle{fancy}\n');
|
||||
fprintf(fid_preamble, '\\renewcommand{\\headrulewidth}{0pt}\n');
|
||||
fprintf(fid_preamble, '\\renewcommand{\\footrulewidth}{0.5pt}\n');
|
||||
fprintf(fid_preamble, '\\rfoot{\\scriptsize\\reportdate\\today\\ -- \\currenttime}\n');
|
||||
end
|
||||
|
||||
% May not need these.....
|
||||
fprintf(fid_preamble, '\\renewcommand{\\textfraction}{0.05}\n');
|
||||
fprintf(fid_preamble, '\\renewcommand{\\topfraction}{0.8}\n');
|
||||
fprintf(fid_preamble, '\\renewcommand{\\bottomfraction}{0.8}\n');
|
||||
fprintf(fid_preamble, '\\setlength{\\parindent}{0in}\n');
|
||||
fprintf(fid_preamble, '\\setlength{\\tabcolsep}{1em}\n');
|
||||
fprintf(fid_preamble, '\\newlength\\sectionheight\n');
|
||||
if ~isempty(o.header)
|
||||
fprintf(fid_preamble, '%s\n', o.header);
|
||||
end
|
||||
|
||||
%% Write body of document
|
||||
[fid_document, msg] = fopen([o.directory '/' document_file_name], 'w');
|
||||
if fid_document == -1
|
||||
error(['@report.write: ' msg]);
|
||||
end
|
||||
|
||||
if ~isempty(o.title)
|
||||
if o.showDate
|
||||
fprintf(fid_preamble, '\\newdateformat{reportdatelong}{\\THEDAY\\ \\monthname\\ \\THEYEAR}\n');
|
||||
end
|
||||
fprintf(fid_document, '\\title{\\huge\\bfseries %s\\vspace{-1em}}\n\\author{}\n', o.title);
|
||||
if o.showDate
|
||||
fprintf(fid_document, '\\date{\\reportdatelong\\today}\n');
|
||||
else
|
||||
fprintf(fid_document, '\\date{}\n');
|
||||
end
|
||||
fprintf(fid_document, '\\maketitle\n');
|
||||
end
|
||||
|
||||
if o.maketoc
|
||||
if o.showDate
|
||||
fprintf(fid_preamble, '\\rhead{}\n\\lhead{}\n');
|
||||
end
|
||||
fprintf(fid_document, '\\tableofcontents\n');
|
||||
end
|
||||
|
||||
if ~isempty(o.title) || o.maketoc
|
||||
fprintf(fid_document, '\\clearpage\n');
|
||||
end
|
||||
|
||||
if isunix && ~ismac
|
||||
fprintf(fid_document, '\\pgfdeclarelayer{axis background}\n');
|
||||
fprintf(fid_document, '\\pgfdeclarelayer{axis lines}\n');
|
||||
fprintf(fid_document, '\\pgfsetlayers{axis background,axis lines,main}\n');
|
||||
end
|
||||
fprintf(fid_document, '\\pgfplotsset{tick scale binop={\\times},\ntrim axis left}\n');
|
||||
fprintf(fid_document, '\\centering\n');
|
||||
|
||||
for i = 1:length(o.pages)
|
||||
if o.showOutput
|
||||
fprintf(1, 'Writing Page: %d\n', i);
|
||||
end
|
||||
page_file_name = [page_file_name_root num2str(i) '.tex'];
|
||||
[fid_pg, msg] = fopen([o.directory '/' page_file_name], 'w');
|
||||
if fid_pg == -1
|
||||
error(['@report.write: ' msg]);
|
||||
end
|
||||
o.pages{i}.write(fid_pg, i, o.directory);
|
||||
status = fclose(fid_pg);
|
||||
if status == -1
|
||||
error('@report.write: closing %s\n', o.fileName);
|
||||
end
|
||||
fprintf(fid_document, '\\input{%s}\n', page_file_name);
|
||||
end
|
||||
|
||||
%% Close preamble, document
|
||||
fprintf(fid_preamble, '\\begin{document}\n');
|
||||
status = fclose(fid_preamble);
|
||||
if status == -1
|
||||
error('@report.write: closing %s\n', preamble_file_name);
|
||||
end
|
||||
|
||||
status = fclose(fid_document);
|
||||
if status == -1
|
||||
error('@report.write: closing %s\n', document_file_name);
|
||||
end
|
||||
|
||||
%% Create report comprised of preamble and document
|
||||
[fid, msg] = fopen([o.directory '/' o.fileName], 'w');
|
||||
if fid == -1
|
||||
error(['@report.write: ' msg]);
|
||||
end
|
||||
fprintf(fid, '\\input{%s}\n\\input{%s}\n', ...
|
||||
preamble_file_name, document_file_name);
|
||||
fprintf(fid, '\\end{document}\n');
|
||||
status = fclose(fid);
|
||||
if status == -1
|
||||
error('@report.write: closing %s\n', o.fileName);
|
||||
end
|
||||
|
||||
if o.showOutput
|
||||
disp('Finished Writing Report!');
|
||||
end
|
||||
end
|
|
@ -0,0 +1,83 @@
|
|||
classdef report_data < handle
|
||||
% report_data Class to write a page to the report
|
||||
%
|
||||
% Copyright © 2019-2022 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
properties (SetAccess = private)
|
||||
data = ''
|
||||
tableAlignRight = false
|
||||
tableRowColor = 'white'
|
||||
tableRowIndent = 0
|
||||
tableNaNSymb = 'NaN'
|
||||
tablePrecision = ''
|
||||
zeroTol = 1e-6
|
||||
end
|
||||
properties
|
||||
column_names = ''
|
||||
end
|
||||
methods
|
||||
function o = report_data(varargin)
|
||||
%function o = report_data(varargin)
|
||||
% report_data Class Constructor
|
||||
%
|
||||
% INPUTS
|
||||
% varargin 0 args : empty report_data object
|
||||
% 1 arg : must be report_data object (return a copy of arg)
|
||||
% > 1 args: option/value pairs (see structure below for options)
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report_data] report_data object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
if nargin == 0
|
||||
return
|
||||
elseif nargin == 1
|
||||
assert(isa(varargin{1}, 'report_data'), ...
|
||||
'@report_data.report_data: with one arg you must pass a report_data object');
|
||||
o = varargin{1};
|
||||
return
|
||||
end
|
||||
if round(nargin/2) ~= nargin/2
|
||||
error('@report_data.report_data: options must be supplied in name/value pairs.');
|
||||
end
|
||||
|
||||
% Octave 5.1.0 has not implemented `properties` and issues a warning when using `fieldnames`
|
||||
if isoctave
|
||||
warnstate = warning('off', 'Octave:classdef-to-struct');
|
||||
end
|
||||
optNames = fieldnames(o);
|
||||
if isoctave
|
||||
warning(warnstate);
|
||||
end
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
ind = find(strcmpi(optNames, pair{1}));
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@report_data.report_data: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
methods (Hidden = true)
|
||||
writeDataForTable(o, fid, precision)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,97 @@
|
|||
function writeDataForTable(o, fid, precision)
|
||||
%function writeDataForTable(o, fid, precision)
|
||||
% Write Table Data
|
||||
%
|
||||
% INPUTS
|
||||
% o [report_data] report_data object
|
||||
% fid [int] file id
|
||||
% precision [float] precision with which to print the data
|
||||
%
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report_data] report_data object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
%% Validate options provided by user
|
||||
assert(ischar(o.tableRowColor), '@report_data.writeDataForTable: tableRowColor must be a string');
|
||||
assert(isint(o.tableRowIndent) && o.tableRowIndent >= 0, ...
|
||||
'@report_data.writeDataForTable: tableRowIndent must be an integer >= 0');
|
||||
assert(islogical(o.tableAlignRight), '@report_data.writeDataForTable: tableAlignRight must be true or false');
|
||||
assert(ischar(o.tableNaNSymb), '@report_data.writeDataForTable: tableNaNSymb must be a string');
|
||||
|
||||
if ~isempty(o.tablePrecision)
|
||||
assert(isint(o.tablePrecision) && o.tablePrecision >= 0, ...
|
||||
'@report_data.writeDataForTable: tablePrecision must be a non-negative integer');
|
||||
precision = o.tablePrecision;
|
||||
end
|
||||
rounding = 10^precision;
|
||||
|
||||
%% Write Output
|
||||
fprintf(fid, '%% Table Data (report_data)\n');
|
||||
[nrows, ncols] = size(o.data);
|
||||
for i = 1:nrows
|
||||
fprintf(fid, '\\rowcolor{%s}', o.tableRowColor);
|
||||
if o.tableAlignRight
|
||||
fprintf(fid, '\\multicolumn{1}{r}{');
|
||||
end
|
||||
if o.tableRowIndent == 0
|
||||
fprintf(fid, '\\noindent ');
|
||||
else
|
||||
for j=1:o.tableRowIndent
|
||||
fprintf(fid,'\\indent ');
|
||||
end
|
||||
end
|
||||
if o.tableAlignRight
|
||||
fprintf(fid, '}');
|
||||
end
|
||||
for j = 1:ncols
|
||||
val = o.data(i,j);
|
||||
if iscell(val)
|
||||
val = val{:};
|
||||
end
|
||||
if isnan(val)
|
||||
val = o.tableNaNSymb;
|
||||
dataString = '%s';
|
||||
elseif isnumeric(val)
|
||||
dataString = sprintf('%%.%df', precision);
|
||||
if val < o.zeroTol && val > -o.zeroTol
|
||||
val = 0;
|
||||
end
|
||||
% Use round half away from zero rounding
|
||||
val = round(val*rounding)/rounding;
|
||||
if isnan(val)
|
||||
val = o.tableNaNSymb;
|
||||
dataString = '%s';
|
||||
end
|
||||
else
|
||||
dataString = '%s';
|
||||
val = regexprep(val, '_', '\\_');
|
||||
end
|
||||
fprintf(fid, dataString, val);
|
||||
if j ~= ncols
|
||||
fprintf(fid, ' & ');
|
||||
else
|
||||
fprintf(fid, '\\\\%%\n');
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,33 @@
|
|||
function o = addSeries(o, varargin)
|
||||
%function o = addSeries(o, varargin)
|
||||
% Add a series
|
||||
%
|
||||
% INPUTS
|
||||
% o [report_graph] report_graph object
|
||||
% varargin arguments to report_series()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2020 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
o.series{end+1} = report_series(varargin{:});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function lastIndex = end(o, k, n)
|
||||
% function lastIndex = end(o, k, n)
|
||||
% End keyword
|
||||
%
|
||||
% INPUTS
|
||||
% o [report_graph] report_graph object
|
||||
% k [integer] index where end appears
|
||||
% n [integer] number of indices
|
||||
%
|
||||
% OUTPUTS
|
||||
% lastIndex [integer] last graph index
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2020 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(k==1 && n==1, '@report_graph/end: graph only has one dimension');
|
||||
lastIndex = length(o.series);
|
||||
end
|
|
@ -0,0 +1,221 @@
|
|||
classdef report_graph < handle
|
||||
% report_graph Class
|
||||
%
|
||||
% Copyright © 2013-2022 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
properties (Access = private)
|
||||
series = {}
|
||||
end
|
||||
properties (SetAccess = private)
|
||||
title = '' % With one entry (a STRING), the title of the page. With more than one entry (a CELL_ARRAY_STRINGS), the title and subtitle(s) of the page. Values passed must be valid LATEX code (e.g., % must be \%). Default: none.
|
||||
titleFormat = '' % The format to use for the graph title. Unlike other titleFormat options, due to a constraint of TikZ, this format applies to the title and subtitles. Default: TikZ default.
|
||||
titleFontSize = 'normalsize' % The font size for title. Default: normalsize.
|
||||
ylabel = '' % The x-axis label. Default: none.
|
||||
xlabel = '' % The y-axis label. Default: none.
|
||||
axisShape = 'box' % The shape the axis should have. `box' means that there is an axis line to the left, right, bottom, and top of the graphed line(s). ?L??? means that there is an axis to the left and bottom of the graphed line(s). Default: `box'.
|
||||
graphDirName = 'tmpRepDir' % The name of the folder in which to store this figure. Default: tmpRepDir.
|
||||
graphName = '' % The name to use when saving this figure. Default: something of the form graph_pg1_sec2_row1_col3.tex.
|
||||
data = '' % The dseries that provides the data for the graph. Default: none.
|
||||
seriesToUse = '' % The names of the series contained in the dseries provided to the data option. If empty, use all series provided to data option. Default: empty.
|
||||
xrange = '' % The boundary on the x-axis to display in the graph. Default: all.
|
||||
xAxisTight = true % Use a tight x axis. If false, uses PGFPLOTS/TikZ enlarge x limits to choose appropriate axis size. Default: true.
|
||||
yrange = '' % The boundary on the y-axis to display in the graph, represented as a NUMERICAL_VECTOR of size 2, with the first entry less than the second entry. Default: all.
|
||||
yAxisTight = false % Use a tight y axis. If false, uses PGFPLOTS/TikZ enlarge y limits to choose appropriate axis size. Default: false.
|
||||
shade = '' % The date range showing the portion of the graph that should be shaded. Default: none.
|
||||
shadeColor = 'green' % The color to use in the shaded portion of the graph. All valid color strings defined for use by PGFPLOTS/TikZ are valid. Furthermore, You can use combinations of these colors. For example, if you wanted a color that is 20% green and 80% purple, you could pass the string 'green!20!purple'. You can also use RGB colors, following the syntax: `rgb,255:red,231;green,84;blue,121' which corresponds to the RGB color (231;84;121). More examples are available in the section 4.7.5 of the PGFPLOTS/TikZ manual, revision 1.10. Default: `green'
|
||||
shadeOpacity = 20 % The opacity of the shaded area, must be in [0,100]. Default: 20.
|
||||
showGrid = true % Whether or not to display the major grid on the graph. Default: true.
|
||||
showLegend = false % Whether or not to display the legend. Unless you use the graphLegendName option, the name displayed in the legend is the tex name associated with the dseries. You can modify this tex name by using tex_rename. Default: false.
|
||||
legendAt = [] % The coordinates for the legend location. If this option is passed, it overrides the legendLocation option. Must be of size 2. Default: empty.
|
||||
showLegendBox = false % Whether or not to display a box around the legend. Default: false.
|
||||
legendLocation = 'south east' % Where to place the legend in the graph. Default: `south east'.
|
||||
legendOrientation = 'horizontal' % Orientation of the legend. Default: `horizontal'.
|
||||
legendFontSize = 'tiny' % The font size for legend entries. Default: tiny.
|
||||
showZeroline = false % Display a solid black line at y = 0. Default: false.
|
||||
zeroLineColor = 'black' % The color to use for the zero line. Only used if showZeroLine is true. See the explanation in shadeColor for how to use colors with reports. Default: `black'.
|
||||
xTicks = [] % Used only in conjunction with xTickLabels, this option denotes the numerical position of the label along the x-axis. The positions begin at 1. Default: the indices associated with the first and last dates of the dseries and, if passed, the index associated with the first date of the shade option.
|
||||
xTickLabels = {} % The labels to be mapped to the ticks provided by xTicks. Default: the first and last dates of the dseries and, if passed, the date first date of the shade option.
|
||||
xTickLabelRotation = 0 % The amount to rotate the x tick labels by. Default: 0.
|
||||
xTickLabelAnchor = 'east' % Where to anchor the x tick label. Default: `east'.
|
||||
yTickLabelScaled = true % Determines whether or not there is a common scaling factor for the y axis. Default: true.
|
||||
yTickLabelPrecision = 0 % The precision with which to report the yTickLabel. Default: 0.
|
||||
yTickLabelFixed = true % Round the y tick labels to a fixed number of decimal places, given by yTickLabelPrecision. Default: true.
|
||||
yTickLabelZeroFill = true % Whether or not to fill missing precision spots with zeros. Default: true.
|
||||
tickFontSize = 'normalsize' % The font size for x- and y-axis tick labels. Default: normalsize.
|
||||
width = 6 % The width of the graph, in inches. Default: 6.0.
|
||||
height = 4.5 % The height of the graph, in inches. Default: 4.5.
|
||||
miscTikzPictureOptions = '' % If you are comfortable with PGFPLOTS/TikZ, you can use this option to pass arguments directly to the PGFPLOTS/TikZ tikzpicture environment command. (e.g., to scale the graph in the x and y dimensions, you can pass following to this option: ?xscale=2.5, yscale=0.5?). Specifically to be used for desired ``PGFPLOTS/TikZoptionsthathavenotbeenincorporatedinto Dynare Reporting. Default: empty.
|
||||
miscTikzAxisOptions = '' % If you are comfortable with PGFPLOTS/TikZ, you can use this option to pass arguments directly to the PGFPLOTS/TikZ axis environment command. Specifically to be used for desired PGFPLOTS/ TikZ options that have not been incorporated into Dynare Reporting. Default: empty.
|
||||
writeCSV = false % Whether or not to write a CSV file with only the plotted data. The file will be saved in the directory specified by graphDirName with the same base name as specified by graphName with the ending .csv. Default: false.
|
||||
end
|
||||
methods
|
||||
function o = report_graph(varargin)
|
||||
%function o = report_graph(varargin)
|
||||
% report_graph class constructor
|
||||
%
|
||||
% INPUTS
|
||||
% varargin 0 args : empty report_graph object
|
||||
% 1 arg : must be report_graph object (return a copy of arg)
|
||||
% > 1 args: option/value pairs (see structure below for
|
||||
% options)
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report_graph] report_graph object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
if nargin == 0
|
||||
return
|
||||
elseif nargin == 1
|
||||
assert(isa(varargin{1}, 'report_graph'), ...
|
||||
'With one arg to the report_graph constructor, you must pass a report_graph object');
|
||||
o = varargin{1};
|
||||
return
|
||||
elseif nargin > 1
|
||||
if round(nargin/2) ~= nargin/2
|
||||
error('@report_graph.report_graph: options must be supplied in name/value pairs.');
|
||||
end
|
||||
|
||||
% Octave 5.1.0 has not implemented `properties` and issues a warning when using `fieldnames`
|
||||
if isoctave
|
||||
warnstate = warning('off', 'Octave:classdef-to-struct');
|
||||
end
|
||||
optNames = fieldnames(o);
|
||||
if isoctave
|
||||
warning(warnstate);
|
||||
end
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
ind = find(strcmpi(optNames, pair{1}));
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@report_graph.report_graph: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
% Check options provided by user
|
||||
if ischar(o.title)
|
||||
o.title = {o.title};
|
||||
end
|
||||
assert(iscellstr(o.title), '@report_graph.report_graph: title must be a cell array of string(s)');
|
||||
assert(ischar(o.titleFormat), '@report_graph.report_graph: titleFormat file must be a string');
|
||||
assert(ischar(o.xlabel), '@report_graph.report_graph: xlabel file must be a string');
|
||||
assert(ischar(o.ylabel), '@report_graph.report_graph: ylabel file must be a string');
|
||||
assert(ischar(o.miscTikzPictureOptions), '@report_graph.report_graph: miscTikzPictureOptions file must be a string');
|
||||
assert(ischar(o.miscTikzAxisOptions), '@report_graph.report_graph: miscTikzAxisOptions file must be a string');
|
||||
assert(ischar(o.graphName), '@report_graph.report_graph: graphName must be a string');
|
||||
assert(ischar(o.graphDirName), '@report_graph.report_graph: graphDirName must be a string');
|
||||
assert(islogical(o.showGrid), '@report_graph.report_graph: showGrid must be either true or false');
|
||||
assert(islogical(o.xAxisTight), '@report_graph.report_graph: xAxisTight must be either true or false');
|
||||
assert(islogical(o.yAxisTight), '@report_graph.report_graph: yAxisTight must be either true or false');
|
||||
assert(islogical(o.showLegend), '@report_graph.report_graph: showLegend must be either true or false');
|
||||
assert(isempty(o.legendAt) || (isfloat(o.legendAt) && length(o.legendAt)==2), ...
|
||||
'@report_graph.report_graph: legendAt must be a double array of size two');
|
||||
assert(islogical(o.showLegendBox), '@report_graph.report_graph: showLegendBox must be either true or false');
|
||||
assert(islogical(o.showZeroline), '@report_graph.report_graph: showZeroline must be either true or false');
|
||||
assert(isfloat(o.shadeOpacity) && length(o.shadeOpacity)==1 && ...
|
||||
o.shadeOpacity >= 0 && o.shadeOpacity <= 100, ...
|
||||
'@report_graph.report_graph: o.shadeOpacity must be a real in [0 100]');
|
||||
assert(isfloat(o.width), '@report_graph.report_graph: o.width must be a real number');
|
||||
assert(isfloat(o.height), '@report_graph.report_graph: o.height must be a real number');
|
||||
assert(isfloat(o.xTickLabelRotation), '@report_graph.report_graph: o.xTickLabelRotation must be a real number');
|
||||
assert(ischar(o.xTickLabelAnchor), '@report_graph.report_graph: xTickLabelAnchor must be a string');
|
||||
assert(isint(o.yTickLabelPrecision), '@report_graph.report_graph: o.yTickLabelPrecision must be an integer');
|
||||
assert(islogical(o.yTickLabelFixed), '@report_graph.report_graph: yTickLabelFixed must be either true or false');
|
||||
assert(islogical(o.yTickLabelZeroFill), '@report_graph.report_graph: yTickLabelZeroFill must be either true or false');
|
||||
assert(islogical(o.yTickLabelScaled), '@report_graph.report_graph: yTickLabelScaled must be either true or false');
|
||||
assert(islogical(o.writeCSV), '@report_graph.report_graph: writeCSV must be either true or false');
|
||||
assert(ischar(o.shadeColor), '@report_graph.report_graph: shadeColor must be a string');
|
||||
assert(ischar(o.zeroLineColor), '@report_graph.report_graph: zeroLineColor must be a string');
|
||||
assert(any(strcmp(o.axisShape, {'box', 'L'})), ['@report_graph.report_graph: axisShape ' ...
|
||||
'must be one of ''box'' or ''L''']);
|
||||
valid_legend_locations = ...
|
||||
{'south west','south east','north west','north east','outer north east'};
|
||||
assert(any(strcmp(o.legendLocation, valid_legend_locations)), ...
|
||||
['@report_graph.report_graph: legendLocation must be one of ' addCommasToCellStr(valid_legend_locations)]);
|
||||
|
||||
valid_font_sizes = {'tiny', 'scriptsize', 'footnotesize', 'small', ...
|
||||
'normalsize', 'large', 'Large', 'LARGE', 'huge', 'Huge'};
|
||||
assert(any(strcmp(o.legendFontSize, valid_font_sizes)), ...
|
||||
['@report_graph.report_graph: legendFontSize must be one of ' addCommasToCellStr(valid_font_sizes)]);
|
||||
assert(any(strcmp(o.titleFontSize, valid_font_sizes)), ...
|
||||
['@report_graph.report_graph: titleFontSize must be one of ' addCommasToCellStr(valid_font_sizes)]);
|
||||
assert(any(strcmp(o.tickFontSize, valid_font_sizes)), ...
|
||||
['@report_graph.report_graph: tickFontSize must be one of ' addCommasToCellStr(valid_font_sizes)]);
|
||||
|
||||
valid_legend_orientations = {'vertical', 'horizontal'};
|
||||
assert(any(strcmp(o.legendOrientation, valid_legend_orientations)), ...
|
||||
['@report_graph.report_graph: legendOrientation must be one of ' addCommasToCellStr(valid_legend_orientations)]);
|
||||
|
||||
assert(isempty(o.shade) || (isdates(o.shade) && o.shade.ndat >= 2), ...
|
||||
['@report_graph.report_graph: shade is specified as a dates range, e.g. ' ...
|
||||
'''dates(''1999q1''):dates(''1999q3'')''.']);
|
||||
assert(isempty(o.xrange) || (isdates(o.xrange) && o.xrange.ndat >= 2), ...
|
||||
['@report_graph.report_graph: xrange is specified as a dates range, e.g. ' ...
|
||||
'''dates(''1999q1''):dates(''1999q3'')''.']);
|
||||
assert(isempty(o.yrange) || (isfloat(o.yrange) && length(o.yrange) == 2 && ...
|
||||
o.yrange(1) < o.yrange(2)), ...
|
||||
['@report_graph.report_graph: yrange is specified an array with two float entries, ' ...
|
||||
'the lower bound and upper bound.']);
|
||||
assert(isempty(o.data) || isdseries(o.data), ['@report_graph.report_graph: data must ' ...
|
||||
'be a dseries']);
|
||||
assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ['@report_graph.report_graph: ' ...
|
||||
'seriesToUse must be a cell array of string(s)']);
|
||||
assert(isempty(o.xTicks) || isfloat(o.xTicks),...
|
||||
'@report_graph.report_graph: xTicks must be a numerical array');
|
||||
assert(iscellstr(o.xTickLabels) || (ischar(o.xTickLabels) && strcmpi(o.xTickLabels, 'ALL')), ...
|
||||
['@report_graph.report_graph: xTickLabels must be a cell array of strings or ' ...
|
||||
'equivalent to the string ''ALL''']);
|
||||
if ~isempty(o.xTickLabels)
|
||||
assert((ischar(o.xTickLabels) && strcmpi(o.xTickLabels, 'ALL')) || ...
|
||||
~isempty(o.xTicks), ['@report_graph.report_graph: if you set xTickLabels and ' ...
|
||||
'it''s not equal to ''ALL'', you must set xTicks']);
|
||||
end
|
||||
if ~isempty(o.xTicks)
|
||||
assert(~isempty(o.xTickLabels), '@report_graph.report_graph: if you set xTicks, you must set xTickLabels');
|
||||
end
|
||||
|
||||
% using o.seriesToUse, create series objects and put them in o.series
|
||||
if ~isempty(o.data)
|
||||
if isempty(o.seriesToUse)
|
||||
for i=1:o.data.vobs
|
||||
o.series{end+1} = report_series('data', o.data{o.data.name{i}});
|
||||
end
|
||||
else
|
||||
for i=1:length(o.seriesToUse)
|
||||
o.series{end+1} = report_series('data', o.data{o.seriesToUse{i}});
|
||||
end
|
||||
end
|
||||
end
|
||||
o.seriesToUse = '';
|
||||
o.data = '';
|
||||
end
|
||||
end
|
||||
methods (Hidden = true)
|
||||
o = addSeries(o, varargin)
|
||||
write(o, fid, pg, sec, row, col, rep_dir)
|
||||
end
|
||||
methods (Access = private)
|
||||
% Methods defined in separate files
|
||||
lastIndex = end(o, k, n)
|
||||
graphName = writeGraphFile(o, pg, sec, row, col, rep_dir)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,39 @@
|
|||
function write(o, fid, pg, sec, row, col, rep_dir)
|
||||
%function write(o, fid, pg, sec, row, col, rep_dir)
|
||||
% Write a report_graph object
|
||||
%
|
||||
% INPUTS
|
||||
% o [report_graph] report_graph object
|
||||
% fid [integer] file id
|
||||
% pg [integer] this page number
|
||||
% sec [integer] this section number
|
||||
% row [integer] this row number
|
||||
% col [integer] this col number
|
||||
% rep_dir [string] directory containing report.tex
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report_graph] report_graph object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2020 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
graphName = writeGraphFile(o, pg, sec, row, col, rep_dir);
|
||||
fprintf(fid, '\\input{%s}', graphName);
|
||||
end
|
|
@ -0,0 +1,334 @@
|
|||
function graphName = writeGraphFile(o, pg, sec, row, col, rep_dir)
|
||||
%function graphName = writeGraphFile(o, pg, sec, row, col, rep_dir)
|
||||
% Write the tikz file that contains the graph
|
||||
%
|
||||
% INPUTS
|
||||
% o [report_graph] report_graph object
|
||||
% pg [integer] this page number
|
||||
% sec [integer] this section number
|
||||
% row [integer] this row number
|
||||
% col [integer] this col number
|
||||
% rep_dir [string] directory containing report.tex
|
||||
%
|
||||
% OUTPUTS
|
||||
% graphName [string] name of graph written
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2020 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
ne = length(o.series);
|
||||
if ne < 1
|
||||
warning('@report_graph.writeGraphFile: no series to plot, returning');
|
||||
return
|
||||
end
|
||||
|
||||
if exist([rep_dir '/' o.graphDirName], 'dir') ~= 7
|
||||
mkdir([rep_dir '/' o.graphDirName]);
|
||||
end
|
||||
if isempty(o.graphName)
|
||||
graphName = sprintf([o.graphDirName '/graph_pg%d_sec%d_row%d_col%d.tex'], pg, sec, row, col);
|
||||
else
|
||||
graphName = [o.graphDirName '/' o.graphName];
|
||||
end
|
||||
|
||||
[fid, msg] = fopen([rep_dir '/' graphName], 'w');
|
||||
if fid == -1
|
||||
error(['@report_graph.writeGraphFile: ' msg]);
|
||||
end
|
||||
|
||||
fprintf(fid, '%% Graph Object written %s\n', datestr(now));
|
||||
fprintf(fid, '\\begin{tikzpicture}[baseline');
|
||||
if ~isempty(o.miscTikzPictureOptions)
|
||||
fprintf(fid, ',%s', o.miscTikzPictureOptions);
|
||||
end
|
||||
fprintf(fid, ']');
|
||||
|
||||
if isempty(o.xrange)
|
||||
dd = getMaxRange(o.series);
|
||||
else
|
||||
dd = o.xrange;
|
||||
end
|
||||
|
||||
if ispc || ismac
|
||||
fprintf(fid, '\\begin{axis}[%%\nset layers,\n');
|
||||
else
|
||||
fprintf(fid, '\\begin{axis}[%%\n');
|
||||
end
|
||||
% set tick labels
|
||||
if isempty(o.xTickLabels)
|
||||
stringsdd = strings(dd);
|
||||
if ~isempty(o.shade)
|
||||
x1 = find(strcmpi(date2string(o.shade(1)), stringsdd));
|
||||
x2 = find(strcmpi(date2string(o.shade(end)), stringsdd));
|
||||
if x1 == 1
|
||||
x = [1 x2 dd.ndat];
|
||||
xTickLabels = [stringsdd(1) stringsdd(x2) stringsdd(end)];
|
||||
elseif x2 == dd.ndat
|
||||
x = [1 x1 dd.ndat];
|
||||
xTickLabels = [stringsdd(1) stringsdd(x1) stringsdd(end)];
|
||||
else
|
||||
x = [1 x1 x2 dd.ndat];
|
||||
xTickLabels = [stringsdd(1) stringsdd(x1) stringsdd(x2) stringsdd(end)];
|
||||
end
|
||||
else
|
||||
x = [1 dd.ndat];
|
||||
xTickLabels = [stringsdd(1) stringsdd(end)];
|
||||
end
|
||||
fprintf(fid, 'xminorticks=true,\nyminorticks=true,\n');
|
||||
elseif iscell(o.xTickLabels)
|
||||
fprintf(fid,'minor xtick,\n');
|
||||
x = o.xTicks;
|
||||
xTickLabels = o.xTickLabels;
|
||||
else
|
||||
x = [1:dd.ndat];
|
||||
xTickLabels = strings(dd);
|
||||
end
|
||||
fprintf(fid, 'xticklabels={');
|
||||
xlen = length(x);
|
||||
for i = 1:xlen
|
||||
fprintf(fid,'%s,',lower(xTickLabels{i}));
|
||||
end
|
||||
fprintf(fid, '},\nxtick={');
|
||||
for i = 1:xlen
|
||||
fprintf(fid, '%d',x(i));
|
||||
if i ~= length(x)
|
||||
fprintf(fid,',');
|
||||
end
|
||||
end
|
||||
fprintf(fid, '},\ny tick label style={\n/pgf/number format/.cd,\n');
|
||||
if o.yTickLabelFixed
|
||||
fprintf(fid, 'fixed,\n');
|
||||
end
|
||||
if o.yTickLabelZeroFill
|
||||
fprintf(fid, 'zerofill,\n');
|
||||
end
|
||||
fprintf(fid, 'precision=%d,\n/tikz/.cd\n},\n', o.yTickLabelPrecision);
|
||||
fprintf(fid, 'x tick label style={rotate=%f', o.xTickLabelRotation);
|
||||
if o.xTickLabelRotation ~= 0
|
||||
fprintf(fid, ',anchor=%s', o.xTickLabelAnchor);
|
||||
end
|
||||
fprintf(fid, ['},\n',...
|
||||
'width=%fin,\n'...
|
||||
'height=%fin,\n'...
|
||||
'scale only axis,\n'...
|
||||
'unbounded coords=jump,\n'], o.width, o.height);
|
||||
|
||||
if strcmpi(o.axisShape, 'box')
|
||||
fprintf(fid, 'axis lines=box,\n');
|
||||
elseif strcmpi(o.axisShape, 'L')
|
||||
fprintf(fid, 'axis x line=bottom,\naxis y line=left,\n');
|
||||
end
|
||||
|
||||
if ~isempty(o.title{1})
|
||||
fprintf(fid, 'title style={align=center');
|
||||
if ~isempty(o.titleFormat)
|
||||
fprintf(fid, ',font=%s', o.titleFormat);
|
||||
end
|
||||
fprintf(fid, '},\ntitle=');
|
||||
nt = length(o.title);
|
||||
for i=1:nt
|
||||
fprintf(fid, '%s', o.title{i});
|
||||
if i ~= nt
|
||||
fprintf(fid, '\\\\');
|
||||
end
|
||||
end
|
||||
fprintf(fid, ',\n');
|
||||
end
|
||||
|
||||
if o.xAxisTight
|
||||
fprintf(fid, 'enlarge x limits=false,\n');
|
||||
else
|
||||
fprintf(fid, 'enlarge x limits=true,\n');
|
||||
end
|
||||
|
||||
if isempty(o.yrange)
|
||||
nonzeroseries = false;
|
||||
for i=1:ne
|
||||
if ~o.series{i}.isZero()
|
||||
nonzeroseries = true;
|
||||
break;
|
||||
end
|
||||
end
|
||||
if ~nonzeroseries
|
||||
fprintf(fid, 'ymin=-1,\nymax=1,\n');
|
||||
end
|
||||
if o.yAxisTight
|
||||
fprintf(fid, 'enlarge y limits=false,\n');
|
||||
else
|
||||
fprintf(fid, 'enlarge y limits=true,\n');
|
||||
end
|
||||
else
|
||||
fprintf(fid, 'ymin=%f,\nymax=%f,\n',o.yrange(1),o.yrange(2));
|
||||
end
|
||||
fprintf(fid, 'xmin = 1,\nxmax = %d,\n', length(dd));
|
||||
|
||||
if o.showLegend
|
||||
fprintf(fid, 'legend style={');
|
||||
if ~o.showLegendBox
|
||||
fprintf(fid, 'draw=none,');
|
||||
end
|
||||
fprintf(fid, 'font=\\%s,', o.legendFontSize);
|
||||
if strcmp(o.legendOrientation, 'horizontal')
|
||||
fprintf(fid,'legend columns=-1,');
|
||||
end
|
||||
if isempty(o.legendAt)
|
||||
fprintf(fid, '},\nlegend pos=%s,\n', o.legendLocation);
|
||||
else
|
||||
fprintf(fid, 'at={(%f,%f)}},\n',o.legendAt(1),o.legendAt(2));
|
||||
end
|
||||
end
|
||||
|
||||
fprintf(fid, 'tick label style={font=\\%s},\n', o.tickFontSize);
|
||||
|
||||
if o.showGrid
|
||||
fprintf(fid, 'xmajorgrids=true,\nymajorgrids=true,\n');
|
||||
end
|
||||
|
||||
if ~isempty(o.xlabel)
|
||||
fprintf(fid, 'xlabel=%s,\n', o.xlabel);
|
||||
end
|
||||
|
||||
if ~isempty(o.ylabel)
|
||||
fprintf(fid, 'ylabel=%s,\n', o.ylabel);
|
||||
end
|
||||
|
||||
if ~o.yTickLabelScaled
|
||||
fprintf(fid, 'scaled y ticks = false,\n');
|
||||
end
|
||||
|
||||
if ~isempty(o.miscTikzAxisOptions)
|
||||
fprintf(fid, '%s', o.miscTikzAxisOptions);
|
||||
end
|
||||
fprintf(fid, ']\n');
|
||||
|
||||
if ~isempty(o.title{1})
|
||||
fprintf(fid, '\\pgfplotsset{every axis title/.append style={}}=[font=\\%s]\n', o.titleFontSize);
|
||||
end
|
||||
|
||||
if ~isempty(o.shade)
|
||||
fprintf(fid, '%%shading\n');
|
||||
stringsdd = strings(dd);
|
||||
x1 = find(strcmpi(date2string(o.shade(1)), stringsdd));
|
||||
x2 = find(strcmpi(date2string(o.shade(end)), stringsdd));
|
||||
assert(~isempty(x1) && ~isempty(x2), ['@report_graph.writeGraphFile: either ' ...
|
||||
date2string(o.shade(1)) ' or ' date2string(o.shade(end)) ' is not in the date ' ...
|
||||
'range of data selected.']);
|
||||
if x1 == 1
|
||||
fprintf(fid,['\\begin{pgfonlayer}{axis background}\n\\fill[%s!%f]\n(axis ' ...
|
||||
'cs:\\pgfkeysvalueof{/pgfplots/xmin},\\pgfkeysvalueof{/pgfplots/ymin})\nrectangle (axis ' ...
|
||||
'cs:%f,\\pgfkeysvalueof{/pgfplots/ymax});\n\\end{pgfonlayer}\n'], ...
|
||||
o.shadeColor, o.shadeOpacity, x2);
|
||||
elseif x2 == dd.ndat
|
||||
fprintf(fid,['\\begin{pgfonlayer}{axis background}\n\\fill[%s!%f]\n(axis ' ...
|
||||
'cs:%f,\\pgfkeysvalueof{/pgfplots/ymin})\nrectangle (axis ' ...
|
||||
'cs:\\pgfkeysvalueof{/pgfplots/xmax},\\pgfkeysvalueof{/' ...
|
||||
'pgfplots/ymax});\n\\end{pgfonlayer}\n'], ...
|
||||
o.shadeColor, o.shadeOpacity, x1);
|
||||
else
|
||||
fprintf(fid,['\\begin{pgfonlayer}{axis background}\n\\fill[%s!%f]\n(axis ' ...
|
||||
'cs:%f,\\pgfkeysvalueof{/pgfplots/ymin})\nrectangle (axis ' ...
|
||||
'cs:%f,\\pgfkeysvalueof{/pgfplots/ymax});\n\\end{pgfonlayer}\n'], ...
|
||||
o.shadeColor, o.shadeOpacity, x1, x2);
|
||||
end
|
||||
end
|
||||
|
||||
if o.showZeroline
|
||||
fprintf(fid, '%%zeroline\n\\addplot[%s,line width=.5,forget plot] coordinates {(1,0)(%d,0)};\n', ...
|
||||
o.zeroLineColor, dd.ndat);
|
||||
end
|
||||
|
||||
if o.writeCSV
|
||||
csvseries = dseries();
|
||||
end
|
||||
|
||||
if isunix && ~ismac
|
||||
for i=1:ne
|
||||
isfan = ~isempty(o.series{i}.graphFanShadeColor);
|
||||
if isfan
|
||||
break
|
||||
end
|
||||
end
|
||||
if isfan
|
||||
data = dseries();
|
||||
for i=1:ne
|
||||
tmp = o.series{i}.data;
|
||||
tmp = tmp.set_names(int2str(i));
|
||||
data = [data tmp];
|
||||
end
|
||||
|
||||
if isempty(dd) || all(dd == data.dates)
|
||||
ds = data;
|
||||
else
|
||||
ds = data(dd);
|
||||
end
|
||||
|
||||
for i=2:ne
|
||||
tmp = ds{i} - ds{i-1};
|
||||
idx = find(tmp.data ~= 0);
|
||||
assert(~isempty(idx), ...
|
||||
'Problem creating fan area for data provided. Please check your data.');
|
||||
split = ds(ds.dates(idx));
|
||||
end
|
||||
idx = find(ds.dates == split.dates(1));
|
||||
for i=2:ne
|
||||
fprintf(fid, '\\addplot[fill=%s!%d, draw=none, forget plot] coordinates {',...
|
||||
o.series{i}.graphFanShadeColor, o.series{i}.graphFanShadeOpacity);
|
||||
for j=idx-1:ds.dates.ndat
|
||||
fprintf(fid, '(%d, %f) ', j, ds{i-1}(ds.dates(j),1).data);
|
||||
end
|
||||
for j=ds.dates.ndat:-1:idx-1
|
||||
fprintf(fid, '(%d, %f) ', j, ds{i}(ds.dates(j),1).data);
|
||||
end
|
||||
fprintf(fid, '} \\closedcycle;\n');
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for i=1:ne
|
||||
o.series{i}.writeSeriesForGraph(fid, dd, i);
|
||||
if o.writeCSV
|
||||
csvseries = [csvseries ...
|
||||
o.series{i}.data(dd).set_names([...
|
||||
o.series{i}.data.name{:} '_' ...
|
||||
o.series{i}.graphLegendName '_' ...
|
||||
o.series{i}.graphLineColor '_' ...
|
||||
o.series{i}.graphLineStyle '_' ...
|
||||
num2str(o.series{i}.graphLineWidth) '_' ...
|
||||
o.series{i}.graphMarker '_' ...
|
||||
o.series{i}.graphMarkerEdgeColor '_' ...
|
||||
o.series{i}.graphMarkerFaceColor '_' ...
|
||||
num2str(o.series{i}.graphMarkerSize)]) ...
|
||||
];
|
||||
end
|
||||
if o.showLegend
|
||||
le = o.series{i}.getNameForLegend();
|
||||
if ~isempty(le)
|
||||
fprintf(fid, '\\addlegendentry{%s}\n', le);
|
||||
end
|
||||
end
|
||||
end
|
||||
if o.writeCSV
|
||||
csvseries.save(strrep(o.graphName, '.tex', ''), 'csv');
|
||||
end
|
||||
fprintf(fid, '\\end{axis}\n\\end{tikzpicture}%%');
|
||||
if fclose(fid) == -1
|
||||
error('@report_graph.writeGraphFile: closing %s\n', o.filename);
|
||||
end
|
||||
end
|
|
@ -0,0 +1,31 @@
|
|||
function s = getNameForLegend(o)
|
||||
%function s = getNameForLegend(o)
|
||||
|
||||
% Copyright © 2014-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
if isempty(o.data) || ~o.graphShowInLegend
|
||||
% for the case when there is no data in the series
|
||||
% e.g. graphVline was passed
|
||||
% or when the user does not want this series shown in
|
||||
% the legend
|
||||
s = '';
|
||||
else
|
||||
assert(size(o.data,2) == 1);
|
||||
s = o.data.tex{:};
|
||||
end
|
||||
end
|
|
@ -0,0 +1,27 @@
|
|||
function dd = getRange(o)
|
||||
%function dd = getRange(o)
|
||||
|
||||
% Copyright © 2013-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
if isempty(o.data)
|
||||
dd = dates();
|
||||
else
|
||||
assert(size(o.data, 2) == 1);
|
||||
dd = o.data.dates;
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
function s = getTexName(o)
|
||||
%function s = getTexName(o)
|
||||
|
||||
% Copyright © 2013-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
if isempty(o.data)
|
||||
% for the case when there is no data in the series
|
||||
% e.g. graphVline was passed
|
||||
s = '';
|
||||
else
|
||||
assert(size(o.data,2) == 1);
|
||||
s = o.data.tex{:};
|
||||
end
|
||||
end
|
|
@ -0,0 +1,32 @@
|
|||
function tf = isZero(o)
|
||||
%function o = isZero(o)
|
||||
% Write the tikz file that contains the graph
|
||||
%
|
||||
% INPUTS
|
||||
% o [report_series] report_series object
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report_series] report_series object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
tf = all(o.data.data == 0);
|
||||
end
|
|
@ -0,0 +1,62 @@
|
|||
function o = printSeries(o, fid, dser, dates, precision)
|
||||
%function printSeries(o, fid, dser, dates, precision)
|
||||
% function to print a row of data, contained in dser
|
||||
%
|
||||
% INPUTS
|
||||
% fid [int] file id
|
||||
% dser [string] name of data series to be printed
|
||||
% dates [dates] dates for report_series slice
|
||||
% precision [float] precision with which to print the data
|
||||
%
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report_series] report_series object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2014-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
dataString = sprintf('%%.%df', precision);
|
||||
precision = 10^precision;
|
||||
|
||||
data = dser(dates);
|
||||
data = setDataToZeroFromZeroTol(o, data);
|
||||
for i=1:size(data,1)
|
||||
fprintf(fid, '&');
|
||||
if o.tableShowMarkers
|
||||
if data(i) < -o.tableMarkerLimit
|
||||
fprintf(fid, '\\color{%s}', o.tableNegColor);
|
||||
elseif data(i) > o.tableMarkerLimit
|
||||
fprintf(fid, '\\color{%s}', o.tablePosColor);
|
||||
end
|
||||
fprintf(fid, '[');
|
||||
end
|
||||
% Use round half away from zero rounding
|
||||
output = round(data(i)*precision)/precision;
|
||||
if isnan(output)
|
||||
fprintf(fid, '%s', o.tableNaNSymb);
|
||||
else
|
||||
fprintf(fid, dataString, output);
|
||||
end
|
||||
|
||||
if o.tableShowMarkers
|
||||
fprintf(fid, ']');
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,125 @@
|
|||
classdef report_series < handle
|
||||
% report_series Class to write a page to the report
|
||||
%
|
||||
% Copyright © 2013-2022 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
properties (SetAccess = private)
|
||||
data = '' % The dseries that provides the data for the graph. Default: none.
|
||||
graphFanShadeColor = '' % The shading color to use between a series and the previously-added series in a graph. Useful for making fan charts. Default: empty.
|
||||
graphFanShadeOpacity = 50 % The opacity of the color passed in graphFanShadeColor. Default: 50.
|
||||
graphLegendName = '' % The name to display in the legend for this series, passed as valid LATEX (e.g., GDP_{US}, $\alpha$, \color{red}GDP\color{black}). Will be displayed only if the data and showLegend options have been passed. Default: the tex name of the series.
|
||||
graphLineColor = 'black' % Color to use for the series in a graph. See the explanation in shadeColor for how to use colors with reports. Default: `black'
|
||||
graphLineStyle = 'solid' % Line style for this series in a graph. Default: `solid'.
|
||||
graphLineWidth = 0.5 % Line width for this series in a graph. Default: 0.5.
|
||||
graphShowInLegend = true % Whether or not to show this series in the legend, given that the showLegend option was passed to addGraph. Default: true.
|
||||
graphMarker = '' % The Marker to use on this series in a graph. Default: none.
|
||||
graphMarkerEdgeColor = '' % The edge color of the graph marker. See the explanation in shadeColor for how to use colors with reports. Default: graphLineColor.
|
||||
graphMarkerFaceColor = '' % The face color of the graph marker. See the explanation in shadeColor for how to use colors with reports. Default: graphLineColor.
|
||||
graphMarkerSize = 1 % The size of the graph marker. Default: 1.
|
||||
graphMiscTikzAddPlotOptions = '' % If you are comfortable with PGFPLOTS/TikZ, you can use this option to pass arguments di- rectly to the PGFPLOTS/TikZ addPlots command. (e.g., Instead of passing the marker options above, you can pass a string such as the following to this option: `mark=halfcircle*,mark options={rotate=90,scale=3}'). Specifically to be used for desired PGFPLOTS/TikZ options that have not been incorporated into Dynare Reproting. Default: empty.
|
||||
graphHline = {} % Use this option to draw a horizontal line at the given value. Default: empty.
|
||||
graphVline = dates() % Use this option to draw a vertical line at a given date. Default: empty.
|
||||
graphBar = false % Whether or not to display this series as a bar graph as oppsed to the default of displaying it as a line graph. Default: false.
|
||||
graphBarColor = 'black' % The outline color of each bar in the bar graph. Only active if graphBar is passed. Default: `black'.
|
||||
graphBarFillColor = 'black' % The fill color of each bar in the bar graph. Only active if graphBar is passed. Default: `black'.
|
||||
graphBarWidth = 2 % The width of each bar in the bar graph. Only active if graphBar is passed. Default: 2.
|
||||
tableShowMarkers = false % In a Table, if true, surround each cell with brackets and color it according to tableNegColor and tablePosColor. No effect for graphs. Default: false.
|
||||
tableNegColor = 'red' % The color to use when marking Table data that is less than zero. Default: `red'
|
||||
tablePosColor = 'blue' % The color to use when marking Table data that is greater than zero. Default: `blue'
|
||||
tableMarkerLimit = 1e-4 % For values less than ?1 * tableMarkerLimit, mark the cell with the color denoted by tableNeg- Color. For those greater than tableMarkerLimit, mark the cell with the color denoted by table- PosColor. Default: 1e-4.
|
||||
tableSubSectionHeader = '' % A header for a subsection of the table. No data will be associated with it. It is equivalent to adding an empty series with a name. Default: ''
|
||||
tableAlignRight = false % Whether or not to align the series name to the right of the cell. Default: false.
|
||||
tableRowColor = 'white' % The color that you want the row to be. Predefined values include LightCyan and Gray. Default: white.
|
||||
tableRowIndent = 0 % The number of times to indent the name of the series in the table. Used to create subgroups of series. Default: 0.
|
||||
tableDataRhs = '' % A series to be added to the right of the current series. Usefull for displaying aggregate data for a series. e.g if the series is quarterly tableDataRhs could point to the yearly averages of the quarterly series. This would cause quarterly data to be displayed followed by annual data. Default: empty.
|
||||
tableNaNSymb = 'NaN' % Replace NaN values with the text in this option. Default: NaN.
|
||||
tablePrecision = '' % The number of decimal places to report in the table data. Default: the value set by precision.
|
||||
zeroTol = 1e-6 % The zero tolerance. Anything smaller than zeroTol and larger than -zeroTol will be set to zero before being graphed or written to the table. Default: 1e-6.
|
||||
end
|
||||
methods
|
||||
function o = report_series(varargin)
|
||||
%function o = report_series(varargin)
|
||||
% Report_Series Class Constructor
|
||||
%
|
||||
% INPUTS
|
||||
% varargin 0 args : empty report_series object
|
||||
% 1 arg : must be report_series object (return a copy of arg)
|
||||
% > 1 args: option/value pairs (see structure below for options)
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report_series] report_series object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
if nargin == 0
|
||||
return
|
||||
elseif nargin == 1
|
||||
assert(isa(varargin{1}, 'report_series'), ...
|
||||
'@report_series.report_series: with one arg you must pass a report_series object');
|
||||
o = varargin{1};
|
||||
return
|
||||
end
|
||||
|
||||
if round(nargin/2) ~= nargin/2
|
||||
error('@report_series.report_series: options must be supplied in name/value pairs.');
|
||||
end
|
||||
|
||||
% Octave 5.1.0 has not implemented `properties` and issues a warning when using `fieldnames`
|
||||
if isoctave
|
||||
warnstate = warning('off', 'Octave:classdef-to-struct');
|
||||
end
|
||||
optNames = fieldnames(o);
|
||||
if isoctave
|
||||
warning(warnstate);
|
||||
end
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
ind = find(strcmpi(optNames, pair{1}));
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@report_series.report_series: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
if ~isempty(o.graphLegendName)
|
||||
o.data = o.data.tex_rename(o.graphLegendName);
|
||||
end
|
||||
end
|
||||
end
|
||||
methods (Hidden = true)
|
||||
s = getNameForLegend(o)
|
||||
writeSeriesForGraph(o, fid, xrange, series_num)
|
||||
end
|
||||
methods (Hidden = true)
|
||||
writeSeriesForTable(o, fid, dates, precision, ncols, rowcolor)
|
||||
end
|
||||
methods (Hidden = true)
|
||||
tf = isZero(o)
|
||||
end
|
||||
methods
|
||||
dd = getRange(o)
|
||||
end
|
||||
methods (Access = private)
|
||||
s = getTexName(o)
|
||||
o = printSeries(o, fid, dser, dates, precision)
|
||||
d = setDataToZeroFromZeroTol(o, ds)
|
||||
ymax = ymax(o, dd)
|
||||
ymin = ymin(o, dd)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,28 @@
|
|||
function d = setDataToZeroFromZeroTol(o, ds)
|
||||
%function d = setDataToZeroFromZeroTol(o, ds)
|
||||
|
||||
% Copyright © 2014-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
d = ds.data;
|
||||
stz = bsxfun(@and, ...
|
||||
bsxfun(@lt, d, o.zeroTol), ...
|
||||
bsxfun(@gt, d, -o.zeroTol));
|
||||
if any(stz)
|
||||
d(stz) = 0;
|
||||
end
|
||||
end
|
|
@ -0,0 +1,167 @@
|
|||
function writeSeriesForGraph(o, fid, xrange, series_num)
|
||||
%function writeSeriesForGraph(o, fid, xrange, series_num)
|
||||
% Print a TikZ line
|
||||
%
|
||||
% INPUTS
|
||||
% o [report_series] series object
|
||||
% xrange [dates] range of x values for line
|
||||
% series_num [int] the number of this series in the total number of series passed to this graph
|
||||
%
|
||||
% OUTPUTS
|
||||
% NONE
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2014-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
%% Validate options provided by user
|
||||
if isempty(o.graphVline) && isempty(o.graphHline)
|
||||
assert(~isempty(o.data) && isdseries(o.data), ['@report_series.writeSeriesForGraph: must ' ...
|
||||
'provide data as a dseries']);
|
||||
end
|
||||
|
||||
assert(ischar(o.graphMiscTikzAddPlotOptions), ['@report_series.writeSeriesForGraph: ' ...
|
||||
'graphMiscTikzAddPlotOptions file must be a string']);
|
||||
assert(islogical(o.graphShowInLegend), ['@report_series.writeSeriesForGraph: ' ...
|
||||
'graphShowInLegend must be either true or false']);
|
||||
|
||||
% Line
|
||||
assert(ischar(o.graphLineColor), '@report_series.writeSeriesForGraph: graphLineColor must be a string');
|
||||
assert(ischar(o.graphLineStyle), '@report_series.writeSeriesForGraph: graphLineStyle must be a string');
|
||||
assert(isfloat(o.graphLineWidth) && o.graphLineWidth > 0, ...
|
||||
'@report_series.writeSeriesForGraph: graphLineWidth must be a positive number');
|
||||
|
||||
% Bar
|
||||
assert(islogical(o.graphBar), '@report_series.writeSeriesForGraph: graphBar must be either true or false');
|
||||
assert(ischar(o.graphBarColor), '@report_series.writeSeriesForGraph: graphBarColor must be a string');
|
||||
assert(ischar(o.graphBarFillColor), '@report_series.writeSeriesForGraph: graphBarFillColor must be a string');
|
||||
assert(isfloat(o.graphBarWidth) && o.graphBarWidth > 0, ...
|
||||
'@report_series.writeSeriesForGraph: graphbarWidth must be a positive number');
|
||||
|
||||
% GraphMarker
|
||||
valid_graphMarker = {'x', '+', '-', '|', 'o', 'asterisk', 'star', '10-pointed star', 'oplus', ...
|
||||
'oplus*', 'otimes', 'otimes*', 'square', 'square*', 'triangle', 'triangle*', 'diamond', ...
|
||||
'diamond*', 'halfdiamond*', 'halfsquare*', 'halfsquare right*', ...
|
||||
'halfsquare left*','Mercedes star','Mercedes star flipped','halfcircle',...
|
||||
'halfcircle*','pentagon','pentagon star'};
|
||||
assert(isempty(o.graphMarker) || any(strcmp(o.graphMarker, valid_graphMarker)), ...
|
||||
['@report_series.writeSeriesForGraph: graphMarker must be one of ' addCommasToCellStr(valid_graphMarker)]);
|
||||
|
||||
assert(ischar(o.graphMarkerEdgeColor), '@report_series.writeSeriesForGraph: graphMarkerEdgeColor must be a string');
|
||||
assert(ischar(o.graphMarkerFaceColor), '@report_series.writeSeriesForGraph: graphMarkerFaceColor must be a string');
|
||||
assert(isfloat(o.graphMarkerSize) && o.graphMarkerSize > 0, ...
|
||||
'@report_series.writeSeriesForGraph: graphMarkerSize must be a positive number');
|
||||
|
||||
% Marker & Line
|
||||
assert(~(strcmp(o.graphLineStyle, 'none') && isempty(o.graphMarker)), ['@report_series.writeSeriesForGraph: ' ...
|
||||
'you must provide at least one of graphLineStyle and graphMarker']);
|
||||
|
||||
% Validate graphVline
|
||||
assert(isempty(o.graphVline) || (isdates(o.graphVline) && o.graphVline.ndat == 1), ...
|
||||
'@report_series.writeSeriesForGraph: graphVline must be a dates of size one');
|
||||
assert(isempty(o.graphHline) || isnumeric(o.graphHline), ...
|
||||
'@report_series.writeSeriesForGraph: graphHline must a single numeric value');
|
||||
|
||||
% Zero tolerance
|
||||
assert(isfloat(o.zeroTol), '@report_series.write: zeroTol must be a float');
|
||||
|
||||
% Fan Chart
|
||||
assert(ischar(o.graphFanShadeColor), '@report_series.writeSeriesForGraph: graphFanShadeColor must be a string');
|
||||
assert(isint(o.graphFanShadeOpacity), '@report_series.writeSeriesForGraph: graphFanShadeOpacity must be an int');
|
||||
|
||||
%% graphVline && graphHline
|
||||
if ~isempty(o.graphVline)
|
||||
fprintf(fid, '%%Vertical Line\n\\begin{pgfonlayer}{axis lines}\n\\draw');
|
||||
writeLineOptions(o, fid, series_num);
|
||||
stringsdd = strings(xrange);
|
||||
x = find(strcmpi(date2string(o.graphVline), stringsdd));
|
||||
fprintf(fid, ['(axis cs:%d,\\pgfkeysvalueof{/pgfplots/ymin}) -- (axis ' ...
|
||||
'cs:%d,\\pgfkeysvalueof{/pgfplots/ymax});\n\\end{pgfonlayer}\n'], ...
|
||||
x, x);
|
||||
end
|
||||
if ~isempty(o.graphHline)
|
||||
fprintf(fid, '%%Horizontal Line\n\\begin{pgfonlayer}{axis lines}\n\\addplot');
|
||||
writeLineOptions(o, fid, series_num);
|
||||
fprintf(fid, ['coordinates {(\\pgfkeysvalueof{/pgfplots/xmin},%f)' ...
|
||||
'(\\pgfkeysvalueof{/pgfplots/xmax},%f)};\n\\end{pgfonlayer}\n'], ...
|
||||
o.graphHline, o.graphHline);
|
||||
end
|
||||
if ~isempty(o.graphVline) || ~isempty(o.graphHline)
|
||||
% return since the code below assumes that o.data exists
|
||||
return
|
||||
end
|
||||
|
||||
%%
|
||||
if isempty(xrange) || all(xrange == o.data.dates)
|
||||
ds = o.data;
|
||||
else
|
||||
ds = o.data(xrange);
|
||||
end
|
||||
|
||||
thedata = setDataToZeroFromZeroTol(o, ds);
|
||||
fprintf(fid, '%%series %s\n\\addplot', o.data.name{:});
|
||||
writeLineOptions(o, fid, series_num);
|
||||
fprintf(fid,'\ntable[row sep=crcr]{\nx y\\\\\n');
|
||||
for i=1:ds.dates.ndat
|
||||
if ~isnan(thedata(i))
|
||||
fprintf(fid, '%d %f\\\\\n', i, thedata(i));
|
||||
end
|
||||
end
|
||||
fprintf(fid,'};\n');
|
||||
|
||||
% For Fan charts
|
||||
if ispc || ismac
|
||||
if ~isempty(o.graphFanShadeColor)
|
||||
assert(isint(series_num) && series_num > 1, ['@report_series.writeSeriesForGraph: can only add '...
|
||||
'graphFanShadeColor and graphFanShadeOpacity starting from the ' ...
|
||||
'second series in the graph']);
|
||||
fprintf(fid, '\\addplot[%s!%d, forget plot] fill between[of=%d and %d];\n', ...
|
||||
o.graphFanShadeColor, o.graphFanShadeOpacity, series_num, series_num - 1);
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function writeLineOptions(o, fid, series_num)
|
||||
if o.graphBar
|
||||
fprintf(fid, '[ybar,ybar legend,color=%s,fill=%s,line width=%fpt',...
|
||||
o.graphBarColor, o.graphBarFillColor, o.graphBarWidth);
|
||||
else
|
||||
fprintf(fid, '[color=%s,%s,line width=%fpt,line join=round',...
|
||||
o.graphLineColor, o.graphLineStyle, o.graphLineWidth);
|
||||
|
||||
if ~isempty(o.graphMarker)
|
||||
if isempty(o.graphMarkerEdgeColor)
|
||||
o.graphMarkerEdgeColor = o.graphLineColor;
|
||||
end
|
||||
if isempty(o.graphMarkerFaceColor)
|
||||
o.graphMarkerFaceColor = o.graphLineColor;
|
||||
end
|
||||
fprintf(fid, ',mark=%s,mark size=%f,every mark/.append style={draw=%s,fill=%s}',...
|
||||
o.graphMarker,o.graphMarkerSize,o.graphMarkerEdgeColor,o.graphMarkerFaceColor);
|
||||
end
|
||||
end
|
||||
if ~isempty(o.graphMiscTikzAddPlotOptions)
|
||||
fprintf(fid, ',%s', o.graphMiscTikzAddPlotOptions);
|
||||
end
|
||||
if isunix && ~ismac
|
||||
fprintf(fid,']');
|
||||
else
|
||||
fprintf(fid,',name path=%d]', series_num);
|
||||
end
|
||||
end
|
|
@ -0,0 +1,111 @@
|
|||
function writeSeriesForTable(o, fid, dates, precision, ncols, rowcolor)
|
||||
%function writeSeriesForTable(o, fid, dates, precision, ncols, rowcolor)
|
||||
% Write Table Row
|
||||
%
|
||||
% INPUTS
|
||||
% o [report_series] report_series object
|
||||
% fid [int] file id
|
||||
% dates [dates] dates for report_series slice
|
||||
% precision [float] precision with which to print the data
|
||||
% ncols [int] total number of columns in table
|
||||
% rowcolor [string] string to color this row
|
||||
%
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report_series] report_series object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
%% Validate options passed to function
|
||||
for i=1:length(dates)
|
||||
assert(isdates(dates{i}));
|
||||
end
|
||||
assert(isint(precision));
|
||||
|
||||
%% Validate options provided by user
|
||||
assert(ischar(o.tableSubSectionHeader), '@report_series.writeSeriesForTable: tableSubSectionHeader must be a string');
|
||||
if isempty(o.tableSubSectionHeader)
|
||||
assert(~isempty(o.data) && isdseries(o.data), ...
|
||||
'@report_series.writeSeriesForTable: must provide data as a dseries');
|
||||
|
||||
if ~isempty(o.tableDataRhs)
|
||||
assert(~isempty(o.tableDataRhs) && isdseries(o.tableDataRhs), ...
|
||||
'@report_series.writeSeriesForTable: must provide tableDataRhs as a dseries');
|
||||
assert(iscell(dates) && length(dates) == 2, ...
|
||||
'@report_series.writeSeriesForTable: must provide second range with tableDataRhs');
|
||||
end
|
||||
end
|
||||
|
||||
assert(ischar(o.tableNegColor), '@report_series.writeSeriesForTable: tableNegColor must be a string');
|
||||
assert(ischar(o.tablePosColor), '@report_series.writeSeriesForTable: tablePosColor must be a string');
|
||||
assert(ischar(o.tableRowColor), '@report_series.writeSeriesForTable: tableRowColor must be a string');
|
||||
assert(isint(o.tableRowIndent) && o.tableRowIndent >= 0, ...
|
||||
'@report_series.writeSeriesForTable: tableRowIndent must be an integer >= 0');
|
||||
assert(islogical(o.tableShowMarkers), '@report_series.writeSeriesForTable: tableShowMarkers must be true or false');
|
||||
assert(islogical(o.tableAlignRight), '@report_series.writeSeriesForTable: tableAlignRight must be true or false');
|
||||
assert(isfloat(o.tableMarkerLimit), '@report_series.writeSeriesForTable: tableMarkerLimit must be a float');
|
||||
assert(ischar(o.tableNaNSymb), '@report_series.writeSeriesForTable: tableNaNSymb must be a string');
|
||||
|
||||
if ~isempty(o.tablePrecision)
|
||||
assert(isint(o.tablePrecision) && o.tablePrecision >= 0, ...
|
||||
'@report_series.writeSeriesForTable: tablePrecision must be a non-negative integer');
|
||||
precision = o.tablePrecision;
|
||||
end
|
||||
|
||||
%% Write Output
|
||||
fprintf(fid, '%% Table Row (report_series)\n');
|
||||
if ~isempty(o.tableRowColor) && ~strcmpi(o.tableRowColor, 'white')
|
||||
fprintf(fid, '\\rowcolor{%s}', o.tableRowColor);
|
||||
elseif ~isempty(rowcolor)
|
||||
fprintf(fid, '\\rowcolor{%s}', rowcolor);
|
||||
else
|
||||
fprintf(fid, '\\rowcolor{%s}', o.tableRowColor);
|
||||
end
|
||||
if ~isempty(o.tableSubSectionHeader)
|
||||
fprintf(fid, '\\textbf{%s}', o.tableSubSectionHeader);
|
||||
for i=1:ncols-1
|
||||
fprintf(fid, ' &');
|
||||
end
|
||||
fprintf(fid, '\\\\%%\n');
|
||||
return
|
||||
end
|
||||
if o.tableAlignRight
|
||||
fprintf(fid, '\\multicolumn{1}{r}{');
|
||||
end
|
||||
if o.tableRowIndent == 0
|
||||
fprintf(fid, '\\noindent');
|
||||
else
|
||||
for i=1:o.tableRowIndent
|
||||
fprintf(fid,'\\indent');
|
||||
end
|
||||
end
|
||||
fprintf(fid, ' %s', o.data.tex{:});
|
||||
if o.tableAlignRight
|
||||
fprintf(fid, '}');
|
||||
end
|
||||
|
||||
printSeries(o, fid, o.data, dates{1}, precision);
|
||||
if ~isempty(o.tableDataRhs)
|
||||
printSeries(o, fid, o.tableDataRhs, dates{2}, precision);
|
||||
end
|
||||
|
||||
fprintf(fid, '\\\\%%\n');
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
function ymax = ymax(o, dd)
|
||||
%function ymax = ymax(o, dd)
|
||||
|
||||
% Copyright © 2014-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.data) && size(o.data, 2) == 1);
|
||||
ymax = max(o.data(dd).data);
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
function ymin = ymin(o, dd)
|
||||
%function ymin = ymin(o, dd)
|
||||
|
||||
% Copyright © 2014-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.data) && size(o.data, 2) == 1);
|
||||
ymin = min(o.data(dd).data);
|
||||
end
|
|
@ -0,0 +1,36 @@
|
|||
function o = addData(o, varargin)
|
||||
%function o = addData(o, varargin)
|
||||
% Add a series
|
||||
%
|
||||
% INPUTS
|
||||
% o [report_table] report_table object
|
||||
% varargin arguments to report_data()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
if length(o.table_data) >= 1
|
||||
error('@report_table.addData: You can only use addData once per table')
|
||||
end
|
||||
o.table_data{1} = report_data(varargin{:});
|
||||
end
|
|
@ -0,0 +1,33 @@
|
|||
function o = addSeries(o, varargin)
|
||||
%function o = addSeries(o, varargin)
|
||||
% Add a series
|
||||
%
|
||||
% INPUTS
|
||||
% o [report_table] report_table object
|
||||
% varargin arguments to report_series()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
o.series{end+1} = report_series(varargin{:});
|
||||
end
|
|
@ -0,0 +1,244 @@
|
|||
classdef report_table < handle
|
||||
% report_table Class
|
||||
%
|
||||
% Copyright © 2013-2022 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
properties (Access = private, Constant = true)
|
||||
titleFormatDefalut = {'\large'}
|
||||
end
|
||||
properties (Access = private)
|
||||
series = {}
|
||||
table_data = {} % The table data
|
||||
% Not documented
|
||||
preamble = {''}
|
||||
afterward = {''}
|
||||
end
|
||||
properties (SetAccess = private)
|
||||
tableDirName = 'tmpRepDir' % The name of the folder in which to store this table. Default: tmpRepDir.
|
||||
tableName = '' % The name to use when saving this table. Default: something of the form table_pg1_sec2_row1_col3.tex.
|
||||
title = {''} % Table Title. Default: none.
|
||||
titleFormat = '' % A string representing the valid LATEX markup to use on title. The number of cell array entries must be equal to that of the title option if you do not want to use the default value for the title (and subtitles). Default: \large\bfseries.
|
||||
showHlines = false % Whether or not to show horizontal lines separating the rows. Default: false.
|
||||
showVlines = false %
|
||||
vlineAfter = '' % Show a vertical line after the specified date (or dates if a cell array of dates is passed). Default: empty.
|
||||
vlineAfterEndOfPeriod = false % Show a vertical line after the end of every period (i.e. after every year, after the fourth quarter, etc.). Default: false.
|
||||
data = '' % The dseries that provides the data for the table. Default: none.
|
||||
seriesToUse = '' % The names of the series contained in the dseries provided to the data option. If empty, use all series provided to data option. Default: empty.
|
||||
range = {} % The date range of the data to be displayed. Default: all.
|
||||
precision = 1 % The number of decimal places to report in the table data (rounding done via the round half away from zero method). Default: 1.
|
||||
writeCSV = false % Whether or not to write a CSV file containing the data displayed in the table. The file will be saved in the directory specified by tableDirName with the same base name as specified by tableName with the ending .csv. Default: false.
|
||||
highlightRows = {''} % A cell array containing the colors to use for row highlighting. See shadeColor for how to use colors with reports. Highlighting for a specific row can be overridden by using the tableRowColor option to addSeries. Default: empty.
|
||||
end
|
||||
methods
|
||||
function o = report_table(varargin)
|
||||
%function o = report_table(varargin)
|
||||
% Report_Table Class Constructor
|
||||
%
|
||||
% INPUTS
|
||||
% varargin 0 args : empty report_table object
|
||||
% 1 arg : must be report_table object (return a copy of arg)
|
||||
% > 1 args: option/value pairs (see structure below for options)
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [report_table] report_table object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
o.titleFormat = o.titleFormatDefalut;
|
||||
if nargin == 0
|
||||
return
|
||||
elseif nargin == 1
|
||||
assert(isa(varargin{1}, 'report_table'), ...
|
||||
'With one arg to the Report_Table constructor, you must pass a report_table object');
|
||||
o = varargin{1};
|
||||
return
|
||||
end
|
||||
|
||||
if round(nargin/2) ~= nargin/2
|
||||
error('Options to Report_Table constructor must be supplied in name/value pairs.');
|
||||
end
|
||||
|
||||
% Octave 5.1.0 has not implemented `properties` and issues a warning when using `fieldnames`
|
||||
if isoctave
|
||||
warnstate = warning('off', 'Octave:classdef-to-struct');
|
||||
end
|
||||
optNames = fieldnames(o);
|
||||
if isoctave
|
||||
warning(warnstate);
|
||||
end
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
ind = find(strcmpi(optNames, pair{1}));
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('%s is not a recognized option to the Report_Table constructor.', pair{1});
|
||||
end
|
||||
end
|
||||
|
||||
if ~iscell(o.range)
|
||||
o.range = {o.range};
|
||||
end
|
||||
|
||||
if isdates(o.vlineAfter)
|
||||
o.vlineAfter = {o.vlineAfter};
|
||||
end
|
||||
|
||||
% Check options provided by user
|
||||
if ischar(o.title)
|
||||
o.title = {o.title};
|
||||
end
|
||||
|
||||
if ischar(o.titleFormat)
|
||||
o.titleFormat = {o.titleFormat};
|
||||
end
|
||||
if length(o.title) ~= length(o.titleFormat)
|
||||
o.titleFormat = repmat(o.titleFormatDefalut, 1, length(o.title));
|
||||
end
|
||||
assert(islogical(o.showHlines), '@report_table.report_table: showHlines must be true or false');
|
||||
assert(islogical(o.showVlines), '@report_table.report_table: showVlines must be true or false');
|
||||
assert(isint(o.precision) && o.precision >= 0, '@report_table.report_table: precision must be a non-negative integer');
|
||||
assert(isempty(o.range) || length(o.range) <=2 && allCellsAreDatesRange(o.range), ...
|
||||
['@report_table.report_table: range is specified as a dates range, e.g. ' ...
|
||||
'''dates(''1999q1''):dates(''1999q3'')''.']);
|
||||
assert(isempty(o.data) || isdseries(o.data), ...
|
||||
'@report_table.report_table: data must be a dseries');
|
||||
assert(isempty(o.seriesToUse) || iscellstr(o.seriesToUse), ...
|
||||
'@report_table.report_table: seriesToUse must be a cell array of string(s)');
|
||||
assert(isempty(o.vlineAfter) || allCellsAreDates(o.vlineAfter), ...
|
||||
'@report_table.report_table: vlineAfter must be a dates');
|
||||
if o.showVlines
|
||||
o.vlineAfter = '';
|
||||
end
|
||||
assert(islogical(o.vlineAfterEndOfPeriod), ...
|
||||
'@report_table.report_table: vlineAfterEndOfPeriod must be true or false');
|
||||
assert(iscellstr(o.title), ...
|
||||
'@report_table.report_table: title must be a cell array of string(s)');
|
||||
assert(iscellstr(o.titleFormat), ...
|
||||
'@report_table.report_table: titleFormat must be a cell array of string(s)');
|
||||
assert(ischar(o.tableName), '@report_table.report_table: tableName must be a string');
|
||||
assert(ischar(o.tableDirName), '@report_table.report_table: tableDirName must be a string');
|
||||
assert(islogical(o.writeCSV), '@report_table.report_table: writeCSV must be either true or false');
|
||||
assert(iscellstr(o.highlightRows), '@report_table.report_table: highlightRowsmust be a cell string');
|
||||
|
||||
% using o.seriesToUse, create series objects and put them in o.series
|
||||
if ~isempty(o.data)
|
||||
if isempty(o.seriesToUse)
|
||||
for i=1:o.data.vobs
|
||||
o.series{end+1} = report_series('data', o.data{o.data.name{i}});
|
||||
end
|
||||
else
|
||||
for i=1:length(o.seriesToUse)
|
||||
o.series{end+1} = report_series('data', o.data{o.seriesToUse{i}});
|
||||
end
|
||||
end
|
||||
end
|
||||
o.data = '';
|
||||
o.seriesToUse = '';
|
||||
end
|
||||
end
|
||||
methods (Hidden = true)
|
||||
o = addData(o, varargin)
|
||||
o = addSeries(o, varargin)
|
||||
write(o, fid, pg, sec, row, col, rep_dir)
|
||||
end
|
||||
methods (Access = private)
|
||||
o = writeTableFile(o, pg, sec, row, col, rep_dir)
|
||||
end
|
||||
end
|
||||
|
||||
function tf = allCellsAreDatesRange(dcell)
|
||||
%function tf = allCellsAreDatesRange(dcell)
|
||||
% Determines if all the elements of dcell are a range of dates
|
||||
%
|
||||
% INPUTS
|
||||
% dcell cell of dates
|
||||
%
|
||||
% OUTPUTS
|
||||
% tf true if every entry of dcell is a range of dates
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2014-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(iscell(dcell));
|
||||
tf = true;
|
||||
for i=1:length(dcell)
|
||||
if ~(isdates(dcell{i}) && dcell{i}.ndat >= 2)
|
||||
tf = false;
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function tf = allCellsAreDates(dcell)
|
||||
%function tf = allCellsAreDates(dcell)
|
||||
% Determines if all the elements of dcell are dates objects
|
||||
%
|
||||
% INPUTS
|
||||
% dcell cell of dates objects
|
||||
%
|
||||
% OUTPUTS
|
||||
% tf true if every entry of dcell is a dates object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2014-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(iscell(dcell));
|
||||
tf = true;
|
||||
for i=1:length(dcell)
|
||||
if ~isdates(dcell{i})
|
||||
tf = false;
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,39 @@
|
|||
function write(o, fid, pg, sec, row, col, rep_dir)
|
||||
%function write(o, fid, pg, sec, row, col, rep_dir)
|
||||
% Write a Table object
|
||||
%
|
||||
% INPUTS
|
||||
% o [table] table object
|
||||
% fid [integer] file id
|
||||
% pg [integer] this page number
|
||||
% sec [integer] this section number
|
||||
% row [integer] this row number
|
||||
% col [integer] this col number
|
||||
% rep_dir [string] directory containing report.tex
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [table] table object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
tableName = writeTableFile(o, pg, sec, row, col, rep_dir);
|
||||
fprintf(fid, '\\input{%s}', tableName);
|
||||
end
|
|
@ -0,0 +1,250 @@
|
|||
function tableName = writeTableFile(o, pg, sec, row, col, rep_dir)
|
||||
%function tableName = writeTableFile(o, pg, sec, row, col, rep_dir)
|
||||
% Write a Report_Table object
|
||||
%
|
||||
% INPUTS
|
||||
% o [report_table] report_table object
|
||||
% pg [integer] this page number
|
||||
% sec [integer] this section number
|
||||
% row [integer] this row number
|
||||
% col [integer] this col number
|
||||
% rep_dir [string] directory containing report.tex
|
||||
%
|
||||
% OUTPUTS
|
||||
% tableName [string] name of table written
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
ne = length(o.series);
|
||||
is_data_table = ~isempty(o.table_data);
|
||||
if ne == 0 && ~is_data_table
|
||||
warning('@report_table.write: no series to plot, returning');
|
||||
return
|
||||
end
|
||||
if is_data_table
|
||||
ne = size(o.table_data{1}.data,2);
|
||||
end
|
||||
if exist([rep_dir '/' o.tableDirName], 'dir') ~= 7
|
||||
mkdir([rep_dir '/' o.tableDirName]);
|
||||
end
|
||||
if isempty(o.tableName)
|
||||
tableName = sprintf([o.tableDirName '/table_pg%d_sec%d_row%d_col%d.tex'], pg, sec, row, col);
|
||||
else
|
||||
tableName = [o.tableDirName '/' o.tableName];
|
||||
end
|
||||
|
||||
[fid, msg] = fopen([rep_dir '/' tableName], 'w');
|
||||
if fid == -1
|
||||
error(['@report_table.writeTableFile: ' msg]);
|
||||
end
|
||||
|
||||
fprintf(fid, '%% Report_Table Object written %s\n', datestr(now));
|
||||
fprintf(fid, '\\begin{tabular}[t]{l}\n');
|
||||
fprintf(fid, '\\setlength{\\parindent}{6pt}\n');
|
||||
fprintf(fid, '\\setlength{\\tabcolsep}{4pt}\n');
|
||||
|
||||
%number of left-hand columns, 1 until we allow the user to group data,
|
||||
% e.g.: GDP Europe
|
||||
% GDP France
|
||||
% GDP Germany
|
||||
% this example would be two lh columns, with GDP Europe spanning both
|
||||
nlhc = 1;
|
||||
if ~is_data_table
|
||||
fprintf(fid, '\\begin{tabular}{@{}l');
|
||||
if isempty(o.range)
|
||||
Dates = getMaxRange(o.series);
|
||||
o.range = {Dates};
|
||||
else
|
||||
Dates = o.range{1};
|
||||
end
|
||||
ndates = Dates.ndat;
|
||||
|
||||
for i=1:ndates
|
||||
fprintf(fid, 'r');
|
||||
if o.showVlines
|
||||
fprintf(fid, '|');
|
||||
elseif o.vlineAfterEndOfPeriod && subperiod(Dates(i)) == Dates(i).freq
|
||||
fprintf(fid, '|');
|
||||
elseif ~isempty(o.vlineAfter)
|
||||
for j=1:length(o.vlineAfter)
|
||||
if Dates(i) == o.vlineAfter{j}
|
||||
fprintf(fid, '|');
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
years = unique(year(Dates));
|
||||
if length(o.range) > 1
|
||||
rhscols = strings(o.range{2});
|
||||
if o.range{2}.freq == 1
|
||||
rhscols = strrep(rhscols, 'Y', '');
|
||||
end
|
||||
else
|
||||
rhscols = {};
|
||||
end
|
||||
for i=1:length(rhscols)
|
||||
fprintf(fid, 'r');
|
||||
if o.showVlines
|
||||
fprintf(fid, '|');
|
||||
end
|
||||
end
|
||||
nrhc = length(rhscols);
|
||||
ncols = ndates+nlhc+nrhc;
|
||||
fprintf(fid, '@{}}%%\n');
|
||||
for i=1:length(o.title)
|
||||
if ~isempty(o.title{i})
|
||||
fprintf(fid, '\\multicolumn{%d}{c}{%s %s}\\\\\n', ...
|
||||
ncols, o.titleFormat{i}, o.title{i});
|
||||
end
|
||||
end
|
||||
fprintf(fid, '\\toprule%%\n');
|
||||
|
||||
% Column Headers
|
||||
thdr = num2cell(years, size(years, 1));
|
||||
if Dates.freq == 1
|
||||
for i=1:size(thdr, 1)
|
||||
fprintf(fid, ' & %d', thdr{i, 1});
|
||||
end
|
||||
for i=1:length(rhscols)
|
||||
fprintf(fid, ' & %s', rhscols{i});
|
||||
end
|
||||
else
|
||||
thdr{1, 2} = subperiod(Dates)';
|
||||
if size(thdr, 1) > 1
|
||||
for i=2:size(thdr, 1)
|
||||
split = find(thdr{i-1, 2} == Dates.freq, 1, 'first');
|
||||
assert(~isempty(split), '@report_table.writeTableFile: Shouldn''t arrive here');
|
||||
thdr{i, 2} = thdr{i-1, 2}(split+1:end);
|
||||
thdr{i-1, 2} = thdr{i-1, 2}(1:split);
|
||||
end
|
||||
end
|
||||
for i=1:size(thdr, 1)
|
||||
fprintf(fid, ' & \\multicolumn{%d}{c}{%d}', size(thdr{i,2}, 2), thdr{i,1});
|
||||
end
|
||||
for i=1:length(rhscols)
|
||||
fprintf(fid, ' & %s', rhscols{i});
|
||||
end
|
||||
fprintf(fid, '\\\\\n');
|
||||
switch Dates.freq
|
||||
case 4
|
||||
sep = 'Q';
|
||||
case 12
|
||||
sep = 'M';
|
||||
case 52
|
||||
sep = 'W';
|
||||
otherwise
|
||||
error('@report_table.writeTableFile: Invalid frequency.');
|
||||
end
|
||||
for i=1:size(thdr, 1)
|
||||
period = thdr{i, 2};
|
||||
for j=1:size(period, 2)
|
||||
fprintf(fid, ' & \\multicolumn{1}{c');
|
||||
if o.showVlines
|
||||
fprintf(fid, '|');
|
||||
elseif o.vlineAfterEndOfPeriod && j == size(period, 2)
|
||||
fprintf(fid, '|');
|
||||
elseif ~isempty(o.vlineAfter)
|
||||
for k=1:length(o.vlineAfter)
|
||||
if year(o.vlineAfter{k}) == thdr{i} && ...
|
||||
subperiod(o.vlineAfter{k}) == period(j)
|
||||
fprintf(fid, '|');
|
||||
end
|
||||
end
|
||||
end
|
||||
fprintf(fid, '}{%s%d}', sep, period(j));
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
fprintf(fid, '\\begin{tabular}{');
|
||||
if o.showVlines
|
||||
fprintf(fid, '|');
|
||||
end
|
||||
if ~isempty(o.table_data{1}.column_names) && ne ~= length(o.table_data{1}.column_names)
|
||||
error(['@report_table.writeTableFile: when writing a data table and passing the ' ...
|
||||
'`column_names` option, it must have the same number of elements as the ' ...
|
||||
'number of columns in the data']);
|
||||
end
|
||||
for i = 1:ne
|
||||
if isempty(o.table_data{1}.column_names) ||isempty(o.table_data{1}.column_names{i})
|
||||
fprintf(fid, 'l');
|
||||
else
|
||||
fprintf(fid, 'r');
|
||||
end
|
||||
if o.showVlines
|
||||
fprintf(fid, '|');
|
||||
end
|
||||
end
|
||||
fprintf(fid,'}');
|
||||
end
|
||||
|
||||
% Write Report_Table Data
|
||||
if ~is_data_table
|
||||
fprintf(fid, '\\\\[-2pt]%%\n');
|
||||
fprintf(fid, '\\hline%%\n');
|
||||
fprintf(fid, '%%\n');
|
||||
if o.writeCSV
|
||||
csvseries = dseries();
|
||||
end
|
||||
for i=1:ne
|
||||
o.series{i}.writeSeriesForTable(fid, o.range, o.precision, ncols, o.highlightRows{mod(i,length(o.highlightRows))+1});
|
||||
if o.writeCSV
|
||||
if isempty(o.series{i}.tableSubSectionHeader)
|
||||
csvseries = [csvseries ...
|
||||
o.series{i}.data(Dates).set_names([...
|
||||
num2str(i) '_' ...
|
||||
o.series{i}.data.name{:}])];
|
||||
end
|
||||
end
|
||||
if o.showHlines
|
||||
fprintf(fid, '\\hline\n');
|
||||
end
|
||||
end
|
||||
if o.writeCSV
|
||||
csvseries.save(strrep(o.tableName, '.tex', ''), 'csv');
|
||||
end
|
||||
else
|
||||
if ~isempty(o.table_data{1}.column_names)
|
||||
fprintf(fid, '%%\n');
|
||||
fprintf(fid, '\\hline%%\n');
|
||||
fprintf(fid, '%%\n');
|
||||
end
|
||||
for i = 1:ne
|
||||
if ~isempty(o.table_data{1}.column_names) && ~isempty(o.table_data{1}.column_names{i})
|
||||
fprintf(fid, '%s', o.table_data{1}.column_names{i});
|
||||
end
|
||||
if i ~= ne
|
||||
fprintf(fid, ' & ');
|
||||
end
|
||||
end
|
||||
fprintf(fid, '\\\\[-2pt]%%\n');
|
||||
fprintf(fid, '\\hline%%\n');
|
||||
o.table_data{1}.writeDataForTable(fid, o.precision);
|
||||
end
|
||||
fprintf(fid, '\\bottomrule\n');
|
||||
fprintf(fid, '\\end{tabular}\n');
|
||||
fprintf(fid, '\\end{tabular}\n');
|
||||
fprintf(fid, '\\setlength{\\parindent}{0pt}\n \\par \\medskip\n\n');
|
||||
fprintf(fid, '%% End Report_Table Object\n');
|
||||
if fclose(fid) == -1
|
||||
error('@report_table.writeTableFile: closing %s\n', o.filename);
|
||||
end
|
||||
end
|
|
@ -0,0 +1,39 @@
|
|||
function o = addData(o, varargin)
|
||||
%function o = addData(o, varargin)
|
||||
% Add a series
|
||||
%
|
||||
% INPUTS
|
||||
% o [section] section object
|
||||
% varargin arguments to report_series()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.elements), ...
|
||||
'@section.addData: Before adding data, you must add either a table');
|
||||
assert(~isa(o.elements{1}, 'paragraph'), ...
|
||||
'@section.addSeries: A section that contains a paragraph cannot contain a graph or a table');
|
||||
assert(isa(o.elements{end}, 'report_table'), ...
|
||||
'@report.addData: you can only add data to a report_table object');
|
||||
o.elements{end}.addData(varargin{:});
|
||||
end
|
|
@ -0,0 +1,37 @@
|
|||
function o = addGraph(o, varargin)
|
||||
%function o = addGraph(o, varargin)
|
||||
% Add a graph
|
||||
%
|
||||
% INPUTS
|
||||
% o [section] section object
|
||||
% varargin arguments to report_graph()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2020 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
if ~isempty(o.elements)
|
||||
assert(~isa(o.elements{1}, 'paragraph'), ...
|
||||
'@section.addSeries: A section that contains a paragraph cannot contain a graph or a table');
|
||||
end
|
||||
o.elements{end+1} = report_graph(varargin{:});
|
||||
end
|
|
@ -0,0 +1,39 @@
|
|||
function o = addParagraph(o, varargin)
|
||||
%function o = addParagraph(o, varargin)
|
||||
% Add a paragraph
|
||||
%
|
||||
% INPUTS
|
||||
% o [section] section object
|
||||
% varargin arguments to paragraph()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated page object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2014-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(o.cols == 1, ...
|
||||
'@addParagraph: you can only add a paragraph to a Section that contains one column');
|
||||
for i = 1:length(o.elements)
|
||||
assert(isa(o.elements{i}, 'paragraph'), ...
|
||||
'@addParagraph: you can only add a paragraph to a Section that contains only paragraphs');
|
||||
end
|
||||
o.elements{end+1} = paragraph(varargin{:});
|
||||
end
|
|
@ -0,0 +1,39 @@
|
|||
function o = addSeries(o, varargin)
|
||||
%function o = addSeries(o, varargin)
|
||||
% Add a series
|
||||
%
|
||||
% INPUTS
|
||||
% o [section] section object
|
||||
% varargin arguments to report_series()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2020 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(~isempty(o.elements), ...
|
||||
'@section.addSeries: Before adding a series, you must add either a graph or a table');
|
||||
assert(~isa(o.elements{1}, 'paragraph'), ...
|
||||
'@section.addSeries: A section that contains a paragraph cannot contain a graph or a table');
|
||||
assert(isa(o.elements{end}, 'report_graph') || isa(o.elements{end}, 'report_table'), ...
|
||||
'@report.addSeries: you can only add a series to a report_table or report_graph object');
|
||||
o.elements{end}.addSeries(varargin{:});
|
||||
end
|
|
@ -0,0 +1,37 @@
|
|||
function o = addTable(o, varargin)
|
||||
%function o = addTable(o, varargin)
|
||||
% Add a report_table
|
||||
%
|
||||
% INPUTS
|
||||
% o [section] section object
|
||||
% varargin arguments to report_table()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
if ~isempty(o.elements)
|
||||
assert(~isa(o.elements{1}, 'paragraph'), ...
|
||||
'@section.addSeries: A section that contains a paragraph cannot contain a graph or a table');
|
||||
end
|
||||
o.elements{end+1} = report_table(varargin{:});
|
||||
end
|
|
@ -0,0 +1,37 @@
|
|||
function o = addVspace(o, varargin)
|
||||
%function o = addVspace(o, varargin)
|
||||
% Add a vspace
|
||||
%
|
||||
% INPUTS
|
||||
% o [section] section object
|
||||
% varargin arguments to vspace()
|
||||
%
|
||||
% OUTPUTS
|
||||
% updated section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
if ~isempty(o.elements)
|
||||
assert(~isa(o.elements{1}, 'paragraph'), ...
|
||||
'@section.addSeries: A section that contains a paragraph cannot contain a graph or a table');
|
||||
end
|
||||
o.elements{end+1} = vspace(varargin{:});
|
||||
end
|
|
@ -0,0 +1,35 @@
|
|||
function lastIndex = end(o, k, n)
|
||||
% function lastIndex = end(o, k, n)
|
||||
% End keyword
|
||||
%
|
||||
% INPUTS
|
||||
% o [section] section object
|
||||
% k [integer] index where end appears
|
||||
% n [integer] number of indices
|
||||
%
|
||||
% OUTPUTS
|
||||
% lastIndex [integer] last section index
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(k==1 && n==1, '@section/end: section only has one dimension');
|
||||
lastIndex = numElements(o);
|
||||
end
|
|
@ -0,0 +1,22 @@
|
|||
function n = numElements(o)
|
||||
% function n = numElements(o)
|
||||
|
||||
% Copyright © 2013-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
n = length(o.elements);
|
||||
end
|
|
@ -0,0 +1,90 @@
|
|||
classdef section < handle
|
||||
% section Class
|
||||
%
|
||||
% Copyright © 2013-2022 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
properties (Access = private)
|
||||
elements = {}
|
||||
end
|
||||
properties (SetAccess = private)
|
||||
cols = 1 % The number of columns in the section. Default: 1.
|
||||
height = '' % A string to be used with the \sectionheight LATEX command. Default: '!'
|
||||
end
|
||||
methods
|
||||
function o = section(varargin)
|
||||
%function o = section(varargin)
|
||||
% Section Class Constructor
|
||||
%
|
||||
% INPUTS
|
||||
% varargin 0 args : empty section object
|
||||
% 1 arg : must be section object (return a copy of arg)
|
||||
% > 1 args: option/value pairs (see structure below for options)
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [section] section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
if nargin == 0
|
||||
return
|
||||
elseif nargin == 1
|
||||
assert(isa(varargin{1}, 'section'), ...
|
||||
'With one arg to Section constructor, you must pass a section object');
|
||||
o = varargin{1};
|
||||
return
|
||||
end
|
||||
|
||||
if round(nargin/2) ~= nargin/2
|
||||
error('@section.section: options must be supplied in name/value pairs.');
|
||||
end
|
||||
|
||||
% Octave 5.1.0 has not implemented `properties` and issues a warning when using `fieldnames`
|
||||
if isoctave
|
||||
warnstate = warning('off', 'Octave:classdef-to-struct');
|
||||
end
|
||||
optNames = fieldnames(o);
|
||||
if isoctave
|
||||
warning(warnstate);
|
||||
end
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
ind = find(strcmpi(optNames, pair{1}));
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@section.section: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
|
||||
% Check options provided by user
|
||||
assert(isint(o.cols), '@section.section: cols must be an integer');
|
||||
assert(isempty(o.height) || ischar(o.height), ...
|
||||
'@section.section: cols must be a string');
|
||||
end
|
||||
end
|
||||
methods (Hidden = true)
|
||||
o = addGraph(o, varargin)
|
||||
o = addParagraph(o, varargin)
|
||||
o = addTable(o, varargin)
|
||||
o = addVspace(o, varargin)
|
||||
lastIndex = end(o, k, n)
|
||||
n = numElements(o)
|
||||
write(o, fid, pg, sec, rep_dir)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,94 @@
|
|||
function write(o, fid, pg, sec, rep_dir)
|
||||
%function write(o, fid, pg, sec, rep_dir)
|
||||
% Write Section object
|
||||
%
|
||||
% INPUTS
|
||||
% o [section] section object
|
||||
% fid [integer] file id
|
||||
% pg [integer] this page number
|
||||
% sec [integer] this section number
|
||||
% rep_dir [string] directory containing report.tex
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [section] section object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
fprintf(fid, '%% Section Object written %s\n', datestr(now));
|
||||
if isempty(o.elements)
|
||||
warning(['reporting:section.write(): trying to print a section ' ...
|
||||
'with no elements. Perhaps you forgot to overwrite the report object.']);
|
||||
return
|
||||
end
|
||||
|
||||
if ~isempty(o.height)
|
||||
fprintf(fid, '\\setlength\\sectionheight{%s}%%\n', o.height);
|
||||
end
|
||||
fprintf(fid, '\\maxsizebox{\\linewidth}{');
|
||||
if isempty(o.height)
|
||||
fprintf(fid, '!');
|
||||
else
|
||||
fprintf(fid, '\\sectionheight');
|
||||
end
|
||||
fprintf(fid, '}{%%\n');
|
||||
fprintf(fid, '\\begin{tabular}[t]{');
|
||||
for i=1:o.cols
|
||||
if ~isa(o.elements{1}, 'paragraph')
|
||||
% if one element is a paragraph, they all are
|
||||
% due to check in add*.m functions
|
||||
fprintf(fid, 'l');
|
||||
else
|
||||
fprintf(fid, 'c');
|
||||
end
|
||||
end
|
||||
fprintf(fid, '}\n');
|
||||
|
||||
ne = numElements(o);
|
||||
row = 1;
|
||||
col = 1;
|
||||
for i=1:ne
|
||||
if isa(o.elements{i}, 'vspace')
|
||||
o.elements{i}.write(fid);
|
||||
fprintf(fid, '\\\\\n');
|
||||
if col ~= o.cols
|
||||
fprintf(fid, '\\end{tabular}}\\\\\n');
|
||||
fprintf(fid, '%% End Section Object\n\n');
|
||||
return
|
||||
end
|
||||
else
|
||||
if isa(o.elements{i}, 'paragraph')
|
||||
o.elements{i}.write(fid);
|
||||
else
|
||||
o.elements{i}.write(fid, pg, sec, row, col, rep_dir);
|
||||
end
|
||||
if col ~= o.cols
|
||||
fprintf(fid, ' & ');
|
||||
col = col + 1;
|
||||
else
|
||||
fprintf(fid, '\\\\\n');
|
||||
row = row + 1;
|
||||
col = 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
fprintf(fid, '\\end{tabular}}\\\\\n');
|
||||
fprintf(fid, '%% End Section Object\n\n');
|
||||
end
|
|
@ -0,0 +1,81 @@
|
|||
classdef vspace < handle
|
||||
% vspace Class
|
||||
%
|
||||
% Copyright © 2013-2022 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
properties (SetAccess = private)
|
||||
hline = 0 % Number of horizontal lines to be inserted. Default 0
|
||||
number = 1 % Number of new lines to be inserted. Default 1
|
||||
end
|
||||
methods
|
||||
function o = vspace(varargin)
|
||||
%function o = vspace(varargin)
|
||||
% Vspace Class Constructor
|
||||
%
|
||||
% INPUTS
|
||||
% varargin 0 args : empty vspace object
|
||||
% 1 arg : must be vspace object (return a copy of arg)
|
||||
% > 1 args: option/value pairs (see structure below for options)
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [vspace] vspace object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
if nargin == 0
|
||||
return
|
||||
elseif nargin == 1
|
||||
assert(isa(varargin{1}, 'vspace'), ...
|
||||
'@vspace.vspace: with one arg to Vspace constructor, you must pass a vspace object');
|
||||
o = varargin{1};
|
||||
return
|
||||
end
|
||||
|
||||
if round(nargin/2) ~= nargin/2
|
||||
error('@vspace.vspace: options must be supplied in name/value pairs.');
|
||||
end
|
||||
|
||||
% Octave 5.1.0 has not implemented `properties` and issues a warning when using `fieldnames`
|
||||
if isoctave
|
||||
warnstate = warning('off', 'Octave:classdef-to-struct');
|
||||
end
|
||||
optNames = fieldnames(o);
|
||||
if isoctave
|
||||
warning(warnstate);
|
||||
end
|
||||
|
||||
% overwrite default values
|
||||
for pair = reshape(varargin, 2, [])
|
||||
ind = find(strcmpi(optNames, pair{1}));
|
||||
assert(isempty(ind) || length(ind) == 1);
|
||||
if ~isempty(ind)
|
||||
o.(optNames{ind}) = pair{2};
|
||||
else
|
||||
error('@vspace.vspace: %s is not a recognized option.', pair{1});
|
||||
end
|
||||
end
|
||||
|
||||
% Check options provided by user
|
||||
assert(isint(o.number), '@vspace.vspace: number must be an integer');
|
||||
assert(isint(o.hline), '@vspace.vspace: hline must be an integer');
|
||||
end
|
||||
end
|
||||
methods (Hidden = true)
|
||||
% Methods defined in separate files
|
||||
write(o, fid);
|
||||
end
|
||||
end
|
|
@ -0,0 +1,36 @@
|
|||
function o = write(o, fid)
|
||||
%function o = write(o, fid)
|
||||
% Write a Vspace object
|
||||
%
|
||||
% INPUTS
|
||||
% o [vspace] vspace object
|
||||
% fid [integer] file id
|
||||
%
|
||||
% OUTPUTS
|
||||
% o [vspace] vspace object
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
fprintf(fid, repmat(' \\par \\medskip ', 1, o.number));
|
||||
if o.hline > 0
|
||||
fprintf(fid, ['\\\\\n' repmat('\\noindent\\makebox[\\linewidth]{\\rule{\\linewidth}{0.4pt}}\\\\', 1, o.hline)]);
|
||||
end
|
||||
end
|
|
@ -0,0 +1,41 @@
|
|||
function str = addCommasToCellStr(cs)
|
||||
%function ncs = addCommasToCellStr(cs)
|
||||
% Add commas between entries of cell string and return a sting
|
||||
%
|
||||
% INPUTS
|
||||
% cs [Cell Arrays of Strings] Cell string in which to intersperse commas
|
||||
%
|
||||
% OUTPUTS
|
||||
% str [string] cs with commas interspersed
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% none
|
||||
|
||||
% Copyright © 2016 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
assert(iscellstr(cs), 'addCommasToCellStr: cs should be a cell array of strings.');
|
||||
|
||||
str = '';
|
||||
for i=1:length(cs)
|
||||
if i < length(cs)
|
||||
str = [str cs{i} ', '];
|
||||
else
|
||||
str = [str cs{i}];
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,36 @@
|
|||
function dd = getMaxRange(cellser)
|
||||
% function dd = getMaxRange(cellser)
|
||||
|
||||
% Copyright © 2013-2015 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
ddmin = dates();
|
||||
ddmax = dates();
|
||||
ne = length(cellser);
|
||||
for i=1:ne
|
||||
ddt = cellser{i}.getRange();
|
||||
if ~isempty(ddt)
|
||||
if isempty(ddmin)
|
||||
ddmin = ddt(1);
|
||||
ddmax = ddt(end);
|
||||
else
|
||||
ddmin = min(ddt(1), ddmin);
|
||||
ddmax = max(ddt(end), ddmax);
|
||||
end
|
||||
end
|
||||
end
|
||||
dd = ddmin:ddmax;
|
|
@ -0,0 +1,28 @@
|
|||
function initialize_reporting_toolbox()
|
||||
%function initialize_reporting_toolbox()
|
||||
%
|
||||
% Function to set the necessary paths for the Reporting toolbox
|
||||
%
|
||||
% Copyright © 2015-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
% Find reporting source directory
|
||||
reporting_src_root = strrep(which('initialize_reporting_toolbox'), 'initialize_reporting_toolbox.m', '');
|
||||
|
||||
% Add path to reporting source
|
||||
addpath([reporting_src_root '/../macros']);
|
||||
end
|
|
@ -0,0 +1,34 @@
|
|||
function rep = AnnualTable(rep, db_a, dc_a, seriesRootName, arange)
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
shortNames = {'US', 'EU', 'JA', 'EA6', 'LA6', 'RC6'};
|
||||
longNames = {'Coca Cola', 'Kinder Bueno', 'Pizza', ...
|
||||
'Vegetarianism Is Good', 'OS X', 'Dothraki'};
|
||||
|
||||
rep.addSeries('tableSubSectionHeader', 'A group', ...
|
||||
'tableRowColor', 'red!22');
|
||||
for i = 1:length(shortNames)
|
||||
db_a.tex_rename_([seriesRootName shortNames{i}], longNames{i});
|
||||
rep.addSeries('data', db_a{[seriesRootName shortNames{i}]});
|
||||
delta = dc_a{[seriesRootName shortNames{i}]}-db_a{[seriesRootName shortNames{i}]};
|
||||
delta.tex_rename_('$\Delta$');
|
||||
rep.addSeries('data', delta, ...
|
||||
'tableShowMarkers', true, ...
|
||||
'tableAlignRight', true);
|
||||
end
|
||||
end
|
|
@ -0,0 +1,38 @@
|
|||
function rep = CommResidTablePage(rep, db_q, dc_q, trange, vline_after)
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
seriesNames = {{'RES_LRPOIL_GAP_WORLD'}, ...
|
||||
{'RES_LRPOIL_BAR_WORLD'}, ...
|
||||
{'RES_LRPOIL_G_WORLD'}, ...
|
||||
{'RES_LRPFOOD_GAP_WORLD'}, ...
|
||||
{'RES_LRPFOOD_BAR_WORLD'}, ...
|
||||
{'RES_LRPFOOD_G_WORLD'}};
|
||||
|
||||
rep.addTable('title', 'Commodities', ...
|
||||
'range', trange, ...
|
||||
'vlineAfter', vline_after);
|
||||
|
||||
for i = 1:length(seriesNames)
|
||||
rep.addSeries('data', db_q{seriesNames{i}{1}});
|
||||
delta = db_q{seriesNames{i}{1}} - dc_q{seriesNames{i}{1}};
|
||||
delta.tex_rename_('$\Delta$');
|
||||
rep.addSeries('data', delta, ...
|
||||
'tableShowMarkers', true, ...
|
||||
'tableAlignRight', true);
|
||||
end
|
||||
end
|
|
@ -0,0 +1,113 @@
|
|||
function rep = CountryGraphPage(rep, countryAbbr, db_q, dc_q, prange, srange)
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
startpoint = strings(prange(1));
|
||||
shaded = strings(srange(1));
|
||||
endpoint = strings(prange(end));
|
||||
rep.addGraph('title', 'Interest Rate', ...
|
||||
'xrange', prange, ...
|
||||
'shade', srange, ...
|
||||
'showZeroline', true, ...
|
||||
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
|
||||
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
|
||||
'xTickLabelRotation', 0, ...
|
||||
'writeCSV', true);
|
||||
rep.addSeries('data', db_q{['RS_' countryAbbr]}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineStyle', 'dashed', ...
|
||||
'graphLineWidth', 1.5);
|
||||
rep.addSeries('data', dc_q{['RS_' countryAbbr]}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineWidth', 1.5);
|
||||
|
||||
rep.addGraph('title', 'Output Gap', ...
|
||||
'xrange', prange, ...
|
||||
'shade', srange, ...
|
||||
'showZeroline', true, ...
|
||||
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
|
||||
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
|
||||
'xTickLabelRotation', 0);
|
||||
rep.addSeries('data', db_q{['Y_' countryAbbr]}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineStyle', 'dashed', ...
|
||||
'graphLineWidth', 1.5);
|
||||
rep.addSeries('data', dc_q{['Y_' countryAbbr]}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineWidth', 1.5);
|
||||
|
||||
rep.addGraph('title', 'Headline Inflation (y/y)', ...
|
||||
'xrange', prange, ...
|
||||
'shade', srange, ...
|
||||
'showZeroline', true, ...
|
||||
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
|
||||
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
|
||||
'xTickLabelRotation', 0);
|
||||
rep.addSeries('data', db_q{['PCH_PIE4_' countryAbbr]}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineStyle', 'dashed', ...
|
||||
'graphLineWidth', 1.5);
|
||||
rep.addSeries('data', dc_q{['PCH_PIE4_' countryAbbr]}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineWidth', 1.5);
|
||||
|
||||
rep.addGraph('title', 'Headline Inflation (q/q)', ...
|
||||
'xrange', prange, ...
|
||||
'shade', srange, ...
|
||||
'showZeroline', true, ...
|
||||
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
|
||||
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
|
||||
'xTickLabelRotation', 0);
|
||||
rep.addSeries('data', db_q{['PCH_PIE_' countryAbbr]}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineStyle', 'dashed', ...
|
||||
'graphLineWidth', 1.5);
|
||||
rep.addSeries('data', dc_q{['PCH_PIE_' countryAbbr]}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineWidth', 1.5);
|
||||
|
||||
rep.addGraph('title', 'GDP Growth (q/q)', ...
|
||||
'xrange', prange, ...
|
||||
'shade', srange, ...
|
||||
'showZeroline', true, ...
|
||||
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
|
||||
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
|
||||
'xTickLabelRotation', 0);
|
||||
rep.addSeries('data', db_q{['PCH_GROWTH_' countryAbbr]}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineStyle', 'dashed', ...
|
||||
'graphLineWidth', 1.5);
|
||||
rep.addSeries('data', dc_q{['PCH_GROWTH_' countryAbbr]}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineWidth', 1.5);
|
||||
|
||||
rep.addGraph('title', 'Core Inflation (y/y)', ...
|
||||
'titleFormat', '\Huge', ...
|
||||
'xrange', prange, ...
|
||||
'shade', srange, ...
|
||||
'showZeroline', true, ...
|
||||
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
|
||||
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
|
||||
'xTickLabelRotation', 0);
|
||||
rep.addSeries('data', db_q{['PCH_PIEX4_' countryAbbr]}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineStyle', 'dashed', ...
|
||||
'graphLineWidth', 1.5);
|
||||
rep.addSeries('data', dc_q{['PCH_PIEX4_' countryAbbr]}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineWidth', 1.5);
|
||||
end
|
|
@ -0,0 +1,68 @@
|
|||
function rep = CountryTablePage(rep, countryAbbr, countryName, db_q, dc_q, db_a, dc_a, trange, vline_after)
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
seriesNames = {{'RS_', 'Short Term Interest Rate'}, ...
|
||||
{'RR_', 'Real Interest Rate'}, ...
|
||||
{'BLT_','Bank Lending Tightening' }, ...
|
||||
{'PCH_GROWTH_', 'Real GDP Growth (@q ar)'}, ...
|
||||
{'PCH_GROWTH4_', '\% y-o-y'}, ...
|
||||
{'PCH_GROWTH_BAR_', 'Potential GDP Growth (@q ar)'}, ...
|
||||
{'PCH_GROWTH4_BAR_', '\% y-o-y'}, ...
|
||||
{'PCH_PIE_', 'Headline CPI Inflation (@q ar)'}, ...
|
||||
{'PCH_PIE4_', '\% y-o-y'}, ...
|
||||
{'PCH_PIEX_', 'Core CPI Inflation (@q ar)'}, ...
|
||||
{'PCH_PIEX4_', '\% y-o-y'}, ...
|
||||
{'PCH_PIE_GAS_', 'Gas Inflation (@q ar)'}, ...
|
||||
{'PCH_PIE4_GAS_', '\% y-o-y'}, ...
|
||||
{'PCH_PIE_CONSFOOD_', 'Food Inflation (@q ar)'}, ...
|
||||
{'PCH_PIE4_CONSFOOD_', '\% y-o-y'}, ...
|
||||
{'PCH_DOT_REER_T_', 'REER Depreciation (@q ar)'}, ...
|
||||
{'PCH_DOT4_REER_T_', '\% y-o-y'}, ...
|
||||
{'Y_', 'Output Gap'}, ...
|
||||
{'UNR_', 'Unemployment Rate'}, ...
|
||||
{'UNR_BAR_', 'NAIRU'}, ...
|
||||
{'UNR_GAP_', 'Unemployment Gap'}};
|
||||
|
||||
otherThree = {'EA6','LA6','RC6'};
|
||||
notForOtherThree = {'BLT_', 'UNR_', 'UNR_BAR_', 'UNR_GAP_'};
|
||||
|
||||
rep.addTable('title', countryName, ...
|
||||
'range', {trange, dates('2012a'):dates('2014a')}, ...
|
||||
'vlineAfter', {vline_after dates('2014q4')}, ...
|
||||
'writeCSV', true, ...
|
||||
'highlightRows', {'gray!22', 'cyan!33', 'blue!44', 'red!55'});
|
||||
|
||||
for i = 1:length(seriesNames)
|
||||
if any(strcmp(countryAbbr, otherThree)) && ...
|
||||
any(strcmp(seriesNames{i}{1}, notForOtherThree))
|
||||
continue
|
||||
end
|
||||
db_q.tex_rename_([seriesNames{i}{1} countryAbbr], seriesNames{i}{2});
|
||||
rep.addSeries('data', db_q{[seriesNames{i}{1} countryAbbr]}, ...
|
||||
'tableDataRhs', db_a{[seriesNames{i}{1} countryAbbr]});
|
||||
delta = db_q{[seriesNames{i}{1} countryAbbr]}-dc_q{[seriesNames{i}{1} countryAbbr]};
|
||||
delta.tex_rename_('$\Delta$');
|
||||
|
||||
deltaa = db_a{[seriesNames{i}{1} countryAbbr]}-dc_a{[seriesNames{i}{1} countryAbbr]};
|
||||
deltaa.tex_rename_('$\Delta$');
|
||||
rep.addSeries('data', delta, ...
|
||||
'tableShowMarkers', true, ...
|
||||
'tableRowIndent', 2, ...
|
||||
'tableDataRhs', deltaa);
|
||||
end
|
||||
end
|
|
@ -0,0 +1,65 @@
|
|||
function rep = ResidTablePage(rep, countryAbbr, countryName, db_q, dc_q, trange, vline_after)
|
||||
% Copyright © 2011-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
seriesNames = {{'RES_RS_'}, ...
|
||||
{'RES_RR_BAR_'}, ...
|
||||
{'RES_BLT_'}, ...
|
||||
{'RES_BLT_BAR_'}, ...
|
||||
{'RES_YY_'}, ...
|
||||
{'RES_Y_'}, ...
|
||||
{'RES_LGDP_BAR_'}, ...
|
||||
{'RES_G_'}, ...
|
||||
{'RES_UNR_GAP_'}, ...
|
||||
{'RES_UNR_G_'}, ...
|
||||
{'RES_UNR_BAR_'}, ...
|
||||
{'RES_RR_DIFF_'}, ...
|
||||
{'RES_LZ_BAR_'}, ...
|
||||
{'RES_DOT_LZ_BAR_'}, ...
|
||||
{'RES_PIETAR_'}, ...
|
||||
{'RES_PIE_'}, ...
|
||||
{'RES_PIEX_'}, ...
|
||||
{'RES_PIE_GAS_'}, ...
|
||||
{'RES_PIE_CONSFOOD_'}};
|
||||
|
||||
otherThree = {'EA6', 'LA6', 'RC6'};
|
||||
notForOtherThree = {'RES_BLT_', 'RES_BLT_BAR_', 'RES_UNR_GAP_', 'RES_UNR_G_', 'RES_UNR_BAR_'};
|
||||
|
||||
notForUS = {'RES_RR_DIFF_', 'RES_LZ_BAR_'};
|
||||
|
||||
firstThree = {'US', 'EU', 'JA'};
|
||||
notForFirstThree = {'RES_DOT_LZ_BAR_', 'RES_PIETAR_'};
|
||||
|
||||
rep.addTable('title', countryName, ...
|
||||
'range', trange, ...
|
||||
'vlineAfter', vline_after);
|
||||
|
||||
for i=1:length(seriesNames)
|
||||
if (any(strcmp(countryAbbr, otherThree)) && ...
|
||||
any(strcmp(seriesNames{i}{1}, notForOtherThree))) || ...
|
||||
(any(strcmp(countryAbbr, 'US')) && any(strcmp(seriesNames{i}{1}, notForUS))) || ...
|
||||
(any(strcmp(countryAbbr, firstThree)) && any(strcmp(seriesNames{i}{1}, notForFirstThree)))
|
||||
continue
|
||||
end
|
||||
rep.addSeries('data', db_q{[seriesNames{i}{1} countryAbbr]});
|
||||
delta = db_q{[seriesNames{i}{1} countryAbbr]}-dc_q{[seriesNames{i}{1} countryAbbr]};
|
||||
delta.tex_rename_('$\Delta$');
|
||||
rep.addSeries('data', delta, ...
|
||||
'tableShowMarkers', true, ...
|
||||
'tableAlignRight', true);
|
||||
end
|
||||
end
|
|
@ -0,0 +1,316 @@
|
|||
function createReport(dc_a, dc_q, db_a, db_q)
|
||||
%function createReport(dc_a, dc_q, db_a, db_q)
|
||||
%
|
||||
% Copyright © 2013-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
tic
|
||||
larange= dates('2007a'):dates('2014a');
|
||||
trange = dates('2012q2'):dates('2014q4');
|
||||
prange = dates('2007q1'):dates('2013q4');
|
||||
forecast_date = dates('2012q2');
|
||||
srange = forecast_date:prange(end);
|
||||
|
||||
startpoint = strings(prange(1));
|
||||
shaded = strings(srange(1));
|
||||
endpoint = strings(prange(end));
|
||||
|
||||
shortNames = {'US', 'EU', 'JA', 'EA6', 'LA6', 'RC6'};
|
||||
longNames = {'Coca Cola', 'Kinder Bueno', 'Pizza', ...
|
||||
'Vegetarianism Is Good', 'OS X', 'Dothraki'};
|
||||
|
||||
%% Begin Report
|
||||
rep = report('directory', 'my/report/dir', 'title', 'Report Title', ...
|
||||
'maketoc', true);
|
||||
|
||||
%% Page 1: GDP
|
||||
rep.addPage('title', 'Jan1 vs Jan2', ...
|
||||
'titleFormat', '\large\bfseries');
|
||||
rep.addSection();
|
||||
rep.addVspace();
|
||||
|
||||
% Table 1
|
||||
rep.addTable('title', {'Real GDP Growth','subtitle 1', 'subtitle 2'}, ...
|
||||
'range', larange, ...
|
||||
'vlineAfter', dates('2011y'), ...
|
||||
'highlightRows', {'gray!25','white','green!22'});
|
||||
rep = AnnualTable(rep, db_a, dc_a, 'PCH_GROWTH4_', larange);
|
||||
rep.addVspace('number', 2);
|
||||
|
||||
% Table 2
|
||||
rep.addTable('title', 'Potential GDP Growth', 'range', larange, ...
|
||||
'vlineAfter', dates('2011y'));
|
||||
rep = AnnualTable(rep, db_a, dc_a, 'PCH_GROWTH4_BAR_', larange);
|
||||
|
||||
|
||||
%% Page 2: Headline & Core Inflation
|
||||
rep.addPage('title', 'Jan1 vs Jan2', ...
|
||||
'titleFormat', '\large\bfseries');
|
||||
rep.addSection();
|
||||
rep.addVspace();
|
||||
|
||||
% Table 1
|
||||
rep.addTable('title', 'Headline CPI Inflation', 'range', larange, ...
|
||||
'vlineAfter', dates('2011y'));
|
||||
rep = AnnualTable(rep, db_a, dc_a, 'PCH_PIE4_', larange);
|
||||
rep.addVspace('number', 2);
|
||||
|
||||
% Table 2
|
||||
rep.addTable('title', 'Core CPI Inflation', 'range', larange, ...
|
||||
'vlineAfter', dates('2011y'));
|
||||
rep = AnnualTable(rep, db_a, dc_a, 'PCH_PIEX4_', larange);
|
||||
|
||||
|
||||
%% Page 3: Gas & Food Inflation
|
||||
rep.addPage('title', 'Jan1 vs Jan2', ...
|
||||
'titleFormat', '\large\bfseries');
|
||||
rep.addSection();
|
||||
rep.addVspace();
|
||||
|
||||
% Table 1
|
||||
rep.addTable('title', 'Gas Inflation', 'range', larange, ...
|
||||
'vlineAfter', dates('2011y'));
|
||||
rep = AnnualTable(rep, db_a, dc_a, 'PCH_PIE4_GAS_', larange);
|
||||
rep.addVspace('number', 2);
|
||||
|
||||
% Table 2
|
||||
rep.addTable('title', 'Food Inflation', 'range', larange, ...
|
||||
'vlineAfter', dates('2011y'));
|
||||
rep = AnnualTable(rep, db_a, dc_a, 'PCH_PIE4_CONSFOOD_', larange);
|
||||
|
||||
|
||||
%% Page 4: i & Output Gap
|
||||
rep.addPage('title', 'Jan1 vs Jan2', ...
|
||||
'titleFormat', '\large\bfseries');
|
||||
rep.addSection();
|
||||
rep.addVspace();
|
||||
|
||||
% Table 1
|
||||
rep.addTable('title', 'Nominal Interest Rate', 'range', larange, ...
|
||||
'vlineAfter', dates('2011y'));
|
||||
rep = AnnualTable(rep, db_a, dc_a, 'RS_', larange);
|
||||
rep.addVspace('number', 2);
|
||||
|
||||
% Table 2
|
||||
rep.addTable('title', 'Output Gap', 'range', larange, ...
|
||||
'vlineAfter', dates('2011y'), 'tableDirName', 'page4table2');
|
||||
db_a.tex_rename_('Y_WORLD', 'World');
|
||||
rep.addSeries('data', db_a{'Y_WORLD'});
|
||||
delta = db_a{'Y_WORLD'}-dc_a{'Y_WORLD'};
|
||||
delta.tex_rename_('$\Delta$');
|
||||
rep.addSeries('data', delta, ...
|
||||
'tableShowMarkers', true, ...
|
||||
'tableAlignRight', true);
|
||||
rep = AnnualTable(rep, db_a, dc_a, 'Y_', larange);
|
||||
|
||||
%% Country Pages
|
||||
for i=1:length(shortNames)
|
||||
rep.addPage('title', {'Jan1 vs Jan2', longNames{i}}, ...
|
||||
'titleFormat', {'\large\bfseries', '\large'});
|
||||
rep.addSection('cols', 5);
|
||||
rep = CountryGraphPage(rep, shortNames{i}, db_q, dc_q, prange, srange);
|
||||
|
||||
rep.addPage('title', 'Jan1 vs Jan2', ...
|
||||
'titleFormat', '\large\bfseries');
|
||||
rep.addSection();
|
||||
rep = CountryTablePage(rep, shortNames{i}, longNames{i}, db_q, dc_q, ...
|
||||
db_a, dc_a, trange, dates('2012q2'));
|
||||
end
|
||||
|
||||
%% Residual Reports
|
||||
% Countries
|
||||
for i=1:length(shortNames)
|
||||
rep.addPage('title', 'Residual Report Jan1 vs Jan2', ...
|
||||
'titleFormat', '\large\bfseries');
|
||||
rep.addSection();
|
||||
rep = ResidTablePage(rep, shortNames{i}, longNames{i}, db_q, dc_q, trange, dates('2012q2'));
|
||||
end
|
||||
|
||||
% Commodities
|
||||
rep.addPage('title', 'Residual Report Jan1 vs Jan2', ...
|
||||
'titleFormat', '\large\bfseries');
|
||||
rep.addSection();
|
||||
rep = CommResidTablePage(rep, db_q, dc_q, trange, dates('2012q2'));
|
||||
|
||||
%% Commodities Graphs
|
||||
%Page 24
|
||||
rep.addPage('title', 'Jan1 vs Jan2', ...
|
||||
'titleFormat', '\large\bfseries', ...
|
||||
'removeHeaderAndFooter', true);
|
||||
rep.addSection('height', '0.475\textheight');
|
||||
|
||||
rep.addGraph('title', {'World Real Oil Price Index','SUBTITLE'}, ...
|
||||
'xrange', prange, ...
|
||||
'shade', srange, ...
|
||||
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
|
||||
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
|
||||
'xTickLabelRotation', 0);
|
||||
rep.addSeries('data', db_q{'LRPFOOD_BAR_WORLD'}, ...
|
||||
'graphBar', true, ...
|
||||
'graphBarColor', 'red', ...
|
||||
'graphBarFillColor', 'gray', ...
|
||||
'graphBarWidth', 1);
|
||||
db_q.tex_rename_('LRPOIL_WORLD', 'Oil Price');
|
||||
rep.addSeries('data', db_q{'LRPOIL_WORLD'}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineWidth', 1.5, ...
|
||||
'graphMarker', 'triangle*', ...
|
||||
'graphMarkerEdgeColor','black', ...
|
||||
'graphMarkerSize',4);
|
||||
db_q.tex_rename_('LRPOIL_BAR_WORLD', 'Equilibrium Oil Price');
|
||||
rep.addSeries('data', db_q{'LRPOIL_BAR_WORLD'}, ...
|
||||
'graphLineColor', 'green', ...
|
||||
'graphLineStyle', 'solid', ...
|
||||
'graphLineWidth', 1.5);
|
||||
|
||||
rep.addGraph('title', 'World Real Food Price Index', ...
|
||||
'xrange', prange, ...
|
||||
'shade', srange, ...
|
||||
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
|
||||
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
|
||||
'xTickLabelRotation', 0, ...
|
||||
'showLegend', true, ...
|
||||
'legendAt', [.5,.5]);
|
||||
rep.addSeries('data', db_q{'LRPFOOD_BAR_WORLD'}, ...
|
||||
'graphBar', true, ...
|
||||
'graphBarColor', 'green', ...
|
||||
'graphBarFillColor', 'yellow', ...
|
||||
'graphBarWidth', 1);
|
||||
db_q.tex_rename_('LRPFOOD_WORLD', 'Food Price');
|
||||
rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineWidth', 1.5);
|
||||
db_q.tex_rename_('LRPFOOD_BAR_WORLD', 'Equilibrium Food Price');
|
||||
rep.addSeries('graphVline', dates('2009q2'), ...
|
||||
'graphLineColor', 'red', ...
|
||||
'graphLineWidth', 1.5);
|
||||
|
||||
% Page 25
|
||||
rep.addPage('title', {'Jan1 vs Jan2', 'World Oil and Food Prices'}, ...
|
||||
'titleFormat', {'\large\bfseries', '\large'}, ...
|
||||
'setPageNumber', 90);
|
||||
rep.addSection('cols', 1);
|
||||
rep.addParagraph('text', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', ...
|
||||
'cols', 2, ...
|
||||
'heading', '\textbf{My First Paragraph Has Two Columns}');
|
||||
|
||||
rep.addSection('cols', 1);
|
||||
rep.addParagraph('text', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\newline', ...
|
||||
'heading', '\textbf{My Next Paragraphs Only Have One}', ...
|
||||
'indent', false);
|
||||
rep.addParagraph('text', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\newline');
|
||||
|
||||
rep.addSection('cols', 2);
|
||||
|
||||
rep.addGraph('title', 'World Real Oil Price', ...
|
||||
'xrange', prange, ...
|
||||
'shade', srange, ...
|
||||
'xTicks', [1,5,10,15,find(srange(1)==prange),length(prange)], ...
|
||||
'xTickLabels',{startpoint{:},'2008Q1','2009Q2','2010Q3',shaded{:}, endpoint{:}},...
|
||||
'xTickLabelRotation', 0);
|
||||
rep.addSeries('data', db_q{'LRPOIL_WORLD'}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineWidth', 1.5);
|
||||
rep.addSeries('data', dc_q{'LRPOIL_WORLD'}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineStyle', 'dashed', ...
|
||||
'graphLineWidth', 1.5);
|
||||
|
||||
srange1 = prange(1):forecast_date;
|
||||
rep.addGraph('title', 'Equilibrium World Real Oil Price', ...
|
||||
'xrange', prange, ...
|
||||
'shade', srange1);
|
||||
rep.addSeries('data', db_q{'LRPOIL_BAR_WORLD'}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineWidth', 1.5);
|
||||
rep.addSeries('data', dc_q{'LRPOIL_BAR_WORLD'}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineStyle', 'dashed', ...
|
||||
'graphLineWidth', 1.5);
|
||||
|
||||
rep.addGraph('title', 'World Real Food Price', ...
|
||||
'xrange', prange, ...
|
||||
'shade', srange, ...
|
||||
'xTickLabels','ALL',...
|
||||
'xTickLabelRotation', 45,...
|
||||
'xAxisTight',false,...
|
||||
'yAxisTight',true);
|
||||
rep.addSeries('data', db_q{'LRPFOOD_WORLD'}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineWidth', 1.5);
|
||||
rep.addSeries('data', dc_q{'LRPFOOD_WORLD'}, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineStyle', 'dashed', ...
|
||||
'graphLineWidth', 1.5);
|
||||
rep.addSeries('graphHline', 460, ...
|
||||
'graphLineColor', 'red', ...
|
||||
'graphLineWidth', 1.5);
|
||||
|
||||
a=dseries([1:200]', '1984q1');
|
||||
b=dseries([1:200]', '1984q1');
|
||||
c=dseries([1:200]', '1984q1');
|
||||
d=dseries([1:200]', '1984q1');
|
||||
b(dates('2012q2'):dates('2015q2'))=b(dates('2012q2'):dates('2015q2'))+2;
|
||||
c(dates('2012q2'):dates('2015q2'))=c(dates('2012q2'):dates('2015q2'))+4;
|
||||
d(dates('2012q2'):dates('2015q2'))=d(dates('2012q2'):dates('2015q2'))+6;
|
||||
|
||||
rep.addGraph('title', 'Equilibrium World Real Food Price', ...
|
||||
'xrange', prange, ...
|
||||
'shade', srange, ...
|
||||
'showLegend', true, ...
|
||||
'xTickLabelRotation', 0);
|
||||
rep.addSeries('data', a, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineWidth', 1.5, ...
|
||||
'graphLegendName', 'baseline', ...
|
||||
'graphMiscTikzAddPlotOptions', 'mark=halfcircle*,color=red');
|
||||
rep.addSeries('data', b, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineStyle', 'dashed', ...
|
||||
'graphLineWidth', 1.5, ...
|
||||
'graphLegendName', 'control', ...
|
||||
'graphMiscTikzAddPlotOptions', 'mark=halfcircle*,mark options={rotate=90,scale=3}', ...
|
||||
'graphFanShadeColor', 'red', 'graphFanShadeOpacity', 40);
|
||||
rep.addSeries('data', c, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineStyle', 'dashed', ...
|
||||
'graphLineWidth', 1.5, ...
|
||||
'graphLegendName', 'control', ...
|
||||
'graphFanShadeColor', 'red', 'graphFanShadeOpacity', 30);
|
||||
rep.addSeries('data', d, ...
|
||||
'graphLineColor', 'blue', ...
|
||||
'graphLineStyle', 'dashed', ...
|
||||
'graphLineWidth', 1.5, ...
|
||||
'graphLegendName', 'control', ...
|
||||
'graphFanShadeColor', 'red', 'graphFanShadeOpacity', 20);
|
||||
|
||||
%% Page 26
|
||||
rep.addPage('title', {'report\_data test'}, ...
|
||||
'titleFormat', {'\large\bfseries', '\large'});
|
||||
rep.addSection('cols', 1);
|
||||
rep.addTable('title', {'Table Data 0', 'subtitle 2'});
|
||||
rep.addData('data', [repmat({'a'},10,1) num2cell(rand(10,6))]);
|
||||
rep.addVspace();
|
||||
rep.addSection('cols', 1);
|
||||
rep.addTable('title', {'Table Data 1', 'subtitle 3'});
|
||||
rep.addData('data', [repmat({'a'},10,1) repmat({'b'},10,1) num2cell(rand(10,1))], 'column_names', {'Name', '', 'Var2'});
|
||||
|
||||
%% Write & Compile Report
|
||||
rep.write();
|
||||
rep.compile();
|
||||
toc
|
||||
end
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,26 @@
|
|||
% Copyright © 2017-2019 Dynare Team
|
||||
%
|
||||
% 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
|
||||
% along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
initialize_dseries_class();
|
||||
initialize_reporting_toolbox();
|
||||
|
||||
db_a = dseries('db_a.csv');
|
||||
db_q = dseries('db_q.csv');
|
||||
dc_a = dseries('dc_a.csv');
|
||||
dc_q = dseries('dc_q.csv');
|
||||
|
||||
createReport(dc_a, dc_q, db_a, db_q);
|
Loading…
Reference in New Issue