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
d8f34c91
Commit
d8f34c91
authored
9 years ago
by
NickDraper
Browse files
Options
Downloads
Plain Diff
Merge pull request #733 from mantidproject/11714_cutmd_rlu
refs #11714. Introduce correct scaling.
parents
1501dd9a
454fbae6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h
+7
-2
7 additions, 2 deletions
...tid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h
Code/Mantid/Framework/MDAlgorithms/src/CutMD.cpp
+73
-5
73 additions, 5 deletions
Code/Mantid/Framework/MDAlgorithms/src/CutMD.cpp
with
80 additions
and
7 deletions
Code/Mantid/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h
+
7
−
2
View file @
d8f34c91
...
@@ -48,8 +48,13 @@ public:
...
@@ -48,8 +48,13 @@ public:
virtual
void
init
();
virtual
void
init
();
virtual
void
exec
();
virtual
void
exec
();
private
:
static
const
std
::
string
InvAngstromSymbol
;
static
const
std
::
string
RLUSymbol
;
static
const
std
::
string
AutoMethod
;
static
const
std
::
string
RLUMethod
;
static
const
std
::
string
InvAngstromMethod
;
};
};
}
// namespace MDAlgorithms
}
// namespace MDAlgorithms
...
...
This diff is collapsed.
Click to expand it.
Code/Mantid/Framework/MDAlgorithms/src/CutMD.cpp
+
73
−
5
View file @
d8f34c91
...
@@ -4,9 +4,15 @@
...
@@ -4,9 +4,15 @@
#include
"MantidAPI/Projection.h"
#include
"MantidAPI/Projection.h"
#include
"MantidGeometry/Crystal/OrientedLattice.h"
#include
"MantidGeometry/Crystal/OrientedLattice.h"
#include
"MantidKernel/ArrayProperty.h"
#include
"MantidKernel/ArrayProperty.h"
#include
"MantidKernel/ListValidator.h"
#include
"MantidKernel/Matrix.h"
#include
"MantidKernel/Matrix.h"
#include
"MantidKernel/System.h"
#include
"MantidKernel/System.h"
#include
<boost/make_shared.hpp>
#include
<boost/regex.hpp>
#include
<boost/algorithm/string.hpp>
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
API
;
using
namespace
Mantid
::
Geometry
;
using
namespace
Mantid
::
Geometry
;
using
namespace
Mantid
::
Kernel
;
using
namespace
Mantid
::
Kernel
;
...
@@ -47,7 +53,7 @@ DblMatrix scaleProjection(const DblMatrix &inMatrix,
...
@@ -47,7 +53,7 @@ DblMatrix scaleProjection(const DblMatrix &inMatrix,
orientedLattice
.
dstar
(
inMatrix
[
i
][
0
],
inMatrix
[
i
][
1
],
inMatrix
[
i
][
2
]);
orientedLattice
.
dstar
(
inMatrix
[
i
][
0
],
inMatrix
[
i
][
1
],
inMatrix
[
i
][
2
]);
if
(
inUnits
[
i
]
==
outUnits
[
i
])
if
(
inUnits
[
i
]
==
outUnits
[
i
])
continue
;
continue
;
else
if
(
inUnits
[
i
]
==
"a"
)
{
else
if
(
inUnits
[
i
]
==
Mantid
::
MDAlgorithms
::
CutMD
::
InvAngstromSymbol
)
{
// inv angstroms to rlu
// inv angstroms to rlu
for
(
size_t
j
=
0
;
j
<
numDims
;
++
j
)
for
(
size_t
j
=
0
;
j
<
numDims
;
++
j
)
ret
[
i
][
j
]
*=
dStar
;
ret
[
i
][
j
]
*=
dStar
;
...
@@ -178,6 +184,34 @@ std::vector<std::string> labelProjection(const DblMatrix &projection) {
...
@@ -178,6 +184,34 @@ std::vector<std::string> labelProjection(const DblMatrix &projection) {
}
}
return
ret
;
return
ret
;
}
}
/**
Determine the original q units. Assumes first 3 dimensions by index are r,l,d
@param inws : Input workspace to extract dimension info from
@param logger : logging object
@return vector of markers
*/
std
::
vector
<
std
::
string
>
findOriginalQUnits
(
IMDWorkspace
const
*
const
inws
,
Mantid
::
Kernel
::
Logger
&
logger
)
{
std
::
vector
<
std
::
string
>
unitMarkers
(
3
);
for
(
size_t
i
=
0
;
i
<
inws
->
getNumDims
()
&&
i
<
3
;
++
i
)
{
auto
units
=
inws
->
getDimension
(
i
)
->
getUnits
();
const
boost
::
regex
re
(
"A
\\
^-1"
,
boost
::
regex
::
icase
);
// Does the unit label look like it's in Angstroms?
std
::
string
unitMarker
;
if
(
boost
::
regex_match
(
units
.
ascii
(),
re
))
{
unitMarker
=
Mantid
::
MDAlgorithms
::
CutMD
::
InvAngstromSymbol
;
}
else
{
unitMarker
=
Mantid
::
MDAlgorithms
::
CutMD
::
RLUSymbol
;
}
unitMarkers
[
i
]
=
unitMarker
;
logger
.
debug
()
<<
"In dimension with index "
<<
i
<<
" and units "
<<
units
.
ascii
()
<<
" taken to be of type "
<<
unitMarker
<<
std
::
endl
;
}
return
unitMarkers
;
}
}
// anonymous namespace
}
// anonymous namespace
namespace
Mantid
{
namespace
Mantid
{
...
@@ -186,6 +220,12 @@ namespace MDAlgorithms {
...
@@ -186,6 +220,12 @@ namespace MDAlgorithms {
// Register the algorithm into the AlgorithmFactory
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM
(
CutMD
)
DECLARE_ALGORITHM
(
CutMD
)
const
std
::
string
CutMD
::
InvAngstromSymbol
=
"a"
;
const
std
::
string
CutMD
::
RLUSymbol
=
"r"
;
const
std
::
string
CutMD
::
AutoMethod
=
"Auto"
;
const
std
::
string
CutMD
::
RLUMethod
=
"RLU"
;
const
std
::
string
CutMD
::
InvAngstromMethod
=
"Q in A^-1"
;
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
/** Constructor
/** Constructor
*/
*/
...
@@ -221,6 +261,23 @@ void CutMD::init() {
...
@@ -221,6 +261,23 @@ void CutMD::init() {
"as output. True to create an "
"as output. True to create an "
"MDHistoWorkspace as output. This is DND "
"MDHistoWorkspace as output. This is DND "
"only in Horace terminology."
);
"only in Horace terminology."
);
std
::
vector
<
std
::
string
>
propOptions
;
propOptions
.
push_back
(
AutoMethod
);
propOptions
.
push_back
(
RLUMethod
);
propOptions
.
push_back
(
InvAngstromMethod
);
char
buffer
[
1024
];
std
::
sprintf
(
buffer
,
"How will the Q units of the input workspace be interpreted? This property will disappear in future versions of Mantid
\n
"
"%s : Figure it out based on the label units
\n
"
"%s : Force them to be rlu
\n
"
"%s : Force them to be inverse angstroms"
,
AutoMethod
.
c_str
(),
RLUMethod
.
c_str
(),
InvAngstromMethod
.
c_str
());
std
::
string
help
(
buffer
);
boost
::
algorithm
::
trim
(
help
);
declareProperty
(
"InterpretQDimensionUnits"
,
AutoMethod
,
boost
::
make_shared
<
StringListValidator
>
(
propOptions
),
help
);
}
}
void
CutMD
::
exec
()
{
void
CutMD
::
exec
()
{
...
@@ -293,8 +350,18 @@ void CutMD::exec() {
...
@@ -293,8 +350,18 @@ void CutMD::exec() {
std
::
vector
<
std
::
string
>
targetUnits
(
3
);
std
::
vector
<
std
::
string
>
targetUnits
(
3
);
for
(
size_t
i
=
0
;
i
<
3
;
++
i
)
for
(
size_t
i
=
0
;
i
<
3
;
++
i
)
targetUnits
[
i
]
=
projection
.
getUnit
(
i
)
==
RLU
?
"r"
:
"a"
;
targetUnits
[
i
]
=
std
::
vector
<
std
::
string
>
originUnits
(
3
,
"r"
);
// TODO. This is a hack!
projection
.
getUnit
(
i
)
==
RLU
?
RLUSymbol
:
InvAngstromSymbol
;
const
std
::
string
determineUnitsMethod
=
this
->
getProperty
(
"InterpretQDimensionUnits"
);
std
::
vector
<
std
::
string
>
originUnits
;
if
(
determineUnitsMethod
==
AutoMethod
)
{
originUnits
=
findOriginalQUnits
(
inWS
.
get
(),
g_log
);
}
else
if
(
determineUnitsMethod
==
RLUMethod
)
{
originUnits
=
std
::
vector
<
std
::
string
>
(
3
,
RLUSymbol
);
}
else
{
originUnits
=
std
::
vector
<
std
::
string
>
(
3
,
InvAngstromSymbol
);
}
DblMatrix
scaledProjectionMatrix
=
DblMatrix
scaledProjectionMatrix
=
scaleProjection
(
projectionMatrix
,
originUnits
,
targetUnits
,
eventInWS
);
scaleProjection
(
projectionMatrix
,
originUnits
,
targetUnits
,
eventInWS
);
...
@@ -333,7 +400,7 @@ void CutMD::exec() {
...
@@ -333,7 +400,7 @@ void CutMD::exec() {
}
}
// Make labels
// Make labels
std
::
vector
<
std
::
string
>
labels
=
labelProjection
(
p
rojectionMatrix
);
std
::
vector
<
std
::
string
>
labels
=
labelProjection
(
scaledP
rojectionMatrix
);
// Either run RebinMD or SliceMD
// Either run RebinMD or SliceMD
const
std
::
string
cutAlgName
=
noPix
?
"BinMD"
:
"SliceMD"
;
const
std
::
string
cutAlgName
=
noPix
?
"BinMD"
:
"SliceMD"
;
...
@@ -356,7 +423,8 @@ void CutMD::exec() {
...
@@ -356,7 +423,8 @@ void CutMD::exec() {
std
::
vector
<
std
::
string
>
vec
(
numDims
,
"0"
);
std
::
vector
<
std
::
string
>
vec
(
numDims
,
"0"
);
for
(
size_t
j
=
0
;
j
<
3
;
++
j
)
for
(
size_t
j
=
0
;
j
<
3
;
++
j
)
vec
[
j
]
=
boost
::
lexical_cast
<
std
::
string
>
(
projectionMatrix
[
i
][
j
]);
vec
[
j
]
=
boost
::
lexical_cast
<
std
::
string
>
(
scaledProjectionMatrix
[
i
][
j
]);
vecStr
=
boost
::
algorithm
::
join
(
vec
,
", "
);
vecStr
=
boost
::
algorithm
::
join
(
vec
,
", "
);
}
else
{
}
else
{
// Always orthogonal
// Always orthogonal
...
...
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