Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
59c72aa1
Commit
59c72aa1
authored
Jul 31, 2018
by
Lynch, Vickie
Browse files
Refs #22420 separate all from input peaks
parent
a0d78390
Changes
4
Hide whitespace changes
Inline
Side-by-side
Framework/Crystal/inc/MantidCrystal/PredictSatellitePeaks.h
View file @
59c72aa1
...
...
@@ -64,6 +64,7 @@ private:
/// Run the algorithm
void
exec
()
override
;
void
exec_peaks
();
Kernel
::
V3D
getOffsetVector
(
const
std
::
string
&
label
);
void
predictOffsets
(
DataObjects
::
PeaksWorkspace_sptr
Peaks
,
boost
::
shared_ptr
<
Mantid
::
API
::
IPeaksWorkspace
>
&
OutPeaks
,
...
...
Framework/Crystal/src/PredictSatellitePeaks.cpp
View file @
59c72aa1
...
...
@@ -98,6 +98,11 @@ void PredictSatellitePeaks::init() {
/// Run the algorithm
void
PredictSatellitePeaks
::
exec
()
{
bool
includePeaksInRange
=
getProperty
(
"IncludeAllPeaksInRange"
);
if
(
!
includePeaksInRange
)
{
exec_peaks
();
return
;
}
PeaksWorkspace_sptr
Peaks
=
getProperty
(
"Peaks"
);
if
(
!
Peaks
)
throw
std
::
invalid_argument
(
...
...
@@ -108,7 +113,6 @@ void PredictSatellitePeaks::exec() {
V3D
offsets3
=
getOffsetVector
(
"ModVector3"
);
int
maxOrder
=
getProperty
(
"MaxOrder"
);
bool
includePeaksInRange
=
getProperty
(
"IncludeAllPeaksInRange"
);
bool
includeOrderZero
=
getProperty
(
"IncludeIntegerHKL"
);
if
(
Peaks
->
getNumberPeaks
()
<=
0
)
{
...
...
@@ -127,7 +131,6 @@ void PredictSatellitePeaks::exec() {
OutPeaks
->
setInstrument
(
instrument
);
OutPeaks
->
mutableSample
().
setOrientedLattice
(
&
lattice
);
const
auto
NPeaks
=
Peaks
->
getNumberPeaks
();
Kernel
::
Matrix
<
double
>
goniometer
;
goniometer
.
identityMatrix
();
...
...
@@ -157,22 +160,18 @@ void PredictSatellitePeaks::exec() {
}
size_t
N
=
NPeaks
*
(
1
+
2
*
maxOrder
);
if
(
includePeaksInRange
)
{
N
=
possibleHKLs
.
size
();
N
=
max
<
size_t
>
(
100
,
N
);
}
size_t
N
=
possibleHKLs
.
size
();
N
=
max
<
size_t
>
(
100
,
N
);
auto
&
UB
=
lattice
.
getUB
();
goniometer
=
peak0
.
getGoniometerMatrix
();
Progress
prog
(
this
,
0.0
,
1.0
,
N
);
vector
<
vector
<
int
>>
AlreadyDonePeaks
;
DblMatrix
orientedUB
=
goniometer
*
UB
;
auto
orientedUB
=
goniometer
*
UB
;
HKLFilterWavelength
lambdaFilter
(
orientedUB
,
lambdaMin
,
lambdaMax
);
int
seqNum
=
0
;
OutPeaks
->
mutableRun
().
addProperty
<
std
::
vector
<
double
>>
(
"Offset1"
,
offsets1
,
true
);
OutPeaks
->
mutableRun
().
addProperty
<
std
::
vector
<
double
>>
(
"Offset2"
,
offsets2
,
true
);
OutPeaks
->
mutableRun
().
addProperty
<
std
::
vector
<
double
>>
(
"Offset3"
,
offsets3
,
true
);
if
(
includePeaksInRange
)
{
for
(
auto
it
=
possibleHKLs
.
begin
();
it
!=
possibleHKLs
.
end
();
++
it
){
V3D
hkl
=
*
it
;
predictOffsets
(
Peaks
,
OutPeaks
,
offsets1
,
maxOrder
,
hkl
,
...
...
@@ -185,7 +184,45 @@ void PredictSatellitePeaks::exec() {
lambdaFilter
,
includePeaksInRange
,
includeOrderZero
,
seqNum
,
AlreadyDonePeaks
);
}
}
else
{
setProperty
(
"SatellitePeaks"
,
OutPeaks
);
}
void
PredictSatellitePeaks
::
exec_peaks
()
{
PeaksWorkspace_sptr
Peaks
=
getProperty
(
"Peaks"
);
if
(
!
Peaks
)
throw
std
::
invalid_argument
(
"Input workspace is not a PeaksWorkspace. Type="
+
Peaks
->
id
());
V3D
offsets1
=
getOffsetVector
(
"ModVector1"
);
V3D
offsets2
=
getOffsetVector
(
"ModVector2"
);
V3D
offsets3
=
getOffsetVector
(
"ModVector3"
);
int
maxOrder
=
getProperty
(
"MaxOrder"
);
bool
includePeaksInRange
=
false
;
bool
includeOrderZero
=
getProperty
(
"IncludeIntegerHKL"
);
if
(
Peaks
->
getNumberPeaks
()
<=
0
)
{
g_log
.
error
()
<<
"There are No peaks in the input PeaksWorkspace
\n
"
;
return
;
}
API
::
Sample
sample
=
Peaks
->
mutableSample
();
OrientedLattice
lattice
=
sample
.
getOrientedLattice
();
const
auto
instrument
=
Peaks
->
getInstrument
();
auto
OutPeaks
=
boost
::
dynamic_pointer_cast
<
IPeaksWorkspace
>
(
WorkspaceFactory
::
Instance
().
createPeaks
());
OutPeaks
->
setInstrument
(
instrument
);
OutPeaks
->
mutableSample
().
setOrientedLattice
(
&
lattice
);
vector
<
vector
<
int
>>
AlreadyDonePeaks
;
int
seqNum
=
0
;
HKLFilterWavelength
lambdaFilter
(
DblMatrix
(
3
,
3
,
true
),
0.1
,
100.
);
OutPeaks
->
mutableRun
().
addProperty
<
std
::
vector
<
double
>>
(
"Offset1"
,
offsets1
,
true
);
OutPeaks
->
mutableRun
().
addProperty
<
std
::
vector
<
double
>>
(
"Offset2"
,
offsets2
,
true
);
OutPeaks
->
mutableRun
().
addProperty
<
std
::
vector
<
double
>>
(
"Offset3"
,
offsets3
,
true
);
std
::
vector
<
Peak
>
peaks
=
Peaks
->
getPeaks
();
for
(
auto
it
=
peaks
.
begin
();
it
!=
peaks
.
end
();
++
it
){
auto
peak
=
*
it
;
...
...
@@ -200,7 +237,6 @@ std::vector<Peak> peaks = Peaks->getPeaks();
lambdaFilter
,
includePeaksInRange
,
includeOrderZero
,
seqNum
,
AlreadyDonePeaks
);
}
}
setProperty
(
"SatellitePeaks"
,
OutPeaks
);
}
...
...
Framework/Crystal/test/PredictSatellitePeaksTest.h
View file @
59c72aa1
...
...
@@ -20,6 +20,7 @@
#include
"MantidAPI/Run.h"
#include
"MantidCrystal/CalculateUMatrix.h"
#include
"MantidAPI/AnalysisDataService.h"
#include
"MantidGeometry/Instrument/Goniometer.h"
using
namespace
Mantid
::
Crystal
;
using
namespace
Mantid
::
API
;
...
...
@@ -52,6 +53,12 @@ public:
pw
->
addPeak
(
p1
);
pw
->
addPeak
(
p2
);
AnalysisDataService
::
Instance
().
addOrReplace
(
WSName
,
pw
);
// Set Goniometer to 180 degrees
Mantid
::
Geometry
::
Goniometer
gonio
;
gonio
.
makeUniversalGoniometer
();
gonio
.
setRotationAngle
(
1
,
180
);
pw
->
mutableRun
().
setGoniometer
(
gonio
,
false
);
CalculateUMatrix
alg2
;
TS_ASSERT_THROWS_NOTHING
(
alg2
.
initialize
())
TS_ASSERT
(
alg2
.
isInitialized
())
...
...
@@ -91,6 +98,26 @@ public:
TS_ASSERT_DELTA
(
peak3
.
getK
(),
0.0
,
.0001
);
TS_ASSERT_DELTA
(
peak3
.
getL
(),
0.2
,
.0001
);
/*PredictSatellitePeaks alg4;
TS_ASSERT_THROWS_NOTHING(alg4.initialize());
TS_ASSERT(alg4.isInitialized());
alg4.setProperty("Peaks", WSName);
alg4.setProperty("SatellitePeaks", std::string("SatellitePeaks"));
alg4.setProperty("ModVector1", "0.5,0,.2");
alg4.setProperty("MaxOrder", "1");
alg4.setProperty("IncludeAllPeaksInRange", true);
alg4.setProperty("MinDSpacing", "3");
alg4.setProperty("MaxDSpacing", "16");
alg4.setProperty("WavelengthMin", "0.5");
alg4.setProperty("WavelengthMax", "22");
TS_ASSERT(alg4.execute())
TS_ASSERT(alg4.isExecuted());
PeaksWorkspace_sptr SatellitePeaks2 = alg4.getProperty("SatellitePeaks");
TS_ASSERT_EQUALS(SatellitePeaks2->getNumberPeaks(), 5);*/
AnalysisDataService
::
Instance
().
remove
(
WSName
);
}
};
...
...
Framework/DataObjects/src/PeakColumn.cpp
View file @
59c72aa1
...
...
@@ -160,19 +160,6 @@ void PeakColumn::print(size_t index, std::ostream &s) const {
s
.
flags
(
fflags
);
}
//-------------------------------------------------------------------------------------
/** Remove substring from string
*
* @param str :: string to modify
* @param toErase :: substring to erase
*/
void
PeakColumn
::
eraseSubStr
(
std
::
string
&
str
,
const
std
::
string
&
toErase
)
{
std
::
string
::
size_type
n
=
toErase
.
length
();
for
(
std
::
string
::
size_type
i
=
str
.
find
(
toErase
);
i
!=
std
::
string
::
npos
;
i
=
str
.
find
(
toErase
))
str
.
erase
(
i
,
n
);
}
//-------------------------------------------------------------------------------------
/** Read in some text and convert to a number in the PeaksWorkspace
*
...
...
@@ -187,11 +174,7 @@ void PeakColumn::read(size_t index, const std::string &text) {
// Convert to a double
double
val
=
0
;
// Table has put comma in run numbers so remove
std
::
string
text2
=
text
;
eraseSubStr
(
text2
,
","
);
int
success
=
Strings
::
convert
(
text2
,
val
);
int
success
=
Strings
::
convert
(
text
,
val
);
if
(
success
==
0
)
{
g_log
.
error
()
<<
"Could not convert string '"
<<
text
<<
"' to a number.
\n
"
;
...
...
@@ -224,8 +207,7 @@ void PeakColumn::read(const size_t index, std::istringstream &in) {
//-------------------------------------------------------------------------------------
/** @return true if the column is read-only */
bool
PeakColumn
::
getReadOnly
()
const
{
return
!
((
m_name
==
"h"
)
||
(
m_name
==
"k"
)
||
(
m_name
==
"l"
)
||
(
m_name
==
"RunNumber"
));
return
!
((
m_name
==
"h"
)
||
(
m_name
==
"k"
)
||
(
m_name
==
"l"
));
}
//-------------------------------------------------------------------------------------
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment