21using namespace Kernel;
26 std::make_shared<CommonBinsValidator>()),
27 "The input workspace.");
29 "The output workspace.");
38 std::dynamic_pointer_cast<const DataObjects::RebinnedOutput>(inputWorkspace);
40 std::dynamic_pointer_cast<DataObjects::RebinnedOutput>(outputWorkspace);
42 size_t newNhist = outputWorkspace->getNumberHistograms();
43 size_t newXsize = outputWorkspace->x(0).size();
44 size_t newYsize = outputWorkspace->blocksize();
48 std::vector<double> newXValues(newXsize);
49 for (
size_t i = 0; i < newXsize; ++i) {
50 newXValues[i] = (*inputYAxis)(i);
52 auto newXVector = Kernel::make_cow<HistogramData::HistogramX>(std::move(newXValues));
55 progress.report(
"Swapping data values");
57 for (int64_t i = 0; i < static_cast<int64_t>(newNhist); ++i) {
60 outputWorkspace->setSharedX(i, newXVector);
62 auto &outY = outputWorkspace->mutableY(i);
63 auto &outE = outputWorkspace->mutableE(i);
67 std::vector<double> &outF = F.
access();
69 if (outRebinWorkspace) {
70 outF.resize(newYsize);
73 for (int64_t j = 0; j < int64_t(newYsize); ++j) {
75 outY[j] = inputWorkspace->y(j)[i];
76 outE[j] = inputWorkspace->e(j)[i];
77 if (outRebinWorkspace) {
78 outF[j] = inRebinWorkspace->dataF(j)[i];
81 if (outRebinWorkspace) {
82 outRebinWorkspace->setF(i, F);
97 const size_t oldNhist = inputWorkspace->getNumberHistograms();
98 const auto &inX = inputWorkspace->x(0);
99 const size_t oldYlength = inputWorkspace->blocksize();
100 const size_t oldVerticalAxislength = yAxis->
length();
103 size_t newNhist(oldYlength), newXsize(oldVerticalAxislength), newYsize(oldNhist);
105 outputWorkspace->initialize(newNhist, newXsize, newYsize);
106 outputWorkspace->setTitle(inputWorkspace->getTitle());
107 outputWorkspace->setComment(inputWorkspace->getComment());
108 outputWorkspace->copyExperimentInfoFrom(inputWorkspace.get());
109 outputWorkspace->setYUnit(inputWorkspace->YUnit());
110 outputWorkspace->setYUnitLabel(inputWorkspace->YUnitLabel());
111 outputWorkspace->setDistribution(inputWorkspace->isDistribution());
115 std::unique_ptr<API::NumericAxis> newYAxis(
nullptr);
116 if (inputWorkspace->isHistogramData()) {
117 newYAxis = std::make_unique<API::BinEdgeAxis>(inX.rawData());
119 newYAxis = std::make_unique<API::NumericAxis>(inX.rawData());
122 newYAxis->unit() = inputWorkspace->getAxis(0)->unit();
123 outputWorkspace->getAxis(0)->unit() = inputWorkspace->getAxis(1)->unit();
124 outputWorkspace->replaceAxis(1, std::move(newYAxis));
126 return outputWorkspace;
139 throw std::invalid_argument(
"Axis(1) not found on input workspace.");
143 throw std::invalid_argument(
"Axis(1) is a text axis. Transpose is unable to cope with text axes.");
#define DECLARE_ALGORITHM(classname)
IPeaksWorkspace_sptr workspace
#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.
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.
Class to represent the axis of a workspace.
virtual bool isText() const
Returns true if the axis is Text.
virtual std::size_t length() const =0
Get the length of the axis.
Helper class for reporting progress from algorithms.
A property class for workspaces.
void init() override
Initialisation code.
API::MatrixWorkspace_sptr createOutputWorkspace(const API::MatrixWorkspace_const_sptr &inputWorkspace)
Create the output workspace.
void exec() override
Execution code.
API::Axis * getVerticalAxis(const API::MatrixWorkspace_const_sptr &workspace) const
Return the vertical axis on the workspace, throwing if it is not valid.
Exception for index errors.
IPropertyManager * setProperty(const std::string &name, const T &value)
Templated method to set the value of a PropertyWithValue.
Implements a copy on write data template.
DataType & access()
Access function.
std::shared_ptr< const MatrixWorkspace > MatrixWorkspace_const_sptr
shared pointer to the matrix workspace base class (const version)
std::shared_ptr< MatrixWorkspace > MatrixWorkspace_sptr
shared pointer to the matrix workspace base class
std::shared_ptr< const RebinnedOutput > RebinnedOutput_const_sptr
shared pointer to a const RebinnedOutput
std::shared_ptr< RebinnedOutput > RebinnedOutput_sptr
shared pointer to the RebinnedOutput class
std::enable_if< std::is_pointer< Arg >::value, bool >::type threadSafe(Arg workspace)
Thread-safety check Checks the workspace to ensure it is suitable for multithreaded access.
@ Input
An input workspace.
@ Output
An output workspace.