Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Dóra Kocsis
dynare
Commits
0219301e
Commit
0219301e
authored
Feb 19, 2013
by
Houtan Bastani
Browse files
reporting (WIP)
parent
a64ec3b1
Changes
28
Hide whitespace changes
Inline
Side-by-side
matlab/
reports/addIndentation
.m
→
matlab/
@dynDates/getDatesCellStringArray
.m
View file @
0219301e
function
spaces
=
addIndentation
(
spaces
)
% Return new level of indentation for latex output
function
m
=
getDatesCellStringArray
(
dd
)
%function m = getDatesCellStringArray(dd)
% Returns a cell array of strings containing the dates
%
% INPUTS
%
spaces - char, current level of indentation
%
dd - dynDates object
%
% OUTPUTS
%
spaces - char, new level of indentation
%
m - cell array of strings
%
% SPECIAL REQUIREMENTS
% none
...
...
@@ -27,5 +28,26 @@ function spaces=addIndentation(spaces)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
spaces
=
[
spaces
' '
];
dateSep
=
''
;
switch
dd
.
freq
case
1
case
4
dateSep
=
'q'
;
case
12
dateSep
=
'm'
;
case
52
dateSep
=
'w'
;
otherwise
error
(
'Unknown frequency %d'
,
dd
.
freq
);
end
m
=
cell
(
0
);
for
i
=
1
:
dd
.
ndat
if
isempty
(
dateSep
)
newdate
=
num2str
(
dd
.
time
(
i
,
1
));
else
newdate
=
[
num2str
(
dd
.
time
(
i
,
1
))
dateSep
num2str
(
dd
.
time
(
i
,
2
))];
end
m
=
{
m
{:}
newdate
};
end
end
\ No newline at end of file
matlab/reports/@elements/addGraph.m
View file @
0219301e
...
...
@@ -18,10 +18,5 @@ function e = addGraph(e, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert
(
nargin
>=
1
&&
nargin
<=
3
)
if
nargin
==
1
e
.
objArray
=
e
.
objArray
.
addObj
(
graph
());
else
e
.
objArray
=
e
.
objArray
.
addObj
(
varargin
{:});
end
e
.
objArray
=
e
.
objArray
.
addObj
(
graph
(
varargin
{:}));
end
\ No newline at end of file
matlab/reports/@elements/addTable.m
View file @
0219301e
...
...
@@ -18,10 +18,5 @@ function e = addTable(e, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert
(
nargin
>=
1
&&
nargin
<=
3
)
if
nargin
==
1
e
.
objArray
=
e
.
objArray
.
addObj
(
table
());
else
e
.
objArray
=
e
.
objArray
.
addObj
(
varargin
{:});
end
e
.
objArray
=
e
.
objArray
.
addObj
(
table
(
varargin
{:}));
end
\ No newline at end of file
matlab/reports/@graph/createGraph.m
0 → 100644
View file @
0219301e
function
o
=
createGraph
(
o
)
%function o = createGraph(o)
% Create the graph
%
% INPUTS
% none
%
% OUTPUTS
% none
%
% SPECIAL REQUIREMENTS
% none
% Copyright (C) 2013 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 <http://www.gnu.org/licenses/>.
assert
(
~
isempty
(
o
.
data
));
assert
(
isa
(
o
.
data
,
'dynSeries'
))
;
if
~
isempty
(
o
.
figname
)
warning
(
'Will overwrite %s with new graph\n'
,
o
.
figname
);
end
%o = readConfig(o);
h
=
figure
(
'visible'
,
'off'
);
hold
on
;
box
on
;
%set(0, 'CurrentFigure',h);
%set(h, 'PaperPositionMode', 'auto');
%set(h, 'units', 'normalized', 'outerposition', [0 0 1 1]);
if
strcmpi
(
o
.
seriestoplot
,
'all'
)
data
=
o
.
data
.
data
;
else
data
=
o
.
data
{
o
.
seriestoplot
{:}}
.
data
;
end
x
=
[
1
:
1
:
o
.
data
.
nobs
];
xlabels
=
getDatesCellStringArray
(
o
.
data
.
time
);
plot
(
x
,
data
);
if
~
isempty
(
o
.
shade
)
x1
=
strmatch
(
lower
(
o
.
shade
{
1
}),
xlabels
,
'exact'
);
x2
=
strmatch
(
lower
(
o
.
shade
{
2
}),
xlabels
,
'exact'
);
yrange
=
get
(
gca
,
'YLim'
);
% From ShadePlotForEmpahsis (Matlab Exchange)
% use patch bc area doesn't work with matlab2tikz
patch
([
repmat
(
x1
,
1
,
2
)
repmat
(
x2
,
1
,
2
)],
[
yrange
fliplr
(
yrange
)],
...
'b'
,
'FaceAlpha'
,
.
2
);
end
set
(
gca
,
'XTick'
,
x
);
set
(
gca
,
'XTickLabel'
,
xlabels
);
if
o
.
legend
if
strcmpi
(
o
.
seriestoplot
,
'all'
)
lh
=
legend
(
o
.
data
.
name
);
else
lh
=
legend
(
o
.
seriestoplot
{:});
end
set
(
lh
,
'orientation'
,
o
.
legend_orientation
);
set
(
lh
,
'Location'
,
o
.
legend_location
);
set
(
lh
,
'FontSize'
,
o
.
legend_font_size
);
legend
(
'boxoff'
);
end
if
~
isempty
(
o
.
xlabel
)
xlabel
([
'$\textbf{\footnotesize '
o
.
xlabel
'}$'
],
'Interpreter'
,
'LaTex'
);
end
if
~
isempty
(
o
.
ylabel
)
ylabel
([
'$\textbf{\footnotesize '
o
.
ylabel
'}$'
],
'Interpreter'
,
'LaTex'
);
end
if
~
isempty
(
o
.
title
)
title
([
'$\textbf{\large '
o
.
title
'}$'
],
'Interpreter'
,
'LaTex'
);
end
drawnow
;
o
.
figname
=
[
'figure-'
num2str
(
cputime
)
'.tex'
];
matlab2tikz
(
'filename'
,
o
.
figname
,
...
'showInfo'
,
false
,
...
'showWarnings'
,
false
,
...
'checkForUpdates'
,
false
);
box
off
;
hold
off
;
close
(
h
);
clear
h
;
end
matlab/reports/@graph/display.m
View file @
0219301e
...
...
@@ -30,9 +30,19 @@ function display(o)
name
=
'report.page.section.graph'
;
disp
(
' '
);
disp
([
name
'.
caption
= '
]);
disp
([
name
'.
title
= '
]);
disp
(
' '
);
disp
([
'
''
'
o
.
caption
'
''
'
]);
disp
([
'
''
'
o
.
title
'
''
'
]);
disp
(
' '
);
disp
([
name
'.xlabel = '
]);
disp
(
' '
);
disp
([
'
''
'
o
.
xlabel
'
''
'
]);
disp
(
' '
);
disp
([
name
'.ylabel = '
]);
disp
(
' '
);
disp
([
'
''
'
o
.
ylabel
'
''
'
]);
disp
(
' '
);
disp
([
name
'.footnote = '
]);
...
...
@@ -40,7 +50,32 @@ disp(' ');
disp
([
'
''
'
o
.
footnote
'
''
'
]);
disp
(
' '
);
disp
([
name
'.filename = '
]);
disp
([
name
'.figname = '
]);
disp
(
' '
);
disp
([
'
''
'
o
.
figname
'
''
'
]);
disp
(
' '
);
disp
([
name
'.data = '
]);
disp
(
' '
);
display
(
o
.
data
);
disp
(
' '
);
disp
([
name
'.seriestoplot = '
]);
disp
(
' '
);
disp
(
o
.
seriestoplot
);
disp
(
' '
);
disp
([
name
'.config = '
]);
disp
(
' '
);
disp
([
'
''
'
o
.
config
'
''
'
]);
disp
(
' '
);
disp
([
name
'.legend = '
]);
disp
(
' '
);
disp
(
o
.
legend
);
disp
(
' '
);
disp
([
name
'.shade = '
]);
disp
(
' '
);
disp
(
[
'
''
'
o
.
filename
'
''
'
]
);
disp
(
o
.
shade
);
end
\ No newline at end of file
matlab/reports/@graph/graph.m
View file @
0219301e
...
...
@@ -30,11 +30,24 @@ function o = graph(varargin)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
o
=
struct
;
o
.
caption
=
''
;
o
.
config
=
''
;
o
.
title
=
''
;
o
.
ylabel
=
''
;
o
.
xlabel
=
''
;
o
.
zlabel
=
''
;
o
.
footnote
=
''
;
o
.
filename
=
''
;
o
.
figname
=
''
;
o
.
data
=
''
;
o
.
config
=
''
;
o
.
seriestoplot
=
'all'
;
o
.
shade
=
''
;
%{1959q1:1964q4}
o
.
legend
=
false
;
o
.
legend_location
=
'SouthEast'
;
o
.
legend_orientation
=
'horizontal'
;
o
.
legend_font_size
=
8
;
if
nargin
==
1
assert
(
isa
(
varargin
{
1
},
'graph'
),[
'With one arg to Graph constructor, '
...
...
...
matlab/reports/@graph/write.m
View file @
0219301e
function
write
(
o
,
fid
,
texIndent
)
%function write(o, fid)
% Write a
Page
object
function
o
=
write
(
o
,
fid
)
%function
o =
write(o, fid)
% Write a
Graph
object
%
% INPUTS
%
none
%
fid - int, file id
%
% OUTPUTS
%
none
%
o - this
%
% SPECIAL REQUIREMENTS
% none
...
...
@@ -28,13 +28,9 @@ function write(o, fid, texIndent)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert
(
fid
>
0
);
assert
(
isnumeric
(
texIndent
));
fprintf
(
fid
,
'%d\% Page Object\n'
,
texIndent
);
fprintf
(
fid
,
'%d\newpage\n'
,
texIndent
);
o
.
sections
.
write
(
fid
,
texIndent
+
2
);
fprintf
(
fid
,
'%d\% End Page Object\n'
,
texIndent
);
assert
(
fid
~=
-
1
);
if
isempty
(
o
.
figname
)
o
=
createGraph
(
o
);
end
fprintf
(
fid
,
'\\input{%s}'
,
o
.
figname
);
end
\ No newline at end of file
matlab/reports/@page/addSection.m
View file @
0219301e
...
...
@@ -30,10 +30,5 @@ function p = addSection(p, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert
(
isa
(
p
,
'page'
),
'First argument must be a page object'
);
if
nargin
==
1
p
.
sections
=
p
.
sections
.
addSection
();
elseif
nargin
==
2
||
nargin
==
3
p
.
sections
=
p
.
sections
.
addSection
(
varargin
{:});
end
p
.
sections
=
p
.
sections
.
addSection
(
varargin
{:});
end
matlab/reports/@page/page.m
View file @
0219301e
...
...
@@ -30,12 +30,13 @@ function o = page(varargin)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
o
=
struct
;
o
.
caption
=
''
;
o
.
orientation
=
'portrait'
;
o
.
paper
=
''
;
o
.
title
=
''
;
o
.
orientation
=
''
;
o
.
sections
=
sections
();
if
nargin
==
1
assert
(
isa
(
varargin
{
1
},
'page'
),[
'With one arg to Page constructor, '
...
assert
(
isa
(
varargin
{
1
},
'page'
),
[
'With one arg to Page constructor, '
...
'you must pass a page object'
]);
o
=
varargin
{
1
};
return
;
...
...
matlab/reports/@page/subsref.m
View file @
0219301e
...
...
@@ -23,13 +23,6 @@ switch S(1).type
switch
S
(
1
)
.
subs
case
fieldnames
(
A
)
A
=
A
.
(
S
(
1
)
.
subs
);
case
{
'write'
}
if
areParensNext
(
S
)
write
(
A
,
S
(
2
)
.
subs
{:})
S
=
shiftS
(
S
);
else
assert
(
false
);
end
case
methods
(
A
)
if
areParensNext
(
S
)
A
=
feval
(
S
(
1
)
.
subs
,
A
,
S
(
2
)
.
subs
{:});
...
...
matlab/reports/@page/write.m
View file @
0219301e
function
write
(
o
,
fid
,
indent
)
%function write(o, fid
, indent
)
function
o
=
write
(
o
,
fid
)
%function
o =
write(o, fid)
% Write a Page object
%
% INPUTS
% fid - int, file id
% indent - char, number of spaces to indent tex code
%
% OUTPUTS
%
none
%
o - this
%
% SPECIAL REQUIREMENTS
% none
...
...
@@ -31,14 +30,19 @@ function write(o, fid, indent)
assert
(
fid
~=
-
1
);
fprintf
(
fid
,
'\n%s%% Page Object\n'
,
indent
);
fprintf
(
fid
,
'\n%% Page Object\n'
);
if
~
isempty
(
o
.
title
)
fprintf
(
fid
,
'\\centerline{{\\Large %s}}\n'
,
o
.
title
);
end
if
strcmpi
(
o
.
orientation
,
'landscape'
)
fprintf
(
fid
,
'
%s
\\begin{landscape}\n'
,
indent
);
fprintf
(
fid
,
'\\begin{landscape}\n'
)
end
o
.
sections
.
write
(
fid
,
addIndentation
(
indent
));
o
.
sections
.
write
(
fid
);
if
strcmpi
(
o
.
orientation
,
'landscape'
)
fprintf
(
fid
,
'
%s
\\end{landscape}\n'
,
indent
);
fprintf
(
fid
,
'\\end{landscape}\n'
);
end
fprintf
(
fid
,
'
%s
\\clearpage\n'
,
indent
);
fprintf
(
fid
,
'%
s%
% End Page Object\n\n'
,
indent
);
fprintf
(
fid
,
'\\clearpage\n'
);
fprintf
(
fid
,
'%% End Page Object\n\n'
);
end
\ No newline at end of file
matlab/reports/@pages/addPage.m
View file @
0219301e
...
...
@@ -18,10 +18,11 @@ function ps = addPage(ps, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert
(
nargin
>=
1
&&
nargin
<=
3
)
if
nargin
==
1
ps
.
objArray
=
ps
.
objArray
.
addObj
(
page
());
else
ps
.
objArray
=
ps
.
objArray
.
addObj
(
varargin
{:});
end
ps
.
objArray
=
ps
.
objArray
.
addObj
(
page
(
varargin
{:}));
%assert(nargin >= 1 && nargin <= 3)
%if nargin == 1
% ps.objArray = ps.objArray.addObj(page());
%else
% ps.objArray = ps.objArray.addObj(varargin{:});
%end
end
\ No newline at end of file
matlab/reports/@pages/subsref.m
View file @
0219301e
...
...
@@ -23,13 +23,6 @@ switch S(1).type
switch
S
(
1
)
.
subs
case
fieldnames
(
A
)
A
=
A
.
(
S
(
1
)
.
subs
);
case
{
'write'
}
if
areParensNext
(
S
)
write
(
A
,
S
(
2
)
.
subs
{:})
S
=
shiftS
(
S
);
else
assert
(
false
);
end
case
methods
(
A
)
if
areParensNext
(
S
)
A
=
feval
(
S
(
1
)
.
subs
,
A
,
S
(
2
)
.
subs
{:});
...
...
matlab/reports/@pages/write.m
View file @
0219301e
function
write
(
o
,
fid
,
indent
)
%function write(o, fid
, indent
)
function
o
=
write
(
o
,
fid
)
%function
o =
write(o, fid)
% Write Pages object
%
% INPUTS
% fid - int, file id
% indent - char, number of spaces to indent tex code
%
% OUTPUTS
%
none
%
o - this
%
% SPECIAL REQUIREMENTS
% none
...
...
@@ -30,10 +29,10 @@ function write(o, fid, indent)
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert
(
fid
~=
-
1
);
fprintf
(
fid
,
'\n%
s%
% Pages Object\n'
,
indent
);
fprintf
(
fid
,
'\n%% Pages Object\n'
);
nps
=
numPages
(
o
);
for
i
=
1
:
nps
o
.
objArray
(
i
)
.
write
(
fid
,
addIndentation
(
indent
)
);
o
.
objArray
(
i
)
.
write
(
fid
);
end
fprintf
(
fid
,
'%
s%
% End Pages Object\n\n'
,
indent
);
fprintf
(
fid
,
'%% End Pages Object\n\n'
);
end
\ No newline at end of file
matlab/reports/@report/addPage.m
View file @
0219301e
function
r
=
addPage
(
r
,
varargin
)
%function
r
= addPage(
r
, varargin)
function
o
=
addPage
(
o
,
varargin
)
%function
o
= addPage(
o
, varargin)
% Add a page to the Cell Array of pages in the report
%
% INPUTS
...
...
@@ -30,21 +30,22 @@ function r = addPage(r, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert
(
nargin
>=
1
&&
nargin
<=
3
,
[
'incorrect number of arguments passed '
...
'to addPage'
]);
assert
(
isa
(
r
,
'report'
),
'First argument must be a report object'
);
if
nargin
>
1
assert
(
isa
(
varargin
{
1
},
'page'
),
[
'Optional 2nd arg to addPage must be a '
...
'Page'
]);
if
nargin
>
2
assert
(
isnumeric
(
varargin
{
2
}),
[
'Optional 3rd arg to addPage must be '
...
'an index'
]);
end
end
%
assert(nargin >= 1 && nargin <= 3, ['incorrect number of arguments passed ' ...
%
'to addPage']);
%
assert(isa(r, 'report'), 'First argument must be a report object');
%
if nargin > 1
%
assert(isa(varargin{1},'page'), ['Optional 2nd arg to addPage must be a ' ...
%
'Page']);
%
if nargin > 2
%
assert(isnumeric(varargin{2}), ['Optional 3rd arg to addPage must be ' ...
%
'an index']);
%
end
%
end
if
nargin
==
1
r
.
pages
=
r
.
pages
.
addPage
();
elseif
nargin
==
2
||
nargin
==
3
r
.
pages
=
r
.
pages
.
addPage
(
varargin
{:});
o
.
pages
=
o
.
pages
.
addPage
(
'orientation'
,
o
.
orientation
,
'paper'
,
o
.
paper
);
else
o
.
pages
=
o
.
pages
.
addPage
(
'orientation'
,
o
.
orientation
,
'paper'
,
...
o
.
paper
,
varargin
{:});
end
end
matlab/reports/@report/report.m
View file @
0219301e
...
...
@@ -34,6 +34,7 @@ o = struct;
o
.
title
=
''
;
o
.
orientation
=
'portrait'
;
o
.
paper
=
'a4'
;
o
.
margin
=
'2cm'
;
o
.
pages
=
pages
();
o
.
filename
=
'report.tex'
;
o
.
config
=
''
;
...
...
matlab/reports/@report/subsref.m
View file @
0219301e
...
...
@@ -23,13 +23,6 @@ switch S(1).type
switch
S
(
1
)
.
subs
case
fieldnames
(
A
)
A
=
A
.
(
S
(
1
)
.
subs
);
case
{
'write'
}
if
areParensNext
(
S
)
write
(
A
,
S
(
2
)
.
subs
{:})
S
=
shiftS
(
S
);
else
write
(
A
);
end
case
methods
(
A
)
if
areParensNext
(
S
)
A
=
feval
(
S
(
1
)
.
subs
,
A
,
S
(
2
)
.
subs
{:});
...
...
matlab/reports/@report/write.m
View file @
0219301e
function
write
(
o
)
%function write(o)
function
o
=
write
(
o
)
%function
o =
write(o)
% Write Report object
%
% INPUTS
%
none
%
o - Report Object
%
% OUTPUTS
%
none
%
o - Report Object
%
% SPECIAL REQUIREMENTS
% none
...
...
@@ -36,16 +36,18 @@ end
fprintf
(
fid
,
'%% Report Object\n'
);
fprintf
(
fid
,
'\\documentclass[11pt]{article}\n'
);
fprintf
(
fid
,
'\\usepackage[%spaper,margin=
2.5cm
'
,
o
.
paper
);
fprintf
(
fid
,
'\\usepackage[%spaper,margin=
%s
'
,
o
.
paper
,
o
.
margin
);
if
strcmpi
(
o
.
orientation
,
'landscape'
)
fprintf
(
fid
,
',landscape'
);
end
fprintf
(
fid
,
']{geometry}\n'
);
fprintf
(
fid
,
'\\usepackage{graphicx}\n'
);
fprintf
(
fid
,
'\\usepackage{pdflscape}\n'
)
fprintf
(
fid
,
'\\usepackage{pdflscape}\n'
);
fprintf
(
fid
,
'\\usepackage{pgf}\n'
);
fprintf
(
fid
,
'\\usepackage{pgfplots}\n'
);
fprintf
(
fid
,
'\\begin{document}\n'
);
o
.
pages
.
write
(
fid
,
addIndentation
(
''
)
);
o
.
pages
.
write
(
fid
);
fprintf
(
fid
,
'\\end{document}\n'
);
fprintf
(
fid
,
'%% End Report Object\n'
);
...
...
matlab/reports/@section/addGraph.m
View file @
0219301e
...
...
@@ -30,10 +30,5 @@ function o = addGraph(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert
(
isa
(
o
,
'section'
),
'First argument must be a section object'
);
if
nargin
==
1
o
.
elements
=
o
.
elements
.
addGraph
();
elseif
nargin
==
2
||
nargin
==
3
o
.
elements
=
o
.
elements
.
addGraph
(
varargin
{:});
end
o
.
elements
=
o
.
elements
.
addGraph
(
varargin
{:});
end
matlab/reports/@section/addTable.m
View file @
0219301e
...
...
@@ -30,10 +30,5 @@ function o = addTable(o, varargin)
% You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <http://www.gnu.org/licenses/>.
assert
(
isa
(
o
,
'section'
),
'First argument must be a section object'
);
if
nargin
==
1
o
.
elements
=
o
.
elements
.
addTable
();
elseif
nargin
==
2
||
nargin
==
3
o
.
elements
=
o
.
elements
.
addTable
(
varargin
{:});
end
o
.
elements
=
o
.
elements
.
addTable
(
varargin
{:});
end
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment