44 "Any input MDWorkspace.");
46 std::vector<double> defaultScaling(1, 1.0);
48 "Scaling value multiplying each coordinate. Default "
49 "1.\nEither a single value or a list for each dimension.");
51 std::vector<double> defaultOffset(1, 0.0);
53 "Offset value to add to each coordinate. Default 0.\nEither "
54 "a single value or a list for each dimension.");
57 "Name of the output MDWorkspace.");
65template <
typename MDE,
size_t nd>
67 std::vector<API::IMDNode *> boxes;
69 ws->
getBox()->getBoxes(boxes, 1000,
false);
76 for (
int i = 0; i < static_cast<int>(boxes.size()); i++) {
94 for (
size_t i = 0; i < (arrayLength / 2); i++) {
96 array[i] = array[(arrayLength - 1) - i];
97 array[(arrayLength - 1) - i] = temp;
112 if (std::dynamic_pointer_cast<MatrixWorkspace>(inWS))
113 throw std::runtime_error(
"TransformMD can only transform a "
114 "MDHistoWorkspace or a MDEventWorkspace.");
119 clone->setProperty(
"InputWorkspace", inWS);
120 clone->executeAsChildAlg();
121 outWS = clone->getProperty(
"OutputWorkspace");
125 throw std::runtime_error(
"Invalid output workspace.");
127 size_t nd = outWS->getNumDims();
139 throw std::invalid_argument(
"Scaling argument must be either length 1 or "
140 "match the number of dimensions.");
142 throw std::invalid_argument(
"Offset argument must be either length 1 or "
143 "match the number of dimensions.");
153 histo->cacheValues();
155 for (
int i = 0; i < static_cast<int>(
m_scaling.size()); i++)
158 std::iota(std::begin(axes), std::end(axes), 0);
163 signal_t *signals = histo->mutableSignalArray();
164 signal_t *errorsSq = histo->mutableErrorSquaredArray();
168 size_t nPoints =
static_cast<size_t>(histo->getDimension(0)->getNBins());
170 for (
size_t k = 1; k < histo->getNumDims(); k++) {
171 mPoints *=
static_cast<size_t>(histo->getDimension(k)->getNBins());
174 for (
size_t j = 0; j < mPoints; j++) {
175 this->
reverse(signals + j * nPoints, nPoints);
176 this->
reverse(errorsSq + j * nPoints, nPoints);
177 this->
reverse(numEvents + j * nPoints, nPoints);
184 histo->setDisplayNormalization(inWS->displayNormalizationHisto());
193 event->splitAllIfNeeded(ts);
196 event->refreshCache();
199 event->setCoordinateSystem(inEvent->getSpecialCoordinateSystem());
203 std::vector<double> extents;
204 std::vector<std::string> names, units;
205 for (
size_t d = 0;
d < nd;
d++) {
208 extents.emplace_back(dim->getMinimum());
209 extents.emplace_back(dim->getMaximum());
210 names.emplace_back(std::string(dim->getName()));
211 units.emplace_back(dim->getUnits());
214 create_alg->setProperty(
"Dimensions",
static_cast<int>(nd));
215 create_alg->setProperty(
"EventType", event->getEventTypeName());
216 create_alg->setProperty(
"Extents", extents);
217 create_alg->setProperty(
"Names", names);
218 create_alg->setProperty(
"Units", units);
219 create_alg->setPropertyValue(
"OutputWorkspace",
"__none");
220 create_alg->executeAsChildAlg();
226 std::vector<int> splits;
227 for (
size_t d = 0;
d < nd;
d++) {
228 splits.emplace_back(
static_cast<int>(boxController->getSplitInto(
d)));
231 merge_alg->setPropertyValue(
"InputWorkspaces", outName +
",__none");
232 merge_alg->setProperty(
"SplitInto", splits);
233 merge_alg->setProperty(
"SplitThreshold",
static_cast<int>(boxController->getSplitThreshold()));
234 merge_alg->setProperty(
"MaxRecursionDepth", 13);
235 merge_alg->executeAsChildAlg();
236 event = merge_alg->getProperty(
"OutputWorkspace");
251 transposeMD->setProperty(
"InputWorkspace", toTranspose);
255 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
std::shared_ptr< MDEventWorkspace< MDE, nd > > sptr
Typedef for a shared pointer of this kind of event workspace.
MDBoxBase< MDE, nd > * getBox()
bool isFileBacked() const override
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.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
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 NexusHDF5Descriptor &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.