Skip to content

Commit

Permalink
Fix issue with vertical axis
Browse files Browse the repository at this point in the history
Refs #11873
  • Loading branch information
DanNixon committed Jun 2, 2015
1 parent 39ae55d commit 12fd479
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Expand Up @@ -66,8 +66,9 @@ class DLLExport SplineInterpolation : public API::Algorithm {

/// setup an output workspace using meta data from inws and taking a number of
/// spectra
API::MatrixWorkspace_sptr setupOutputWorkspace(API::MatrixWorkspace_sptr inws,
int size) const;
API::MatrixWorkspace_sptr
setupOutputWorkspace(API::MatrixWorkspace_sptr mws,
API::MatrixWorkspace_sptr iws) const;

/// convert a binned workspace to point data. Uses mean of the bins as point
API::MatrixWorkspace_sptr
Expand Down
25 changes: 18 additions & 7 deletions Code/Mantid/Framework/CurveFitting/src/SplineInterpolation.cpp
@@ -1,4 +1,5 @@
#include "MantidAPI/TextAxis.h"
#include "MantidAPI/NumericAxis.h"
#include "MantidAPI/Progress.h"
#include "MantidKernel/BoundedValidator.h"
#include "MantidCurveFitting/SplineInterpolation.h"
Expand Down Expand Up @@ -90,7 +91,7 @@ void SplineInterpolation::exec() {
MatrixWorkspace_sptr mwspt = convertBinnedData(mws);
MatrixWorkspace_const_sptr iwspt = convertBinnedData(iws);

MatrixWorkspace_sptr outputWorkspace = setupOutputWorkspace(mws, histNo);
MatrixWorkspace_sptr outputWorkspace = setupOutputWorkspace(mws, iws);

Progress pgress(this, 0.0, 1.0, histNo);

Expand All @@ -107,12 +108,17 @@ void SplineInterpolation::exec() {

// check if we want derivatives
if (order > 0) {
derivs[i] = WorkspaceFactory::Instance().create(mws, order);
NumericAxis *vAxis = new API::NumericAxis(order);

// calculate the derivatives for each order chosen
derivs[i] = setupOutputWorkspace(mws, order);
for (int j = 0; j < order; ++j) {
vAxis->setValue(j, j + 1);
derivs[i]->setX(j, mws->readX(0));
calculateDerivatives(mwspt, derivs[i], j + 1);
}

derivs[i]->replaceAxis(1, vAxis);
}

pgress.report();
Expand All @@ -136,15 +142,20 @@ void SplineInterpolation::exec() {
*it with the desired number of spectra.
* Also labels the axis of each spectra with Yi, where i is the index
*
* @param inws :: The input workspace
* @param size :: The number of spectra the workspace should be created with
* @param mws :: The input workspace to match
* @param iws :: The input workspace to interpolate
* @return The pointer to the newly created workspace
*/
API::MatrixWorkspace_sptr
SplineInterpolation::setupOutputWorkspace(API::MatrixWorkspace_sptr inws,
int size) const {
SplineInterpolation::setupOutputWorkspace(API::MatrixWorkspace_sptr mws,
API::MatrixWorkspace_sptr iws) const {
size_t numSpec = iws->getNumberHistograms();
MatrixWorkspace_sptr outputWorkspace =
WorkspaceFactory::Instance().create(inws, size);
WorkspaceFactory::Instance().create(mws, numSpec);

// Use the vertical axis form the workspace to interpolate on the output WS
Axis *vAxis = iws->getAxis(1);
outputWorkspace->replaceAxis(1, vAxis);

return outputWorkspace;
}
Expand Down

0 comments on commit 12fd479

Please sign in to comment.