47 return "Transpose the dimensions of a MDWorkspace to create a new output "
56 "An input workspace.");
58 auto axisValidator = std::make_shared<ArrayBoundedValidator<int>>();
59 axisValidator->setLower(0);
62 "Permutes the axes according to the indexes given. Zero "
63 "based indexing. Defaults to no transpose.");
66 "An output workspace.");
74 auto inWS = std::dynamic_pointer_cast<MDHistoWorkspace>(inWSProp);
76 throw std::invalid_argument(
"Expect the InputWorkspace to be a MDHistoWorkspace");
79 size_t nDimsInput = inWS->getNumDims();
80 size_t nDimsOutput = inWS->getNumDims();
81 std::vector<int> axesInts = this->
getProperty(
"Axes");
82 std::vector<size_t> axes(axesInts.begin(), axesInts.end());
86 auto axisErrors = checker.
validate();
87 if (!axisErrors.empty()) {
88 std::string
error = axisErrors.begin()->second;
89 throw std::invalid_argument(
error.c_str());
91 nDimsOutput = axes.size();
93 axes = std::vector<size_t>(nDimsOutput);
94 std::iota(axes.begin(), axes.end(), 0);
97 std::vector<coord_t> origin(nDimsOutput, 0.0);
98 std::vector<Geometry::IMDDimension_sptr> targetGeometry;
99 for (
size_t i = 0; i < nDimsOutput; ++i) {
102 targetGeometry.emplace_back(cloneDim);
107 outWS->copyExperimentInfos(*inWS);
110 std::vector<coord_t> scaling(nDimsOutput, 1);
113 uint64_t nPoints = inWS->getNPoints();
116 progress.reportIncrement(
size_t(
double(nPoints) * 0.1));
120 auto iterators = inWS->createIterators(nThreads,
nullptr);
123 for (
int it = 0; it < int(iterators.size()); ++it) {
126 auto inIterator = iterators[it].get();
128 auto center = inIterator->getCenter();
129 const coord_t *incoords = center.getBareArray();
130 std::vector<coord_t> outcoords(nDimsOutput);
131 coordTransform.
apply(incoords, &outcoords[0]);
133 size_t index = outWS->getLinearIndexAtCoord(&outcoords[0]);
134 outWS->setSignalAt(
index, inIterator->getSignal());
138 outWS->setMDMaskAt(
index, inIterator->getIsMasked());
140 }
while (inIterator->next());
#define DECLARE_ALGORITHM(classname)
std::map< DeltaEMode::Type, std::string > index
#define PARALLEL_START_INTERRUPT_REGION
Begins a block to skip processing is the algorithm has been interupted Note the end of the block if n...
#define PARALLEL_FOR_NO_WSP_CHECK()
#define PARALLEL_END_INTERRUPT_REGION
Ends a block to skip processing is the algorithm has been interupted Note the start of the block if n...
#define PARALLEL_CHECK_INTERRUPT_REGION
Adds a check after a Parallel region to see if it was interupted.
void declareProperty(std::unique_ptr< Kernel::Property > p, const std::string &doc="") override
Add a property to the list of managed properties.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
void progress(double p, const std::string &msg="", double estimatedTime=0.0, int progressPrecision=0)
Sends ProgressNotification.
Helper class for reporting progress from algorithms.
A property class for workspaces.
Support for a property that holds an array of values.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
MDAxisValidator is a class that checks the number of MD axes match the number of workspace dimensions...
virtual std::map< std::string, std::string > validate() const
Checks the MD axes given against the given number of dimensions of the input workspace.
Base class for properties.
virtual bool isDefault() const =0
Overriden function that returns if property has the same value that it was initialised with,...
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
TransposeMD : Transpose an MDWorkspace.
const std::string category() const override
Algorithm's category for identification.
void exec() override
Execute the algorithm.
int version() const override
Algorithm's version for identification.
void init() override
Initialize the algorithm's properties.
const std::string summary() const override
Algorithm's summary for use in the GUI and help.
std::shared_ptr< IMDHistoWorkspace > IMDHistoWorkspace_sptr
shared pointer to Mantid::API::IMDHistoWorkspace
std::shared_ptr< MDHistoWorkspace > MDHistoWorkspace_sptr
A shared pointer to a MDHistoWorkspace.
std::shared_ptr< IMDDimension > IMDDimension_sptr
Shared Pointer for IMDDimension. Frequently used type in framework.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...
double signal_t
Typedef for the signal recorded in a MDBox, etc.
@ Input
An input workspace.
@ Output
An output workspace.