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

Refs #22420 change save and load isaw peaks

parent ec1a4d66
......@@ -42,6 +42,8 @@ public:
int confidence(Kernel::FileDescriptor &descriptor) const override;
private:
bool m_ModStru;
/// Initialise the properties
void init() override;
......
......@@ -39,6 +39,8 @@ public:
}
private:
bool m_ModStru = false;
/// Initialise the properties
void init() override;
/// Run the algorithm
......
......@@ -154,6 +154,11 @@ std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS,
date = Types::Core::DateAndTime::getCurrentTime().toISO8601String();
else if (tag == "Date:")
date = getWord(in, false);
tag = getWord(in, false);
if (tag == "MOD")
m_ModStru = true;
else
m_ModStru = false;
readToEndOfLine(in, true);
// Now we load the instrument using the name and date
......@@ -298,6 +303,15 @@ 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;
if (m_ModStru) {
mod1 = std::stoi(getWord(in, false), nullptr);
mod2 = std::stoi(getWord(in, false), nullptr);
mod3 = std::stoi(getWord(in, false), nullptr);
}
col = std::stod(getWord(in, false), nullptr);
row = std::stod(getWord(in, false), nullptr);
......@@ -329,6 +343,9 @@ DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS,
// Create the peak object
Peak peak(outWS->getInstrument(), pixelID, wl);
peak.setHKL(qSign * h, qSign * k, qSign * l);
if (m_ModStru) {
peak.setModStru(V3D(mod1, mod2, mod3));
}
peak.setIntensity(Inti);
peak.setSigmaIntensity(SigI);
peak.setBinCount(IPK);
......
......@@ -94,6 +94,8 @@ void SaveIsawPeaks::exec() {
runMap_t runMap;
for (size_t i = 0; i < peaks.size(); ++i) {
Peak &p = peaks[i];
if (p.getModStru()[0] > 0)
m_ModStru = true;
int run = p.getRunNumber();
int bank = 0;
std::string bankName = p.getBankName();
......@@ -152,7 +154,9 @@ void SaveIsawPeaks::exec() {
// For now, this allows the proper instrument to be loaded back after
// saving.
Types::Core::DateAndTime expDate = inst->getValidFromDate() + 1.0;
out << expDate.toISO8601String() << '\n';
out << expDate.toISO8601String();
if (m_ModStru) out << "MOD";
out << '\n';
out << "6 L1 T0_SHIFT\n";
out << "7 " << std::setw(10);
......@@ -320,6 +324,12 @@ void SaveIsawPeaks::exec() {
<< Utils::round(qSign * p.getK()) << std::setw(5)
<< Utils::round(qSign * p.getL());
if (m_ModStru) {
V3D mod = p.getModStru();
out << std::setw(5) << mod[0] << std::setw(5)
<< mod[1] << std::setw(5) << mod[2];
}
// Row/column
out << std::setw(8) << std::fixed << std::setprecision(2)
<< static_cast<double>(p.getCol()) << " ";
......
......@@ -152,6 +152,8 @@ public:
void setCol(int m_col);
void setPeakNumber(int m_peakNumber) override;
int getPeakNumber() const override;
void setModStru(Mantid::Kernel::V3D m_ModStru) override;
Mantid::Kernel::V3D getModStru() const override;
virtual Mantid::Kernel::V3D getDetPos() const override;
double getL1() const override;
......@@ -247,6 +249,7 @@ private:
// keep peak number
int m_peakNumber;
Mantid::Kernel::V3D m_ModStru;
/// List of contributing detectors IDs
std::set<int> m_detIDs;
......
......@@ -29,7 +29,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_peakShape(boost::make_shared<NoShape>()) {
m_peakNumber(0), m_ModStru(V3D(0,0,0)), m_peakShape(boost::make_shared<NoShape>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
}
......@@ -49,7 +49,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst,
: m_H(0), m_K(0), m_L(0), m_intensity(0), 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_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>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
this->setInstrument(m_inst);
......@@ -76,7 +76,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst,
: m_H(0), m_K(0), m_L(0), m_intensity(0), 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_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>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8)
......@@ -99,7 +99,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID,
: m_H(0), m_K(0), m_L(0), m_intensity(0), 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_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>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
this->setInstrument(m_inst);
......@@ -121,7 +121,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID,
: m_H(HKL[0]), m_K(HKL[1]), m_L(HKL[2]), m_intensity(0),
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_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>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
this->setInstrument(m_inst);
......@@ -145,7 +145,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID,
: m_H(HKL[0]), m_K(HKL[1]), m_L(HKL[2]), m_intensity(0),
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_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>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8)
......@@ -169,7 +169,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_peakShape(boost::make_shared<NoShape>()) {
m_peakNumber(0), m_ModStru(V3D(0,0,0)), m_peakShape(boost::make_shared<NoShape>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
this->setInstrument(m_inst);
this->setWavelength(m_Wavelength);
......@@ -198,6 +198,7 @@ Peak::Peak(const Peak &other)
samplePos(other.samplePos), detPos(other.detPos),
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_peakShape(other.m_peakShape->clone()),
convention(other.convention) {}
......@@ -220,6 +221,7 @@ 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_peakShape(boost::make_shared<NoShape>()) {
convention = Kernel::ConfigService::Instance().getString("Q.convention");
if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8)
......@@ -894,6 +896,11 @@ int Peak::getCol() const { return m_col; }
* Returns -1 if it could not find it. */
int Peak::getPeakNumber() const { return m_peakNumber; }
// -------------------------------------------------------------------------------------
/**Returns the unique peak number
* Returns -1 if it could not find it. */
V3D Peak::getModStru() const { return m_ModStru; }
// -------------------------------------------------------------------------------------
/** For RectangularDetectors only, sets the row (y) of the pixel of the
* detector.
......@@ -913,6 +920,13 @@ void Peak::setPeakNumber(int m_peakNumber) {
this->m_peakNumber = m_peakNumber;
}
// -------------------------------------------------------------------------------------
/** Sets the modulated peak structure number
* @param m_ModStrur :: modulated peak structure value */
void Peak::setModStru(V3D m_ModStru) {
this->m_ModStru = m_ModStru;
}
// -------------------------------------------------------------------------------------
/** Return the detector position vector */
Mantid::Kernel::V3D Peak::getDetPos() const { return detPos; }
......
......@@ -82,6 +82,9 @@ public:
virtual int getPeakNumber() const = 0;
virtual void setPeakNumber(int m_PeakNumber) = 0;
virtual Mantid::Kernel::V3D getModStru() const = 0;
virtual void setModStru(Mantid::Kernel::V3D m_ModStru) = 0;
virtual Mantid::Kernel::Matrix<double> getGoniometerMatrix() const = 0;
virtual void setGoniometerMatrix(
const Mantid::Kernel::Matrix<double> &m_GoniometerMatrix) = 0;
......
......@@ -67,8 +67,10 @@ 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_METHOD1(setRunNumber, void(int m_RunNumber));
MOCK_METHOD1(setPeakNumber, void(int m_PeakNumber));
MOCK_METHOD1(setModStru, void(int m_ModStru));
MOCK_CONST_METHOD0(getMonitorCount, double());
MOCK_METHOD1(setMonitorCount, void(double m_MonitorCount));
MOCK_CONST_METHOD0(getH, double());
......
......@@ -61,6 +61,8 @@ void export_IPeak() {
"cache values related to it.")
.def("getRunNumber", &IPeak::getRunNumber, arg("self"),
"Return the run number this peak was measured at")
.def("getModStru", &IPeak::getModStru, arg("self"),
"Return the modulated scructure for this peak")
.def("getPeakNumber", &IPeak::getPeakNumber, arg("self"),
"Return the peak number for this peak")
.def("getBankName", &IPeak::getBankName, arg("self"),
......@@ -68,6 +70,9 @@ void export_IPeak() {
.def("setRunNumber", &IPeak::setRunNumber,
(arg("self"), arg("run_number")),
"Set the run number that measured this peak")
.def("setModStru", &IPeak::setModStru,
(arg("self"), arg("modulated_structure")),
"Set the modulated structure for this peak")
.def("setPeakNumber", &IPeak::setPeakNumber,
(arg("self"), arg("peak_number")),
"Set the peak number for this peak")
......
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