Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
aebe6ac3
"ReadMe.md" did not exist on "2ef643132cc85728af59ce3b8effc9f890468aea"
Commit
aebe6ac3
authored
9 years ago
by
Simon Heybrock
Browse files
Options
Downloads
Patches
Plain Diff
Re #13236 Added test that exposes the WedgeOffset bug in Q1DWeigthed.
parent
cccb5d7a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/Mantid/Framework/Algorithms/test/Q1DWeightedTest.h
+106
-0
106 additions, 0 deletions
Code/Mantid/Framework/Algorithms/test/Q1DWeightedTest.h
with
106 additions
and
0 deletions
Code/Mantid/Framework/Algorithms/test/Q1DWeightedTest.h
+
106
−
0
View file @
aebe6ac3
...
...
@@ -92,6 +92,112 @@ public:
}
// Test whether the WedgeOffset parameter works correctly.
void
testWedgeOffset
()
{
// Setup is copied from testExec().
Mantid
::
DataHandling
::
LoadSpice2D
loader
;
loader
.
initialize
();
loader
.
setPropertyValue
(
"Filename"
,
"BioSANS_exp61_scan0004_0001.xml"
);
const
std
::
string
inputWS
(
"wav"
);
loader
.
setPropertyValue
(
"OutputWorkspace"
,
inputWS
);
loader
.
execute
();
// Move detector to its correct position
Mantid
::
DataHandling
::
MoveInstrumentComponent
mover
;
mover
.
initialize
();
mover
.
setPropertyValue
(
"Workspace"
,
inputWS
);
mover
.
setPropertyValue
(
"ComponentName"
,
"detector1"
);
// According to the instrument geometry, the center of the detector is
// located at N_pixel / 2 + 0.5
// X = (16-192.0/2.0+0.5)*5.15/1000.0 = -0.409425
// Y = (95-192.0/2.0+0.5)*5.15/1000.0 = -0.002575
mover
.
setPropertyValue
(
"X"
,
"0.409425"
);
mover
.
setPropertyValue
(
"Y"
,
"0.002575"
);
mover
.
execute
();
const
std
::
string
outputWS
(
"result"
);
const
std
::
string
wedgeWS1
(
"wedge1"
);
const
std
::
string
wedgeWS2
(
"wedge2"
);
// Test method:
// We use two wedges, which implies that they have an offset of 90 degree.
// We then call the algorithm twice, once with offset 0, once with offset
// 90. With offset 90 the wedges are thus logically "swapped", so we check
// if their values match.
if
(
!
radial_average
.
isInitialized
())
radial_average
.
initialize
();
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"InputWorkspace"
,
inputWS
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"OutputWorkspace"
,
outputWS
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"OutputBinning"
,
"0.01,0.001,0.11"
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"NPixelDivision"
,
"3"
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"ErrorWeighting"
,
"1"
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"WedgeWorkspace"
,
wedgeWS1
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"NumberOfWedges"
,
"2"
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"WedgeAngle"
,
"30"
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"WedgeOffset"
,
"0"
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
execute
())
TS_ASSERT
(
radial_average
.
isExecuted
())
if
(
!
radial_average
.
isInitialized
())
radial_average
.
initialize
();
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"InputWorkspace"
,
inputWS
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"OutputWorkspace"
,
outputWS
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"OutputBinning"
,
"0.01,0.001,0.11"
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"NPixelDivision"
,
"3"
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"ErrorWeighting"
,
"1"
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"WedgeWorkspace"
,
wedgeWS2
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"NumberOfWedges"
,
"2"
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"WedgeAngle"
,
"30"
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
setPropertyValue
(
"WedgeOffset"
,
"90"
))
TS_ASSERT_THROWS_NOTHING
(
radial_average
.
execute
())
TS_ASSERT
(
radial_average
.
isExecuted
())
// Get wedge 0 of the result with offset 0.
auto
result1
=
boost
::
dynamic_pointer_cast
<
Mantid
::
API
::
WorkspaceGroup
>
(
Mantid
::
API
::
AnalysisDataService
::
Instance
().
retrieve
(
wedgeWS1
));
auto
wedge1
=
boost
::
dynamic_pointer_cast
<
Mantid
::
API
::
MatrixWorkspace
>
(
result1
->
getItem
(
0
));
// Get wedge 1 of the result with offset 90.
auto
result2
=
boost
::
dynamic_pointer_cast
<
Mantid
::
API
::
WorkspaceGroup
>
(
Mantid
::
API
::
AnalysisDataService
::
Instance
().
retrieve
(
wedgeWS2
));
auto
wedge2
=
boost
::
dynamic_pointer_cast
<
Mantid
::
API
::
MatrixWorkspace
>
(
result2
->
getItem
(
1
));
double
tolerance
=
1e-12
;
// The two wedges shold be identical.
for
(
size_t
i
=
0
;
i
<
wedge1
->
dataY
(
0
).
size
();
++
i
)
TS_ASSERT_DELTA
(
wedge1
->
dataY
(
0
)[
i
],
wedge2
->
dataY
(
0
)[
i
],
tolerance
);
Mantid
::
API
::
AnalysisDataService
::
Instance
().
remove
(
inputWS
);
Mantid
::
API
::
AnalysisDataService
::
Instance
().
remove
(
outputWS
);
Mantid
::
API
::
AnalysisDataService
::
Instance
().
remove
(
wedgeWS1
);
Mantid
::
API
::
AnalysisDataService
::
Instance
().
remove
(
wedgeWS2
);
}
private
:
Mantid
::
Algorithms
::
Q1DWeighted
radial_average
;
std
::
string
inputWS
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment