Commit c2416671 authored by Lynch, Vickie's avatar Lynch, Vickie
Browse files

Refs #22420 add offset properties

parent eb5448b1
......@@ -43,6 +43,9 @@ public:
private:
bool m_ModStru;
std::vector<double>m_offset1 = {0.0, 0.0, 0.0};
std::vector<double>m_offset2 = {0.0, 0.0, 0.0};
std::vector<double>m_offset3 = {0.0, 0.0, 0.0};
/// Initialise the properties
void init() override;
......
......@@ -8,10 +8,6 @@
namespace Mantid {
namespace Kernel {
class V3D;
}
namespace Crystal {
/** Save a PeaksWorkspace to a ISAW-style ASCII .peaks file.
......
......@@ -198,6 +198,20 @@ std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS,
Strings::convert(getWord(in, false), bank);
if (s == "5")
det.push_back(bank);
if (s == "9") {
m_offset1[0] = std::stod(getWord(in, false), nullptr);
m_offset1[1] = std::stod(getWord(in, false), nullptr);
m_offset1[2] = std::stod(getWord(in, false), nullptr);
m_offset2[0] = std::stod(getWord(in, false), nullptr);
m_offset2[1] = std::stod(getWord(in, false), nullptr);
m_offset2[2] = std::stod(getWord(in, false), nullptr);
m_offset3[0] = std::stod(getWord(in, false), nullptr);
m_offset3[1] = std::stod(getWord(in, false), nullptr);
m_offset3[2] = std::stod(getWord(in, false), nullptr);
outWS->mutableRun().addProperty<std::vector<double>>("Offset1", m_offset1, true);
outWS->mutableRun().addProperty<std::vector<double>>("Offset2", m_offset2, true);
outWS->mutableRun().addProperty<std::vector<double>>("Offset3", m_offset3, true);
}
}
// Find bank numbers in instument that are not in header lines
std::string maskBanks;
......@@ -303,13 +317,18 @@ DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS,
h = std::stod(getWord(in, false), nullptr);
k = std::stod(getWord(in, false), nullptr);
l = std::stod(getWord(in, false), nullptr);
int mod1 = 0;
int mod2 = 0;
int mod3 = 0;
V3D mod = V3D(0,0,0);
if (m_ModStru) {
mod1 = std::stoi(getWord(in, false), nullptr);
mod2 = std::stoi(getWord(in, false), nullptr);
mod3 = std::stoi(getWord(in, false), nullptr);
mod[0] = std::stoi(getWord(in, false), nullptr);
mod[1] = std::stoi(getWord(in, false), nullptr);
mod[2] = std::stoi(getWord(in, false), nullptr);
double deltaH = mod[0]*m_offset1[0]+mod[1]*m_offset2[0]+mod[2]*m_offset3[0];
double deltaK = mod[0]*m_offset1[1]+mod[1]*m_offset2[1]+mod[2]*m_offset3[1];
double deltaL = mod[0]*m_offset1[2]+mod[1]*m_offset2[2]+mod[2]*m_offset3[2];
h += deltaH;
k += deltaK;
l += deltaL;
}
......@@ -344,7 +363,7 @@ DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS,
Peak peak(outWS->getInstrument(), pixelID, wl);
peak.setHKL(qSign * h, qSign * k, qSign * l);
if (m_ModStru) {
peak.setModStru(V3D(mod1, mod2, mod3));
peak.setModStru(mod);
}
peak.setIntensity(Inti);
peak.setSigmaIntensity(SigI);
......
......@@ -13,6 +13,7 @@
#include "MantidKernel/ArrayProperty.h"
#include "MantidKernel/ArrayLengthValidator.h"
#include "MantidKernel/EnabledWhenProperty.h"
#include "MantidAPI/Run.h"
#include <boost/math/special_functions/round.hpp>
......@@ -120,7 +121,7 @@ void PredictSatellitePeaks::exec() {
offsets3.push_back(0.0);
offsets3.push_back(0.0);
offsets3.push_back(0.0);
}
}
bool includePeaksInRange = getProperty("IncludeAllPeaksInRange");
......@@ -138,6 +139,9 @@ void PredictSatellitePeaks::exec() {
auto OutPeaks = boost::dynamic_pointer_cast<IPeaksWorkspace>(
WorkspaceFactory::Instance().createPeaks());
OutPeaks->setInstrument(Instr);
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);
V3D hkl;
int peakNum = 0;
......
......@@ -97,7 +97,7 @@ void SaveIsawPeaks::exec() {
runMap_t runMap;
for (size_t i = 0; i < peaks.size(); ++i) {
Peak &p = peaks[i];
if (p.getModStru()[0] > 0)
if (p.getModStru() != V3D(0,0,0))
m_ModStru = true;
int run = p.getRunNumber();
int bank = 0;
......@@ -268,6 +268,22 @@ void SaveIsawPeaks::exec() {
// =========================================
// Go in order of run numbers
auto run = ws->mutableRun();
std::vector<double> offset1 = run.getPropertyValueAsType<std::vector<double>>("Offset1");
std::vector<double> offset2 = run.getPropertyValueAsType<std::vector<double>>("Offset2");
std::vector<double> offset3 = run.getPropertyValueAsType<std::vector<double>>("Offset3");
if (m_ModStru) {
out << "9 OFFSETS ";
out << std::setw(8) << std::fixed << std::setprecision(2) << offset1[0] << " ";
out << std::setw(8) << std::fixed << std::setprecision(2) << offset1[1] << " ";
out << std::setw(8) << std::fixed << std::setprecision(2) << offset1[2] << " ";
out << std::setw(8) << std::fixed << std::setprecision(2) << offset2[0] << " ";
out << std::setw(8) << std::fixed << std::setprecision(2) << offset2[1] << " ";
out << std::setw(8) << std::fixed << std::setprecision(2) << offset2[2] << " ";
out << std::setw(8) << std::fixed << std::setprecision(2) << offset3[0] << " ";
out << std::setw(8) << std::fixed << std::setprecision(2) << offset3[1] << " ";
out << std::setw(8) << std::fixed << std::setprecision(2) << offset3[2] << "\n";
}
int maxPeakNumb = 0;
int appendPeakNumb = 0;
runMap_t::iterator runMap_it;
......@@ -324,10 +340,14 @@ void SaveIsawPeaks::exec() {
// HKL's are flipped by -1 because of the internal Q convention
// unless Crystallography convention
if (m_ModStru) {
V3D mod = p.getModStru();
out << std::setw(5) << Utils::round(qSign * (p.getH()-mod[0]*0.5)) << std::setw(5)
<< Utils::round(qSign * (p.getK()-mod[1])) << std::setw(5)
<< Utils::round(qSign * (p.getL()-mod[2]));
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));
out << std::setw(5) << Utils::round(qSign * mod[0]) << std::setw(5)
<< Utils::round(qSign * mod[1]) << std::setw(5) << Utils::round(qSign * mod[2]);
}
......
......@@ -83,7 +83,7 @@ public:
virtual void setPeakNumber(int m_PeakNumber) = 0;
virtual Mantid::Kernel::V3D getModStru() const = 0;
virtual void setModStru(Mantid::Kernel::V3D m_ModStru) = 0;
virtual void setModStru(std::vector<double> m_ModStru) = 0;
virtual Mantid::Kernel::Matrix<double> getGoniometerMatrix() const = 0;
virtual void setGoniometerMatrix(
......
......@@ -67,7 +67,7 @@ public:
MOCK_CONST_METHOD0(getInstrument, Geometry::Instrument_const_sptr());
MOCK_CONST_METHOD0(getRunNumber, int());
MOCK_CONST_METHOD0(getPeakNumber, int());
MOCK_CONST_METHOD0(getModStru, int());
MOCK_CONST_METHOD0(getModStru, Mantid::Kernel::V3D());
MOCK_METHOD1(setRunNumber, void(int m_RunNumber));
MOCK_METHOD1(setPeakNumber, void(int m_PeakNumber));
MOCK_METHOD1(setModStru, void(int m_ModStru));
......
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