Fixed plot_contribution routine.

time-shift
Stéphane Adjemian (Charybdis) 2019-05-14 22:12:27 +02:00
parent 0d85e08292
commit 75945a62ac
5 changed files with 27 additions and 18 deletions

View File

@ -1,14 +1,15 @@
function ast = get_ast(eqtags)
%function ast = get_ast(eqtags)
% return the Abstract Syntax Tree the JSON output of preprocessor for the
function [ast, jsonmodel] = get_ast(eqtags)
% Returns the Abstract Syntax Tree the JSON output of preprocessor for the
% given equation tags. Equations are ordered in eqtag order
%
% INPUTS
% eqtags [cellstr] names of equation tags for which to get info.
% - eqtags [cellstr] names of equation tags for which to get info.
% If empty, get all equations
%
% OUTPUTS
% ast [cell array] JSON representation of the abstract syntax tree
% - ast [cell array] JSON representation of the abstract syntax tree
% - jsonmodel [cell array] JSON representation of the equations.
%
% SPECIAL REQUIREMENTS
% none
@ -33,19 +34,25 @@ function ast = get_ast(eqtags)
global M_
if ~isempty(eqtags) && ~(ischar(eqtags) || iscell(eqtags))
error('get_ast_jsonmodel: eqtags not passed correctly')
error('eqtags not passed correctly')
end
jsonfile = [M_.fname filesep() 'model' filesep() 'json' filesep() 'modfile-original.json'];
if exist(jsonfile, 'file') ~= 2
error(['Could not find ' jsonfile '! ' ...
'Please use the json=compute option ' ...
'(See the Dynare invocation section in the reference manual).']);
jsonfile = sprintf('%s%smodel%sjson%smodfile-original.json', M_.fname, filesep(), filesep(), filesep());
if ~exist(jsonfile, 'file')
error('Could not find %s! Please use the json=compute option (see the Dynare invocation section in the reference manual).', jsonfile)
end
tmp = loadjson(jsonfile);
ast = tmp.abstract_syntax_tree;
if nargout>1
jsonmodel = tmp.model;
end
ast = loadjson(jsonfile);
ast = ast.abstract_syntax_tree;
if ~isempty(eqtags)
ast = getEquationsByTags(ast, 'name', eqtags);
end
end
if nargout>1
jsonmodel = getEquationsByTags(jsonmodel, 'name', eqtags);
end
end

View File

@ -98,7 +98,7 @@ else
end
% Get equation.
[~, jsonmodel] = get_ast_jsonmodel(eqtags);
[~, jsonmodel] = get_ast(equationname);
lhs = jsonmodel{1}.lhs;
rhs = jsonmodel{1}.rhs;

View File

@ -455,6 +455,8 @@ ECB_MODFILES = \
ecb/backward-models/irf/solow_2.mod \
ecb/cherrypick/test1.mod \
ecb/cherrypick/test2.mod \
ecb/contribution-plots/contrib1.mod \
ecb/contribution-plots/contrib2.mod \
dynare-command-options/ramst.mod
OLS_MODFILES = \

View File

@ -1,4 +1,4 @@
// --+ options: json=compute +--
// --+ options: json=compute nostrict +--
/* REMARK
** ------

View File

@ -1,4 +1,4 @@
// --+ options: json=compute +--
// --+ options: json=compute nostrict +--
/* REMARKS
** -------