43 "Any input MDWorkspace.");
45 std::vector<double> defaultScaling(1, 1.0);
47 "Scaling value multiplying each coordinate. Default "
48 "1.\nEither a single value or a list for each dimension.");
50 std::vector<double> defaultOffset(1, 0.0);
52 "Offset value to add to each coordinate. Default 0.\nEither "
53 "a single value or a list for each dimension.");
56 "Name of the output MDWorkspace.");
64template <
typename MDE,
size_t nd>
66 std::vector<API::IMDNode *> boxes;
68 ws->
getBox()->getBoxes(boxes, 1000,
false);
75 for (
int i = 0; i < static_cast<int>(boxes.size()); i++) {
93 for (
size_t i = 0; i < (arrayLength / 2); i++) {
95 array[i] = array[(arrayLength - 1) - i];
96 array[(arrayLength - 1) - i] = temp;
111 if (std::dynamic_pointer_cast<MatrixWorkspace>(inWS))
112 throw std::runtime_error(
"TransformMD can only transform a "
113 "MDHistoWorkspace or a MDEventWorkspace.");
118 clone->setProperty(
"InputWorkspace", inWS);
119 clone->executeAsChildAlg();
120 outWS = clone->getProperty(
"OutputWorkspace");
124 throw std::runtime_error(
"Invalid output workspace.");
126 size_t nd = outWS->getNumDims();
138 throw std::invalid_argument(
"Scaling argument must be either length 1 or "
139 "match the number of dimensions.");
141 throw std::invalid_argument(
"Offset argument must be either length 1 or "
142 "match the number of dimensions.");
152 histo->cacheValues();
154 for (
int i = 0; i < static_cast<int>(
m_scaling.size()); i++)
157 std::iota(std::begin(axes), std::end(axes), 0);
162 signal_t *signals = histo->mutableSignalArray();
163 signal_t *errorsSq = histo->mutableErrorSquaredArray();
167 size_t nPoints =
static_cast<size_t>(histo->getDimension(0)->getNBins());
169 for (
size_t k = 1; k < histo->getNumDims(); k++) {
170 mPoints *=
static_cast<size_t>(histo->getDimension(k)->getNBins());
173 for (
size_t j = 0; j < mPoints; j++) {
174 this->
reverse(signals + j * nPoints, nPoints);
175 this->
reverse(errorsSq + j * nPoints, nPoints);
176 this->
reverse(numEvents + j * nPoints, nPoints);
183 histo->setDisplayNormalization(inWS->displayNormalizationHisto());
192 event->splitAllIfNeeded(ts);
195 event->refreshCache();
198 event->setCoordinateSystem(inEvent->getSpecialCoordinateSystem());
202 std::vector<double> extents;
203 std::vector<std::string> names, units;
204 for (
size_t d = 0;
d < nd;
d++) {
207 extents.emplace_back(dim->getMinimum());
208 extents.emplace_back(dim->getMaximum());
209 names.emplace_back(std::string(dim->getName()));
210 units.emplace_back(dim->getUnits());
213 create_alg->setProperty(
"Dimensions",
static_cast<int>(nd));
214 create_alg->setProperty(
"EventType", event->getEventTypeName());
215 create_alg->setProperty(
"Extents", extents);
216 create_alg->setProperty(
"Names", names);
217 create_alg->setProperty(
"Units", units);
218 create_alg->setPropertyValue(
"OutputWorkspace",
"__none");
219 create_alg->executeAsChildAlg();
222 AnalysisDataService::Instance().addOrReplace(outName, event);
223 AnalysisDataService::Instance().addOrReplace(
"__none", none);
225 std::vector<int> splits;
226 for (
size_t d = 0;
d < nd;
d++) {
227 splits.emplace_back(
static_cast<int>(boxController->getSplitInto(
d)));
230 merge_alg->setPropertyValue(
"InputWorkspaces", outName +
",__none");
231 merge_alg->setProperty(
"SplitInto", splits);
232 merge_alg->setProperty(
"SplitThreshold",
static_cast<int>(boxController->getSplitThreshold()));
233 merge_alg->setProperty(
"MaxRecursionDepth", 13);
234 merge_alg->executeAsChildAlg();
235 event = merge_alg->getProperty(
"OutputWorkspace");
236 AnalysisDataService::Instance().remove(
"__none");
250 transposeMD->setProperty(
"InputWorkspace", toTranspose);
254 return std::dynamic_pointer_cast<MDHistoWorkspace>(outputWS);
#define DECLARE_ALGORITHM(classname)
static std::unique_ptr< QThreadPool > tp
#define CALL_MDEVENT_FUNCTION(funcname, workspace)
Macro that makes it possible to call a templated method for a MDEventWorkspace using a IMDEventWorksp...
#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_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_FOR_IF(condition)
Empty definitions - to enable set your complier to enable openMP.
#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.
std::string getPropertyValue(const std::string &name) const override
Get the value of a property as a string.
TypedValue getProperty(const std::string &name) const override
Get the value of a property.
virtual std::shared_ptr< Algorithm > createChildAlgorithm(const std::string &name, const double startProgress=-1., const double endProgress=-1., const bool enableLogging=true, const int &version=-1)
Create a Child Algorithm.
static void sortObjByID(std::vector< IMDNode * > &boxes)
Static method for sorting a list of MDBoxBase pointers by their file position, ascending.
Helper class for reporting progress from algorithms.
A property class for workspaces.
Templated super-class of a multi-dimensional event "box".
void transformDimensions(std::vector< double > &scaling, std::vector< double > &offset) override
Transform the dimensions contained in this box x' = x*scaling + offset.
std::shared_ptr< MDEventWorkspace< MDE, nd > > sptr
Typedef for a shared pointer of this kind of event workspace.
bool isFileBacked() const override
MDBoxBase< MDE, nd > * getBox()
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.
A Thread Pool implementation that keeps a certain number of threads running (normally,...
A First-In-First-Out Thread Scheduler.
The ThreadScheduler object defines how tasks are allocated to threads and in what order.
std::shared_ptr< IMDEventWorkspace > IMDEventWorkspace_sptr
Shared pointer to Mantid::API::IMDEventWorkspace.
std::shared_ptr< Workspace > Workspace_sptr
shared pointer to Mantid::API::Workspace
std::shared_ptr< IMDHistoWorkspace > IMDHistoWorkspace_sptr
shared pointer to Mantid::API::IMDHistoWorkspace
std::shared_ptr< IMDWorkspace > IMDWorkspace_sptr
Shared pointer to the IMDWorkspace base class.
std::shared_ptr< BoxController > BoxController_sptr
Shared ptr to BoxController.
std::shared_ptr< Algorithm > Algorithm_sptr
Typedef for a shared pointer to an Algorithm.
std::size_t numEvents(Nexus::File &file, bool &hasTotalCounts, bool &oldNeXusFileNames, const std::string &prefix, const Nexus::NexusDescriptor &descriptor)
Get the number of events in the currently opened group.
std::shared_ptr< MDHistoWorkspace > MDHistoWorkspace_sptr
A shared pointer to a MDHistoWorkspace.
std::shared_ptr< const IMDDimension > IMDDimension_const_sptr
Shared Pointer to const IMDDimension.
double signal_t
Typedef for the signal recorded in a MDBox, etc.
@ Input
An input workspace.
@ Output
An output workspace.