-
Notifications
You must be signed in to change notification settings - Fork 5
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
Updates Examples #262
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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 |
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'} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure why the comments are here There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 withreadmatrix
There was a problem hiding this comment.
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.