Commit 1277911a authored by Lynch, Vickie's avatar Lynch, Vickie
Browse files

Refs #22420 add set/getIntHKL

parent 5e131b36
......@@ -323,6 +323,7 @@ DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS,
k = qSign * std::stod(getWord(in, false), nullptr);
l = qSign * std::stod(getWord(in, false), nullptr);
V3D mod = V3D(0, 0, 0);
V3D intHKL = V3D(h, k, l);
if (m_ModStru) {
mod[0] = qSign * std::stoi(getWord(in, false), nullptr);
mod[1] = qSign * std::stoi(getWord(in, false), nullptr);
......@@ -369,6 +370,7 @@ DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS,
// Create the peak object
Peak peak(outWS->getInstrument(), pixelID, wl);
peak.setHKL(h, k, l);
peak.setIntHKL(intHKL);
if (m_ModStru) {
peak.setModStru(mod);
}
......
......@@ -244,6 +244,7 @@ void PredictSatellitePeaks::exec() {
continue;
peak->setHKL(hkl1);
peak->setIntHKL(hkl);
peak->setPeakNumber(seqNum);
seqNum++;
peak->setRunNumber(RunNumber);
......
......@@ -354,15 +354,10 @@ void SaveIsawPeaks::exec() {
// unless Crystallography convention
if (m_ModStru) {
V3D mod = p.getModStru();
double deltaH =
mod[0] * offset1[0] + mod[1] * offset2[0] + mod[2] * offset3[0];
double deltaK =
mod[0] * offset1[1] + mod[1] * offset2[1] + mod[2] * offset3[1];
double deltaL =
mod[0] * offset1[2] + mod[1] * offset2[2] + mod[2] * offset3[2];
out << std::setw(5) << Utils::round(qSign * (p.getH() - deltaH))
<< std::setw(5) << Utils::round(qSign * (p.getK() - deltaK))
<< std::setw(5) << Utils::round(qSign * (p.getL() - deltaL));
auto intHKL = p.getIntHKL();
out << std::setw(5) << Utils::round(qSign * intHKL.X())
<< std::setw(5) << Utils::round(qSign * intHKL.Y())
<< std::setw(5) << Utils::round(qSign * intHKL.Z());
out << std::setw(5) << Utils::round(qSign * mod[0]) << std::setw(5)
<< Utils::round(qSign * mod[1]) << std::setw(5)
......
......@@ -71,7 +71,8 @@ public:
alg.setProperty("Peaks", WSName);
alg.setProperty("SatellitePeaks", std::string("SatellitePeaks"));
alg.setProperty("OffsetVector1", "0.5,0,.2,1");
alg.setProperty("ModVector1", "0.5,0,.2");
alg.setProperty("MaxOrder", "1");
TS_ASSERT(alg.execute());
TS_ASSERT(alg.isExecuted());
alg.setPropertyValue("SatellitePeaks", "SatellitePeaks");
......
......@@ -98,12 +98,14 @@ public:
double getK() const override;
double getL() const override;
Mantid::Kernel::V3D getHKL() const override;
Mantid::Kernel::V3D getIntHKL() const override;
void setH(double m_H) override;
void setK(double m_K) override;
void setL(double m_L) override;
void setBankName(std::string m_bankName);
void setHKL(double H, double K, double L) override;
void setHKL(const Mantid::Kernel::V3D &HKL) override;
void setIntHKL(const Mantid::Kernel::V3D &HKL) override;
void resetHKL();
Mantid::Kernel::V3D getQLabFrame() const override;
......@@ -201,6 +203,15 @@ private:
/// L of the peak
double m_L;
/// integer H of the peak
int m_intH;
/// integer K of the peak
int m_intK;
/// integer L of the peak
int m_intL;
/// Integrated peak intensity
double m_intensity;
......
......@@ -9,6 +9,7 @@
#include "MantidKernel/System.h"
#include "boost/make_shared.hpp"
#include <boost/math/special_functions/round.hpp>
#include <algorithm>
#include <cctype>
......@@ -29,7 +30,7 @@ Peak::Peak()
m_finalEnergy(0.), m_GoniometerMatrix(3, 3, true),
m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0),
m_row(-1), m_col(-1), m_orig_H(0), m_orig_K(0), m_orig_L(0),
m_peakNumber(0), m_ModStru(V3D(0, 0, 0)),
m_peakNumber(0), m_ModStru(V3D(0, 0, 0)), m_intH(0),m_intK(0),m_intL(0),
m_peakShape(boost::make_shared<NoShape>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
}
......@@ -51,7 +52,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst,
m_binCount(0), m_GoniometerMatrix(3, 3, true),
m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0),
m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0),
m_ModStru(V3D(0, 0, 0)), m_peakShape(boost::make_shared<NoShape>()) {
m_ModStru(V3D(0, 0, 0)), m_intH(0),m_intK(0),m_intL(0), m_peakShape(boost::make_shared<NoShape>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
this->setInstrument(m_inst);
this->setQLabFrame(QLabFrame, detectorDistance);
......@@ -78,7 +79,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst,
m_binCount(0), m_GoniometerMatrix(goniometer),
m_InverseGoniometerMatrix(goniometer), m_runNumber(0), m_monitorCount(0),
m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0),
m_ModStru(V3D(0, 0, 0)), m_peakShape(boost::make_shared<NoShape>()) {
m_ModStru(V3D(0, 0, 0)), m_intH(0),m_intK(0),m_intL(0), m_peakShape(boost::make_shared<NoShape>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8)
throw std::invalid_argument(
......@@ -101,7 +102,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID,
m_binCount(0), m_GoniometerMatrix(3, 3, true),
m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0),
m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0),
m_ModStru(V3D(0, 0, 0)), m_peakShape(boost::make_shared<NoShape>()) {
m_ModStru(V3D(0, 0, 0)), m_intH(0),m_intK(0),m_intL(0), m_peakShape(boost::make_shared<NoShape>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
this->setInstrument(m_inst);
this->setDetectorID(m_detectorID);
......@@ -123,7 +124,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID,
m_sigmaIntensity(0), m_binCount(0), m_GoniometerMatrix(3, 3, true),
m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0),
m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0),
m_ModStru(V3D(0, 0, 0)), m_peakShape(boost::make_shared<NoShape>()) {
m_ModStru(V3D(0, 0, 0)), m_intH(0),m_intK(0),m_intL(0), m_peakShape(boost::make_shared<NoShape>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
this->setInstrument(m_inst);
this->setDetectorID(m_detectorID);
......@@ -147,7 +148,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID,
m_sigmaIntensity(0), m_binCount(0), m_GoniometerMatrix(goniometer),
m_InverseGoniometerMatrix(goniometer), m_runNumber(0), m_monitorCount(0),
m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0),
m_ModStru(V3D(0, 0, 0)), m_peakShape(boost::make_shared<NoShape>()) {
m_ModStru(V3D(0, 0, 0)), m_intH(0),m_intK(0),m_intL(0), m_peakShape(boost::make_shared<NoShape>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8)
throw std::invalid_argument(
......@@ -170,7 +171,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, double scattering,
m_binCount(0), m_GoniometerMatrix(3, 3, true),
m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0),
m_row(-1), m_col(-1), m_orig_H(0), m_orig_K(0), m_orig_L(0),
m_peakNumber(0), m_ModStru(V3D(0, 0, 0)),
m_peakNumber(0), m_ModStru(V3D(0, 0, 0)), m_intH(0),m_intK(0),m_intL(0),
m_peakShape(boost::make_shared<NoShape>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
this->setInstrument(m_inst);
......@@ -201,6 +202,7 @@ Peak::Peak(const Peak &other)
m_orig_H(other.m_orig_H), m_orig_K(other.m_orig_K),
m_orig_L(other.m_orig_L), m_peakNumber(other.m_peakNumber),
m_ModStru(other.m_ModStru), m_detIDs(other.m_detIDs),
m_intH(other.m_intH), m_intK(other.m_intK), m_intL(other.m_intL),
m_peakShape(other.m_peakShape->clone()), convention(other.convention) {}
//----------------------------------------------------------------------------------------------
......@@ -222,6 +224,9 @@ Peak::Peak(const Geometry::IPeak &ipeak)
m_monitorCount(ipeak.getMonitorCount()), m_row(ipeak.getRow()),
m_col(ipeak.getCol()), m_orig_H(0.), m_orig_K(0.), m_orig_L(0.),
m_peakNumber(ipeak.getPeakNumber()), m_ModStru(ipeak.getModStru()),
m_intH(ipeak.getIntHKL().X()),
m_intK(ipeak.getIntHKL().Y()),
m_intL(ipeak.getIntHKL().Z()),
m_peakShape(boost::make_shared<NoShape>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8)
......@@ -752,6 +757,9 @@ double Peak::getL() const { return m_L; }
/** Return the HKL vector */
Mantid::Kernel::V3D Peak::getHKL() const { return V3D(m_H, m_K, m_L); }
/** Return the int HKL vector */
Mantid::Kernel::V3D Peak::getIntHKL() const { return V3D(m_intH, m_intK, m_intL); }
//----------------------------------------------------------------------------------------------
/** Set the H index of this peak
* @param m_H :: index to set */
......@@ -807,6 +815,16 @@ void Peak::setHKL(const Mantid::Kernel::V3D &HKL) {
m_L = HKL.Z();
}
/** Set int HKL
*
* @param HKL :: vector with integer x,y,z -> h,k,l
*/
void Peak::setIntHKL(const Mantid::Kernel::V3D &HKL) {
m_intH = boost::math::iround(HKL.X());
m_intK = boost::math::iround(HKL.Y());
m_intL = boost::math::iround(HKL.Z());
}
//----------------------------------------------------------------------------------------------
/** Return the # of counts in the bin at its peak*/
double Peak::getBinCount() const { return m_binCount; }
......
......@@ -39,11 +39,13 @@ public:
virtual double getK() const = 0;
virtual double getL() const = 0;
virtual Mantid::Kernel::V3D getHKL() const = 0;
virtual Mantid::Kernel::V3D getIntHKL() const = 0;
virtual void setH(double m_H) = 0;
virtual void setK(double m_K) = 0;
virtual void setL(double m_L) = 0;
virtual void setHKL(double H, double K, double L) = 0;
virtual void setHKL(const Mantid::Kernel::V3D &HKL) = 0;
virtual void setIntHKL(const Mantid::Kernel::V3D &HKL) = 0;
virtual Mantid::Kernel::V3D getDetectorPosition() const = 0;
virtual Mantid::Kernel::V3D getDetectorPositionNoCheck() const = 0;
......
......@@ -77,11 +77,13 @@ public:
MOCK_CONST_METHOD0(getK, double());
MOCK_CONST_METHOD0(getL, double());
MOCK_CONST_METHOD0(getHKL, Mantid::Kernel::V3D());
MOCK_CONST_METHOD0(getIntHKL, Mantid::Kernel::V3D());
MOCK_METHOD1(setH, void(double m_H));
MOCK_METHOD1(setK, void(double m_K));
MOCK_METHOD1(setL, void(double m_L));
MOCK_METHOD3(setHKL, void(double H, double K, double L));
MOCK_METHOD1(setHKL, void(const Mantid::Kernel::V3D &HKL));
MOCK_METHOD1(setIntHKL, void(const Mantid::Kernel::V3D &HKL));
MOCK_CONST_METHOD0(getQLabFrame, Mantid::Kernel::V3D());
MOCK_CONST_METHOD0(getQSampleFrame, Mantid::Kernel::V3D());
MOCK_METHOD0(findDetector, bool());
......
......@@ -86,6 +86,11 @@ void export_IPeak() {
.def("getL", &IPeak::getL, arg("self"), "Get the L index of the peak")
.def("getHKL", &IPeak::getHKL, arg("self"),
"Get HKL as a :class:`~mantid.kernel.V3D` object")
.def("getIntHKL", &IPeak::getIntHKL, arg("self"),
"Get HKL as a :class:`~mantid.kernel.V3D` object")
.def("setIntHKL", (void (IPeak::*)(Mantid::Kernel::V3D)) & IPeak::setIntHKL,
(arg("self"), arg("hkl")),
"Set the integer HKL values of this peak")
.def("setHKL", (void (IPeak::*)(double, double, double)) & IPeak::setHKL,
(arg("self"), arg("h"), arg("k"), arg("l")),
"Set the HKL values of this peak")
......
......@@ -33,7 +33,7 @@ Usage
LoadIsawUB(peaks,"TOPAZ_3007.mat")
IndexPeaks(peaks)
fractional_peaks = PredictSatellitePeaks(peaks, OffsetVector1=[-0.5,0,0.0,1])
fractional_peaks = PredictSatellitePeaks(peaks, ModVector1=[-0.5,0,0.0],MaxOrder=1)
print("Number of fractional peaks: {}".format(fractional_peaks.getNumberPeaks()))
.. testoutput:: TopazExample
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment