Skip to content

Commit

Permalink
Replaces varargin in bayesShadedPlot with argument block (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenNneji authored Nov 15, 2024
1 parent fcc187d commit c944de7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 38 deletions.
Binary file modified examples/miscellaneous/roundRobin/roundRobin.mlx
Binary file not shown.
2 changes: 1 addition & 1 deletion examples/normalReflectivity/customXY/customXYDSPCScript.m
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
% ..and plot this out....

figure(30); clf;
bayesShadedPlot(problem, results,'KeepAxes',true,'interval',65,'q4',false)
bayesShadedPlot(problem, results,'keepAxes',true,'interval',65,'q4',false)

h3 = figure(40); clf
plotHists(results,h3,'smooth',true)
Expand Down
Binary file modified examples/normalReflectivity/customXY/customXYDSPCSheet.mlx
Binary file not shown.
48 changes: 12 additions & 36 deletions utilities/plotting/bayesShadedPlot.m
Original file line number Diff line number Diff line change
@@ -1,49 +1,25 @@
function bayesShadedPlot(problem,result,varargin)

function bayesShadedPlot(problem, result, options)
% Plot the shaded reflectivities from Bayes output
% from RAT
arguments
problem
result
options.q4 {logical} = false
options.keepAxes {logical} = false
options.interval {mustBeMember(options.interval, [65, 95])} = 95
end

if isa(problem,'domainsClass')
isDomains = true;
else
isDomains = false;
end

% Parse the input options
if ~isempty(varargin)

defaultq4 = false;
defaultKeep = false;
defaultInterval = 95;

allIntervals = [65 95];

p = inputParser;
addOptional(p, 'q4', defaultq4, @islogical);
addOptional(p, 'KeepAxes', defaultKeep, @islogical);
addOptional(p, 'interval', defaultInterval, @(x) ismember(x,allIntervals));

parse(p,varargin{:});
inputBlock = p.Results;

q4 = inputBlock.q4;
keepAx = inputBlock.KeepAxes;
interval = inputBlock.interval;

else

q4 = false;
keepAx = false;
interval = 95;

end


if ~keepAx
if ~options.keepAxes
clf; hold on; box on
end

switch interval
switch options.interval
case 95
vals = [1 5];
case 65
Expand Down Expand Up @@ -75,7 +51,7 @@ function bayesShadedPlot(problem,result,varargin)
reflectivity = bestReflectivity{i};

mult = 2^(4*i);
switch q4
switch options.q4
case true
thisQ4 = thisData(:,1).^4;
case false
Expand All @@ -99,7 +75,7 @@ function bayesShadedPlot(problem,result,varargin)
refXValues = result.reflectivity{i}(:,1);
thisSimQ4 = refXValues.^4;

switch q4
switch options.q4
case true
min = min .* thisSimQ4;
max = max .* thisSimQ4;
Expand Down
2 changes: 1 addition & 1 deletion utilities/plotting/plotBayes.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function plotBayes(problem, results)
figure(10); clf; plotRefSLD(problem,results)

figure(30); clf;
bayesShadedPlot(problem,results,'KeepAxes',true,'interval',95,'q4',false)
bayesShadedPlot(problem,results,'keepAxes',true,'interval',95,'q4',false)

h3 = figure(40); clf
plotHists(results,h3,'smooth',true)
Expand Down

0 comments on commit c944de7

Please sign in to comment.