Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates Examples #262

Merged
merged 3 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified examples/domains/customLayers/domainsCustomLayerSheet.mlx
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why this file is changed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a stray space . . .

Alright, I'm a bit obsessive.
image
image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to revisit the possibility of linting and formatting the code. And maybe an issue to address some of the minor linter things such as replacing dlmread usage with readmatrix

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I looked into that. The use of ".layers" as a file format meant I couldn't do the simple switch, so I decided to leave it for now.

Binary file not shown.
Binary file not shown.
Binary file modified examples/miscellaneous/roundRobin/roundRobin.mlx
Binary file not shown.
Binary file modified examples/normalReflectivity/customLayers/customLayersDSPCSheet.mlx
Binary file not shown.
Binary file modified examples/normalReflectivity/customXY/customXYDSPCSheet.mlx
Binary file not shown.
30 changes: 0 additions & 30 deletions examples/validation/ORSO/orsoTest0.m

This file was deleted.

31 changes: 0 additions & 31 deletions examples/validation/ORSO/orsoTest1.m

This file was deleted.

37 changes: 0 additions & 37 deletions examples/validation/ORSO/orsoTest2.m

This file was deleted.

30 changes: 0 additions & 30 deletions examples/validation/ORSO/orsoTest3.m

This file was deleted.

31 changes: 0 additions & 31 deletions examples/validation/ORSO/orsoTest6.m

This file was deleted.

30 changes: 0 additions & 30 deletions examples/validation/ORSO/orsoTest7.m

This file was deleted.

18 changes: 0 additions & 18 deletions examples/validation/ORSO/validateMain.m

This file was deleted.

16 changes: 0 additions & 16 deletions examples/validation/README.md

This file was deleted.

Binary file removed examples/validation/bayes/bayesBenchmark.mlx
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function out = orsoTest3()
function out = orsoTest4()
% ORSO validation Test4 - Reflectivity plus resolution...

layers = dlmread('test0.layers');
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000
0.0000 6.3600 0.0000 3.0000
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
61 changes: 61 additions & 0 deletions tests/ORSO/testORSOValidation.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
classdef testORSOValidation < matlab.unittest.TestCase
%%
% Runs ORSO Validations.
% (For now, we exclude test 4 and test 5, as these test resolution
% functions which will diverge until phase 2 of the resolution calculations
% is implemented)

properties
orsoTolerance = 1.0e-10;
end

properties (TestParameter)
layersFile = {'test0.layers', 'test1.layers', 'test2.layers', 'test3.layers', 'test6.layers', 'test7.layers'}
dataFile = {'test0.dat', 'test1.dat', 'test2.dat', 'test3.dat', 'test6.dat', 'test7.dat'}
% layersFile = {'test0.layers', 'test1.layers', 'test2.layers', 'test3.layers', 'test0.layers', 'test1.layers', 'test6.layers', 'test7.layers'}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why the comments are here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to make sure the correspondence between dat files and layers files was noted down in the main test. For the excluded tests they use previous layers files.

% dataFile = {'test0.dat', 'test1.dat', 'test2.dat', 'test3.dat', 'test4.dat', 'test5.dat', 'test6.dat', 'test7.dat'}
end

methods (Test, ParameterCombination='sequential')

function testORSO(testCase, layersFile, dataFile)
testCase.verifyLessThanOrEqual(testORSOValidation.orsoTest(layersFile, dataFile), testCase.orsoTolerance, 'ORSO test has failed');
end

end

methods (Static)

function out = orsoTest(layersFile, dataFile)

layers = dlmread(layersFile);

% Change the units to Å
layers(:,2) = layers(:,2) .* 1e-6;
layers(:,3) = layers(:,3) .* 1e-6;

% Read in the data.....
data = dlmread(dataFile);

% Group the Layers
thick = layers(:,1);
sld = complex(layers(:,2),layers(:,3));
rough = layers(:,4);

% Calculate reflectivity...
q = data(:,1);
N = size(layers,1);
ref = abelesSingle(q,N,thick,sld,rough);

% Plot the comparison....
figure(1); clf
semilogy(q,ref,'k-','LineWidth',2)
hold on
plot(data(:,1),data(:,2),'r.')

% Calculate the output....
out = sum(sum((data(:,2) - ref).^2));

end
end
end
9 changes: 5 additions & 4 deletions tests/testExamples.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@
['domains' filesep 'customLayers'],...
['domains' filesep 'customXY'],...
['miscellaneous' filesep 'absorption'],...
['miscellaneous' filesep 'bayesBenchmark'],...
['miscellaneous' filesep 'roundRobin'],...
['miscellaneous' filesep 'convertRasCAL1Project']};
exampleLiveScriptFile = {'domainsStandardLayersSheet', 'domainsCustomLayerSheet',...
'domainsCustomXYSheet', 'convertRascal'}
% exampleLiveScriptFile = {'domainsStandardLayersSheet', 'domainsCustomLayerSheet', 'domainsCustomXYSheet',...
% 'customLayersDSPCSheet', 'standardLayersDSPCSheet', 'customXYDSPCSheet',...
% 'roundRobin', 'convertRascal'}
'domainsCustomXYSheet', 'bayesBenchmark', 'convertRascal'}
% exampleLiveScriptFile = {'domainsStandardLayersSheet', 'domainsCustomLayerSheet', 'domainsCustomXYSheet',...
% 'customLayersDSPCSheet', 'standardLayersDSPCSheet', 'customXYDSPCSheet',...
% 'roundRobin', 'bayesBenchmark', 'convertRascal'}
exampleScriptFile = {'standardLayersDSPCScript',...
'customLayersDSPCScript',...
'orsoCustomXYDSPC',...
Expand Down