Commit 414a3eb4 authored by Martyn Gigg's avatar Martyn Gigg
Browse files

Merge branch 'release-next'

parents a62a8e6f 05926afe
......@@ -45,6 +45,12 @@ validModulationVectors(const std::vector<double> &modVector1,
const std::vector<double> &modVector2,
const std::vector<double> &modVector3);
/// Create a list of valid modulation vectors from the input
std::vector<Kernel::V3D>
addModulationVectors(const std::vector<double> &modVector1,
const std::vector<double> &modVector2,
const std::vector<double> &modVector3);
/// Calculate a list of HKL offsets from the given modulation vectors.
std::vector<MNPOffset>
generateOffsetVectors(const std::vector<Kernel::V3D> &modVectors,
......
......@@ -65,23 +65,27 @@ struct IndexPeaksArgs {
std::vector<V3D> modVectorsToUse;
modVectorsToUse.reserve(3);
bool crossTermToUse{false};
if (maxOrderFromAlg > 0) {
// Use inputs from algorithm
maxOrderToUse = maxOrderFromAlg;
crossTermToUse = alg.getProperty(ModulationProperties::CrossTerms);
modVectorsToUse = validModulationVectors(
alg.getProperty(ModulationProperties::ModVector1),
alg.getProperty(ModulationProperties::ModVector2),
alg.getProperty(ModulationProperties::ModVector3));
} else {
// default behavior: map everything automatically
maxOrderToUse = maxOrderFromAlg;
crossTermToUse = alg.getProperty(ModulationProperties::CrossTerms);
modVectorsToUse =
addModulationVectors(alg.getProperty(ModulationProperties::ModVector1),
alg.getProperty(ModulationProperties::ModVector2),
alg.getProperty(ModulationProperties::ModVector3));
// deal with special cases
if (maxOrderFromAlg <= 0) {
// Use lattice definitions if they exist
const auto &lattice = peaksWS->sample().getOrientedLattice();
maxOrderToUse = lattice.getMaxOrder();
crossTermToUse = lattice.getCrossTerm();
maxOrderToUse = lattice.getMaxOrder(); // the lattice can return a 0 here
// if lattice has maxOrder, we will use the modVec from it, otherwise
// stick to the input got from previous assignment
if (maxOrderToUse > 0) {
modVectorsToUse = validModulationVectors(
lattice.getModVec(0), lattice.getModVec(1), lattice.getModVec(2));
}
crossTermToUse = lattice.getCrossTerm();
}
return {peaksWS,
......@@ -453,9 +457,24 @@ void IndexPeaks::exec() {
auto &lattice = args.workspace->mutableSample().getOrientedLattice();
lattice.setMaxOrder(args.satellites.maxOrder);
lattice.setCrossTerm(args.satellites.crossTerms);
lattice.setModVec1(args.satellites.modVectors[0]);
lattice.setModVec2(args.satellites.modVectors[1]);
lattice.setModVec3(args.satellites.modVectors[2]);
if (args.satellites.modVectors.size() >= 1){
lattice.setModVec1(args.satellites.modVectors[0]);
} else {
g_log.warning("empty modVector 1, skipping saving");
}
if (args.satellites.modVectors.size() >= 2){
lattice.setModVec2(args.satellites.modVectors[1]);
} else {
g_log.warning("empty modVector 2, skipping saving");
}
if (args.satellites.modVectors.size() >= 3){
lattice.setModVec3(args.satellites.modVectors[2]);
} else {
g_log.warning("empty modVector 3, skipping saving");
}
}
CombinedIndexingStats indexingInfo;
......
......@@ -108,6 +108,27 @@ validModulationVectors(const std::vector<double> &modVector1,
return modVectors;
}
/**
* Direct add modulation a list to return.
* @param modVector1 List of 3 doubles specifying an offset
* @param modVector2 List of 3 doubles specifying an offset
* @param modVector3 List of 3 doubles specifying an offset
* @return A list of valid modulation vectors
*/
std::vector<Kernel::V3D>
addModulationVectors(const std::vector<double> &modVector1,
const std::vector<double> &modVector2,
const std::vector<double> &modVector3) {
std::vector<V3D> modVectors;
auto addVec = [&modVectors](const auto &modVec) {
modVectors.emplace_back(V3D(modVec[0], modVec[1], modVec[2]));
};
addVec(modVector1);
addVec(modVector2);
addVec(modVector3);
return modVectors;
}
/**
* @param maxOrder Integer specifying the multiples of the
* modulation vector.
......
# Mantid Repository : https://github.com/mantidproject/mantid
#
# Copyright &copy; 2018 ISIS Rutherford Appleton Laboratory UKRI,
# NScD Oak Ridge National Laboratory, European Spallation Source,
# Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
# SPDX - License - Identifier: GPL - 3.0 +
from mantid.simpleapi import Load, FindUBUsingIndexedPeaks, IndexPeaks
import unittest
import numpy as np
import numpy.testing as npt
class IndexPeaksTest(unittest.TestCase):
"""
The purpose of the testing is to ensure the Python bindning works
with various different input arguments.
"""
def test_exec_with_different_args(self):
# load data
Load(
Filename="test_index_satellite_peaks.integrate", OutputWorkspace="test",
)
FindUBUsingIndexedPeaks(PeaksWorkspace="test")
# defualt args
IndexPeaks(PeaksWorkspace="test", Tolerance=0.12)
# testing zero (default) modVec with maxOrder=1
IndexPeaks(
PeaksWorkspace="test",
Tolerance=0.12,
RoundHKLs=False,
SaveModulationInfo=True,
MaxOrder=1,
)
# testing one non-zero modVec with maxOrder=1
IndexPeaks(
PeaksWorkspace="test",
Tolerance=0.12,
RoundHKLs=False,
SaveModulationInfo=True,
MaxOrder=1,
ModVector1="0,0,0.33333",
)
# testing one non-zero modVec with maxOrder=0
IndexPeaks(
PeaksWorkspace="test",
Tolerance=0.12,
RoundHKLs=False,
SaveModulationInfo=True,
ModVector1="0,0,0.33333",
)
if __name__ == "__main__":
unittest.main()
Supports Markdown
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