Skip to content
Snippets Groups Projects
Commit 1990af3a authored by Antti Soininen's avatar Antti Soininen
Browse files

Simplify vertical axis binning

NumbericAxis::createBinBoundaries and BinEdgeAxis::createBinBoundaries
both do the expected binning correctly.

Re #24492
parent 59f288fe
No related merge requests found
......@@ -77,7 +77,7 @@ void Rebin2D::init() {
void Rebin2D::exec() {
// Information to form input grid
MatrixWorkspace_const_sptr inputWS = getProperty("InputWorkspace");
NumericAxis *oldAxis2 = dynamic_cast<API::NumericAxis *>(inputWS->getAxis(1));
const NumericAxis *oldAxis2 = dynamic_cast<API::NumericAxis *>(inputWS->getAxis(1));
if (!oldAxis2) {
throw std::invalid_argument(
"Vertical axis is not a numeric axis, cannot rebin. "
......@@ -87,16 +87,9 @@ void Rebin2D::exec() {
const auto &oldXEdges = inputWS->x(0);
const size_t numXBins = inputWS->blocksize();
const size_t numYBins = inputWS->getNumberHistograms();
std::vector<double> oldYEdges;
if (numYBins == oldAxis2->length()) {
// Pt data on axis 2, create bins
oldYEdges = oldAxis2->createBinBoundaries();
} else {
oldYEdges.resize(oldAxis2->length());
for (size_t i = 0; i < oldAxis2->length(); ++i) {
oldYEdges[i] = (*oldAxis2)(i);
}
}
// This will convert plain NumericAxis to bin edges while
// BinEdgeAxis will just return its edges.
const std::vector<double> oldYEdges = oldAxis2->createBinBoundaries();
// Output grid and workspace. Fills in the new X and Y bin vectors
// MantidVecPtr newXBins;
......
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