Skip to content
Snippets Groups Projects
Commit 65bf3df0 authored by Anton Piccardo-Selg's avatar Anton Piccardo-Selg
Browse files

Refs #13872 Add non-axis frame selection for SlicingAlgorithms

parent f2bf4055
No related merge requests found
Showing
with 382 additions and 18 deletions
......@@ -46,6 +46,8 @@ public:
Kernel::UnitLabel getUnitLabel() const;
const Kernel::MDUnit &getMDUnit() const;
bool canConvertTo(const Kernel::MDUnit &otherUnit) const;
bool isQ() const;
bool isSameType(const MDFrame& frame) const;
std::string name() const;
virtual GeneralFrame *clone() const;
Mantid::Kernel::SpecialCoordinateSystem
......
......@@ -47,6 +47,8 @@ public:
Kernel::UnitLabel getUnitLabel() const;
const Kernel::MDUnit &getMDUnit() const;
bool canConvertTo(const Kernel::MDUnit &otherUnit) const;
bool isQ() const;
bool isSameType(const MDFrame& frame) const;
std::string name() const;
HKL *clone() const;
Mantid::Kernel::SpecialCoordinateSystem
......
......@@ -40,6 +40,8 @@ public:
virtual Mantid::Kernel::UnitLabel getUnitLabel() const = 0;
virtual const Mantid::Kernel::MDUnit &getMDUnit() const = 0;
virtual bool canConvertTo(const Mantid::Kernel::MDUnit &otherUnit) const = 0;
virtual bool isQ() const = 0;
virtual bool isSameType(const MDFrame& frame) const = 0;
virtual std::string name() const = 0;
virtual Mantid::Kernel::SpecialCoordinateSystem
equivalientSpecialCoordinateSystem() const = 0;
......@@ -49,6 +51,8 @@ public:
typedef std::unique_ptr<MDFrame> MDFrame_uptr;
typedef std::unique_ptr<const MDFrame> MDFrame_const_uptr;
typedef std::shared_ptr<MDFrame> MDFrame_sptr;
typedef std::shared_ptr<const MDFrame> MDFrame_const_sptr;
} // namespace Geometry
} // namespace Mantid
......
......@@ -41,6 +41,8 @@ public:
Mantid::Kernel::UnitLabel getUnitLabel() const;
const Mantid::Kernel::MDUnit &getMDUnit() const;
bool canConvertTo(const Mantid::Kernel::MDUnit &otherUnit) const;
bool isQ() const;
bool isSameType(const MDFrame& frame) const;
virtual std::string name() const;
QLab *clone() const;
Mantid::Kernel::SpecialCoordinateSystem
......
......@@ -42,6 +42,8 @@ public:
Kernel::UnitLabel getUnitLabel() const;
const Kernel::MDUnit &getMDUnit() const;
bool canConvertTo(const Kernel::MDUnit &otherUnit) const;
bool isQ() const;
bool isSameType(const MDFrame& frame) const;
std::string name() const;
QSample *clone() const;
Mantid::Kernel::SpecialCoordinateSystem
......
......@@ -41,6 +41,8 @@ public:
virtual ~UnknownFrame();
std::string name() const;
bool canConvertTo(const Mantid::Kernel::MDUnit &otherUnit) const;
bool isQ() const;
bool isSameType(const MDFrame& frame) const;
Mantid::Kernel::UnitLabel getUnitLabel() const;
const Mantid::Kernel::MDUnit &getMDUnit() const;
Mantid::Kernel::SpecialCoordinateSystem
......
......@@ -42,5 +42,17 @@ GeneralFrame::equivalientSpecialCoordinateSystem() const {
return Mantid::Kernel::SpecialCoordinateSystem::None;
}
bool GeneralFrame::isQ() const { return false; }
bool GeneralFrame::isSameType(const MDFrame &frame) const {
auto isSameType = true;
try {
dynamic_cast<const GeneralFrame &>(frame);
} catch (std::bad_cast &) {
isSameType = false;
}
return isSameType;
}
} // namespace Geometry
} // namespace Mantid
......@@ -69,5 +69,16 @@ HKL::equivalientSpecialCoordinateSystem() const {
return Mantid::Kernel::SpecialCoordinateSystem::HKL;
}
bool HKL::isQ() const { return true; }
bool HKL::isSameType(const MDFrame &frame) const {
auto isSameType = true;
try {
dynamic_cast<const HKL &>(frame);
} catch (std::bad_cast &) {
isSameType = false;
}
return isSameType;
}
} // namespace Geometry
} // namespace Mantid
......@@ -40,5 +40,19 @@ QLab::equivalientSpecialCoordinateSystem() const {
return Mantid::Kernel::SpecialCoordinateSystem::QLab;
}
bool QLab::isQ() const {
return true;
}
bool QLab::isSameType(const MDFrame& frame) const {
auto isSameType = true;
try {
dynamic_cast<const QLab&>(frame);
} catch (std::bad_cast&) {
isSameType = false;
}
return isSameType;
}
} // namespace Geometry
} // namespace Mantid
......@@ -35,5 +35,17 @@ QSample::equivalientSpecialCoordinateSystem() const {
return Mantid::Kernel::SpecialCoordinateSystem::QSample;
}
bool QSample::isQ() const { return true; }
bool QSample::isSameType(const MDFrame &frame) const {
auto isSameType = true;
try {
dynamic_cast<const QSample &>(frame);
} catch (std::bad_cast &) {
isSameType = false;
}
return isSameType;
}
} // namespace Geometry
} // namespace Mantid
......@@ -35,5 +35,20 @@ UnknownFrame::equivalientSpecialCoordinateSystem() const {
UnknownFrame *UnknownFrame::clone() const {
return new UnknownFrame(std::unique_ptr<Kernel::MDUnit>(m_unit->clone()));
}
bool UnknownFrame::isQ() const{
return false;
}
bool UnknownFrame::isSameType(const MDFrame &frame) const {
auto isSameType = true;
try {
dynamic_cast<const UnknownFrame &>(frame);
} catch (std::bad_cast &) {
isSameType = false;
}
return isSameType;
}
}
}
......@@ -152,8 +152,18 @@ protected:
bool m_NormalizeBasisVectors;
private:
//Mantid::Geometry::MDFrame_uptr createMDFrameForNonAxisAligned(std::string units) const;
Mantid::Geometry::MDFrame_uptr
createMDFrameForNonAxisAligned(std::string units,
Mantid::Kernel::VMD basisVector) const;
std::vector<Mantid::Kernel::VMD> getOldBasis(size_t dimension) const;
bool isProjectingOnFrame(const Mantid::Kernel::VMD &oldVector,
const Mantid::Kernel::VMD &basisVector) const;
std::vector<size_t> getIndicesWithProjection(
const Mantid::Kernel::VMD &basisVector,
const std::vector<Mantid::Kernel::VMD> &oldBasis) const;
Mantid::Geometry::MDFrame_uptr
extractMDFrameForNonAxisAligned(std::vector<size_t> indicesWithProjection,
std::string units) const;
};
} // namespace DataObjects
......
......@@ -39,9 +39,10 @@ void MDEventWSWrapper::createEmptyEventWS(const MDWSDescription &description) {
Mantid::coord_t(description.getDimMax()[d]), nBins);
} else {
Mantid::Geometry::GeneralFrame frame(description.getDimNames()[d],
description.getDimUnits()[d]);
dim = new Geometry::MDHistoDimension(
description.getDimNames()[d], description.getDimIDs()[d],
description.getDimUnits()[d],
description.getDimNames()[d], description.getDimIDs()[d], frame,
Mantid::coord_t(description.getDimMin()[d]),
Mantid::coord_t(description.getDimMax()[d]), nBins);
}
......
......@@ -251,11 +251,11 @@ void SlicingAlgorithm::makeBasisVectorFromString(const std::string &str) {
std::string units = Strings::strip(strs[0]);
// Create the appropriate frame
//auto frame = createMDFrame(units);
auto frame = createMDFrameForNonAxisAligned(units, basis);
// Create the output dimension
MDHistoDimension_sptr out(
new MDHistoDimension(name, id, units, static_cast<coord_t>(min),
new MDHistoDimension(name, id, *frame, static_cast<coord_t>(min),
static_cast<coord_t>(max), numBins));
// Put both in the algo for future use
......@@ -513,7 +513,7 @@ void SlicingAlgorithm::makeAlignedDimensionFromString(const std::string &str) {
// Copy the dimension name, ID and units
IMDDimension_const_sptr inputDim = m_inWS->getDimension(dim_index);
const auto& frame = inputDim->getMDFrame();
const auto &frame = inputDim->getMDFrame();
m_binDimensions.push_back(MDHistoDimension_sptr(
new MDHistoDimension(inputDim->getName(), inputDim->getDimensionId(),
frame, min, max, numBins)));
......@@ -1006,18 +1006,97 @@ SlicingAlgorithm::getImplicitFunctionForChunk(const size_t *const chunkMin,
}
}
#if 0
/**
* Create an MDFrame for the Non-Axis-Aligned case
* 1. Check that Q-based frames are not mixed with non-Q-based frames
* 2. Select Q-based frame if available
* Create an MDFrame for the Non-Axis-Aligned case. Make sure that
* MDFrames onto which the basis vector projects are not mixed, e.g. no mixing
* of HKL and GenerFrame
* @param units: the units
* @param basisVector: the basis vector
* @returns the unique pointer
*/
Mantid::Geometry::MDFrame_uptr SlicingAlgorithm::createMDFrameForNonAxisAligned(std::string units) const {
Mantid::Geometry::MDFrame_uptr SlicingAlgorithm::createMDFrameForNonAxisAligned(
std::string units, Mantid::Kernel::VMD basisVector) const {
// Get set of basis vectors
auto oldBasis = getOldBasis(m_inWS->getNumDims());
// Get indices onto which the vector projects
auto indicesWithProjection = getIndicesWithProjection(basisVector, oldBasis);
// Extract MDFrame
return extractMDFrameForNonAxisAligned(indicesWithProjection, units);
}
std::vector<Mantid::Kernel::VMD>
SlicingAlgorithm::getOldBasis(size_t dimension) const {
std::vector<Mantid::Kernel::VMD> oldBasis;
for (size_t i = 0; i < dimension; ++i) {
Mantid::Kernel::VMD basisVector(dimension);
basisVector[i] = 1.0;
oldBasis.push_back(basisVector);
}
return oldBasis;
}
/**
* Check if the two vectors are orthogonal or not
* @param oldVector: the old vector
* @param basisVector: the vector under investigation
* @returns true if there is a projection else false
*/
bool SlicingAlgorithm::isProjectingOnFrame(
const Mantid::Kernel::VMD &oldVector,
const Mantid::Kernel::VMD &basisVector) const {
return std::fabs(oldVector.scalar_prod(basisVector)) > 0.0;
}
/**
* Get indices which have a projection contribution
* @param basisVector: the vector under investigation
* @param oldBasis: the old basis vectors
* @returns the indices of vectors onto which the basisVector projects
*/
std::vector<size_t> SlicingAlgorithm::getIndicesWithProjection(
const Mantid::Kernel::VMD &basisVector,
const std::vector<Mantid::Kernel::VMD> &oldBasis) const {
std::vector<size_t> indexWithProjection;
for (size_t index = 0; index < oldBasis.size(); ++index) {
if (isProjectingOnFrame(oldBasis[index], basisVector)) {
indexWithProjection.push_back(index);
}
}
return indexWithProjection;
}
/**
* Extract the MDFrame. Make sure that all MDFrames are compatible -- if not
* throw
* @param indicesWithProjection: list of indices of dimensions which have a
* projection
* @param units: the units
*/
Mantid::Geometry::MDFrame_uptr
SlicingAlgorithm::extractMDFrameForNonAxisAligned(
std::vector<size_t> indicesWithProjection, std::string units) const {
if (indicesWithProjection.empty()) {
throw std::runtime_error("Slicing Algorithm: Chosen vector does not "
"project on any vector of the old basis.");
}
// Get a reference frame to perform pairwise comparison
const auto& referenceMDFrame =
m_inWS->getDimension(indicesWithProjection[0])->getMDFrame();
for (auto it = indicesWithProjection.begin();
it != indicesWithProjection.end(); ++it) {
const auto& toCheckMDFrame = m_inWS->getDimension(*it)->getMDFrame();
if (!referenceMDFrame.isSameType(toCheckMDFrame)) {
throw std::runtime_error("Slicing Algorithm: New basis yvector tries to "
"mix un-mixable MDFrame types.");
}
}
Mantid::Geometry::MDFrame_uptr mdFrame(referenceMDFrame.clone());
return mdFrame;
}
#endif
} // namespace Mantid
} // namespace DataObjects
......@@ -4,9 +4,11 @@
#include "MantidKernel/VMD.h"
#include "MantidGeometry/MDGeometry/IMDDimension.h"
#include "MantidGeometry/MDGeometry/MDImplicitFunction.h"
#include "MantidGeometry/MDGeometry/QSample.h"
#include "MantidMDAlgorithms/SlicingAlgorithm.h"
#include "MantidTestHelpers/MDEventsTestHelper.h"
#include "MantidKernel/MDUnit.h"
#include "MantidKernel/UnitLabel.h"
#include <cxxtest/TestSuite.h>
using namespace Mantid::API;
......@@ -48,6 +50,8 @@ public:
IMDEventWorkspace_sptr ws3;
IMDEventWorkspace_sptr ws4;
IMDEventWorkspace_sptr ws5;
IMDEventWorkspace_sptr wsQSample;
IMDEventWorkspace_sptr wsMixedFrames;
IMDEventWorkspace_sptr ws_names;
SlicingAlgorithmTest() {
......@@ -57,6 +61,19 @@ public:
ws3 = MDEventsTestHelper::makeMDEW<3>(5, 0.0, 10.0, 1);
ws4 = MDEventsTestHelper::makeMDEW<4>(5, 0.0, 10.0, 1);
ws5 = MDEventsTestHelper::makeMDEW<5>(5, 0.0, 10.0, 1);
// Workspace with QSample frames
Mantid::Geometry::QSample qSampleFrame;
wsQSample = MDEventsTestHelper::makeMDEWWithFrames<3>(5, 0.0, 10.0,
qSampleFrame, 1);
// Workspace with mixed frames
std::vector<Mantid::Geometry::MDFrame_sptr> frames;
frames.push_back(std::make_shared<Mantid::Geometry::QSample>());
frames.push_back(std::make_shared<Mantid::Geometry::QSample>());
frames.push_back(std::make_shared<Mantid::Geometry::QSample>());
frames.push_back(std::make_shared<Mantid::Geometry::GeneralFrame>(
Mantid::Geometry::GeneralFrame::GeneralFrameDistance, "m"));
wsMixedFrames = MDEventsTestHelper::makeMDEWWithIndividualFrames<4>(
5, 0.0, 10.0, frames, 1);
/// Workspace with custom names
ws_names = MDEventsTestHelper::makeAnyMDEW<MDEvent<3>, 3>(
3, 0.0, 10.0, 1, "", "[%dh,k,l]", "Q%d");
......@@ -95,7 +112,7 @@ public:
alg.makeAlignedDimensionFromString("Axis0, 11.0, 9.0"));
}
void test_makeAlignedDimensionFromString() {
void test_makeAlignedDimensionFromString() {
SlicingAlgorithmImpl alg;
alg.m_inWS = ws;
TSM_ASSERT_THROWS_NOTHING(
......@@ -112,6 +129,28 @@ public:
TS_ASSERT_EQUALS(dim->getX(10), 9.0);
}
void test_makeAlignedDimensionFromStringWithMDFrameSetToQSample() {
SlicingAlgorithmImpl alg;
alg.m_inWS = wsQSample;
TSM_ASSERT_THROWS_NOTHING(
"", alg.makeAlignedDimensionFromString("Axis2, 1.0, 9.0, 10"));
TS_ASSERT_EQUALS(alg.m_dimensionToBinFrom.size(), 1);
TS_ASSERT_EQUALS(alg.m_binDimensions.size(), 1);
TS_ASSERT_EQUALS(alg.m_dimensionToBinFrom[0], 2);
IMDDimension_sptr dim = alg.m_binDimensions[0];
TS_ASSERT_EQUALS(dim->getName(), "Axis2");
TS_ASSERT_EQUALS(
dim->getUnits(),
Mantid::Kernel::InverseAngstromsUnit().getUnitLabel().ascii());
TSM_ASSERT_THROWS_NOTHING(
"Should be a QSample",
dynamic_cast<const Mantid::Geometry::QSample &>(dim->getMDFrame()))
TS_ASSERT_EQUALS(dim->getNBins(), 10);
TS_ASSERT_EQUALS(dim->getX(10), 9.0);
}
/// Dimension name is of style "[x,y,z]". Handle this.
void test_makeAlignedDimensionFromString_NameWithCommas() {
SlicingAlgorithmImpl alg;
......@@ -373,7 +412,8 @@ public:
TS_ASSERT_EQUALS(alg.m_bases[0], basis);
IMDDimension_sptr dim = alg.m_binDimensions[0];
TS_ASSERT_EQUALS(dim->getName(), "name");
TS_ASSERT_EQUALS(dim->getUnits(), "units");
TSM_ASSERT("The units selection is ignored", dim->getUnits() != "units");
TSM_ASSERT("The unit is in m", dim->getUnits() == "m");
TS_ASSERT_EQUALS(dim->getNBins(), 20);
TS_ASSERT_EQUALS(dim->getMinimum(), -5);
TS_ASSERT_EQUALS(dim->getMaximum(), +5);
......@@ -397,6 +437,68 @@ public:
}
}
void test_makeBasisVectorFromStringWithPureQSampleInput() {
// Test WITH and WITHOUT basis vector normalization
for (int normalize = 0; normalize < 2; normalize++) {
SlicingAlgorithmImpl alg;
alg.m_inWS = wsQSample; // All dimensions are QSample
// Set up data that comes from other properties
alg.m_minExtents.push_back(-5.0);
alg.m_maxExtents.push_back(+5.0);
alg.m_numBins.push_back(20);
alg.m_NormalizeBasisVectors = (normalize > 0);
TS_ASSERT_EQUALS(alg.m_bases.size(), 0);
TSM_ASSERT_THROWS_NOTHING(
"", alg.makeBasisVectorFromString(" name, units , 1,2,3"));
TS_ASSERT_EQUALS(alg.m_bases.size(), 1);
TS_ASSERT_EQUALS(alg.m_binDimensions.size(), 1);
TS_ASSERT_EQUALS(alg.m_binningScaling.size(), 1);
TS_ASSERT_EQUALS(alg.m_transformScaling.size(), 1);
VMD basis(1., 2., 3.);
if (alg.m_NormalizeBasisVectors)
basis.normalize();
TS_ASSERT_EQUALS(alg.m_bases[0], basis);
IMDDimension_sptr dim = alg.m_binDimensions[0];
TS_ASSERT_EQUALS(dim->getName(), "name");
TSM_ASSERT("The units selection is ignored", dim->getUnits() != "units");
TS_ASSERT_EQUALS(
dim->getUnits(),
Mantid::Kernel::InverseAngstromsUnit().getUnitLabel().ascii());
TSM_ASSERT_THROWS_NOTHING(
"Should be a QSample",
dynamic_cast<const Mantid::Geometry::QSample &>(dim->getMDFrame()))
TS_ASSERT_EQUALS(dim->getNBins(), 20);
TS_ASSERT_EQUALS(dim->getMinimum(), -5);
TS_ASSERT_EQUALS(dim->getMaximum(), +5);
TS_ASSERT_DELTA(dim->getX(5), -2.5, 1e-5);
if (alg.m_NormalizeBasisVectors) {
TSM_ASSERT_DELTA("Unit transformation scaling if normalizing",
alg.m_transformScaling[0], 1.0, 1e-5);
TSM_ASSERT_DELTA("A bin ranges from 0-0.5 in OUTPUT, which is 0.5 long "
"in the INPUT, "
"so the binningScaling is 2.",
alg.m_binningScaling[0], 2., 1e-5);
} else {
TSM_ASSERT_DELTA("Length sqrt(14) in INPUT = 1.0 in output",
alg.m_transformScaling[0], sqrt(1.0 / 14.0), 1e-5);
TSM_ASSERT_DELTA("A bin ranges from 0-0.5 in OUTPUT, which is "
"0.5/sqrt(14) long in the INPUT, "
"so the binningScaling is 2/sqrt(14)",
alg.m_binningScaling[0], 2. / sqrt(14.0), 1e-5);
}
}
}
/// Create a basis vector with a dimension with [commas,etc] in the name.
void test_makeBasisVectorFromString_NameWithCommas() {
SlicingAlgorithmImpl alg;
......@@ -424,7 +526,8 @@ public:
IMDDimension_sptr dim = alg.m_binDimensions[0];
TS_ASSERT_EQUALS(dim->getName(), "[Dumb,Name]");
TS_ASSERT_EQUALS(dim->getDimensionId(), "[Dumb,Name]");
TS_ASSERT_EQUALS(dim->getUnits(), "units");
TSM_ASSERT("The units selection is ignored", dim->getUnits() != "units");
TSM_ASSERT("The unit is in m", dim->getUnits() == "m");
TS_ASSERT_EQUALS(dim->getNBins(), 20);
TS_ASSERT_EQUALS(dim->getMinimum(), -5);
TS_ASSERT_EQUALS(dim->getMaximum(), +5);
......@@ -627,6 +730,23 @@ public:
TS_ASSERT(!func->isPointContained(VMD(1.5, 1.5, 1.5, 11.5)));
}
void test_createGeneralTransform_4D_to_4D_with_mixed_frames() {
SlicingAlgorithmImpl *alg = do_createGeneralTransform(
wsMixedFrames, "OutX, m, 1,0,0,0", "OutY, m, 0,1,0,0", "OutZ, m, 0,0,1,0",
"OutE,m, 0,0,0,1", VMD(1, 1, 1, 1), "0,10,0,10,0,10,0,10", "5,5,5,5");
TS_ASSERT_EQUALS(alg->m_bases.size(), 4);
// The implicit function
MDImplicitFunction *func(NULL);
TS_ASSERT_THROWS_NOTHING(func =
alg->getImplicitFunctionForChunk(NULL, NULL));
TS_ASSERT(func);
TS_ASSERT_EQUALS(func->getNumPlanes(), 8);
TS_ASSERT(func->isPointContained(VMD(1.5, 1.5, 1.5, 1.5)));
TS_ASSERT(!func->isPointContained(VMD(1.5, 1.5, 1.5, -1.5)));
TS_ASSERT(!func->isPointContained(VMD(1.5, 1.5, 1.5, 11.5)));
}
/** 4D "left-handed" coordinate system
* obtained by flipping the Y basis vector. */
void test_createGeneralTransform_4D_to_4D_LeftHanded() {
......
......@@ -297,8 +297,9 @@ MDHistoDimension_sptr LoadFlexiNexus::makeDimension(NeXus::File *fin, int index,
min = tmp;
g_log.notice("WARNING: swapped axis values on " + name);
}
Mantid::Geometry::GeneralFrame frame(name, "");
return MDHistoDimension_sptr(
new MDHistoDimension(name, name, "", min, max, length));
new MDHistoDimension(name, name, frame, min, max, length));
}
void LoadFlexiNexus::addMetaData(NeXus::File *fin, Workspace_sptr ws,
ExperimentInfo_sptr info) {
......
......@@ -65,6 +65,8 @@ public:
TS_ASSERT_DELTA(dimi->getMinimum(), -86, .1);
TS_ASSERT_DELTA(dimi->getMaximum(), 84.65, .1);
// test some meta data
std::string title = data->getTitle();
size_t found = title.find("Selene");
......
......@@ -75,6 +75,26 @@ void addMDDimensionsWithFrames(
out->initialize();
}
template <typename MDE, size_t nd>
void addMDDimensionsWithIndividualFrames(
boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> out,
Mantid::coord_t min, Mantid::coord_t max,
std::vector<Mantid::Geometry::MDFrame_sptr> frame,
std::string axisNameFormat, std::string axisIdFormat) {
for (size_t d = 0; d < nd; d++) {
char name[200];
sprintf(name, axisNameFormat.c_str(), d);
char id[200];
sprintf(id, axisIdFormat.c_str(), d);
// Use the same frame for all dimensions
auto dim = boost::make_shared<Mantid::Geometry::MDHistoDimension>(
std::string(name), std::string(id), *frame[d], min, max, 10);
out->addDimension(dim);
}
out->initialize();
}
template <typename MDE, size_t nd>
void addData(
boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>> out,
......@@ -197,6 +217,47 @@ makeAnyMDEW(size_t splitInto, coord_t min, coord_t max,
return out;
}
/** Create a test MDEventWorkspace<nd> . Dimensions are names Axis0, Axis1, etc.
* But you can set an MDFrame. The frames can be set individually.
*
* @param splitInto :: each dimension will split into this many subgrids
* @param min :: extent of each dimension (min)
* @param max :: extent of each dimension (max)
* @param frames:: the chosen frame
* @param numEventsPerBox :: will create one MDLeanEvent in the center of each
*sub-box.
* 0 = don't split box, don't add events
* @param wsName :: if specified, then add the workspace to the analysis data
*service
* @param axisNameFormat :: string for the axis name, processed via sprintf()
* @param axisIdFormat :: string for the axis ID, processed via sprintf()
* @return shared ptr to the created workspace
*/
template <typename MDE, size_t nd>
boost::shared_ptr<Mantid::DataObjects::MDEventWorkspace<MDE, nd>>
makeAnyMDEWWithIndividualFrames(size_t splitInto, coord_t min, coord_t max,
std::vector<Mantid::Geometry::MDFrame_sptr>frames,
size_t numEventsPerBox = 0, std::string wsName = "",
std::string axisNameFormat = "Axis%d",
std::string axisIdFormat = "Axis%d") {
// Create bare workspace
auto out = createOutputWorkspace<MDE, nd>(splitInto);
// Add standard dimensions
addMDDimensionsWithIndividualFrames<MDE, nd>(out, min, max, frames, axisNameFormat,
axisIdFormat);
// Add data
addData<MDE, nd>(out, splitInto, min, max, numEventsPerBox);
// Add to ADS on option
if (!wsName.empty())
Mantid::API::AnalysisDataService::Instance().addOrReplace(wsName, out);
return out;
}
/** Create a test MDEventWorkspace<nd> . Dimensions are names Axis0, Axis1, etc.
* But you can set an MDFrame. For now the same frame for all dimensions
* is used.
......@@ -256,6 +317,18 @@ makeMDEWWithFrames(size_t splitInto, coord_t min, coord_t max,
numEventsPerBox);
}
/** Make a MDEventWorkspace with MDLeanEvents and individual MDFrames*/
template <size_t nd>
boost::shared_ptr<MDEventWorkspace<MDLeanEvent<nd>, nd>>
makeMDEWWithIndividualFrames(size_t splitInto, coord_t min, coord_t max,
std::vector<Mantid::Geometry::MDFrame_sptr> frame,
size_t numEventsPerBox = 0) {
return makeAnyMDEWWithIndividualFrames<MDLeanEvent<nd>, nd>(splitInto, min, max, frame,
numEventsPerBox);
}
/** Make a MDEventWorkspace with MDEvents - updated to split dims by splitInto,
* not 10 */
template <size_t nd>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment