diff --git a/Code/Mantid/Framework/CurveFitting/src/PlotPeakByLogValue.cpp b/Code/Mantid/Framework/CurveFitting/src/PlotPeakByLogValue.cpp index 28cc8d5afa6c61d7ff0f47701ff07e8730e33405..c38b5991d9713441752c3326f4a4961569deb4a6 100644 --- a/Code/Mantid/Framework/CurveFitting/src/PlotPeakByLogValue.cpp +++ b/Code/Mantid/Framework/CurveFitting/src/PlotPeakByLogValue.cpp @@ -26,6 +26,7 @@ #include "MantidAPI/CompositeFunction.h" #include "MantidAPI/TableRow.h" #include "MantidAPI/ITableWorkspace.h" +#include "MantidAPI/BinEdgeAxis.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/MandatoryValidator.h" @@ -227,7 +228,13 @@ void PlotPeakByLogValue::exec() { double logValue = 0; if (logName.empty()) { API::Axis *axis = data.ws->getAxis(1); - logValue = (*axis)(j); + if(dynamic_cast<BinEdgeAxis *>(axis)) { + double lowerEdge((*axis)(j)); + double upperEdge((*axis)(j+1)); + logValue = lowerEdge + (upperEdge - lowerEdge) / 2; + } + else + logValue = (*axis)(j); } else if (logName != "SourceName") { Kernel::Property *prop = data.ws->run().getLogData(logName); if (!prop) { diff --git a/Code/Mantid/Framework/CurveFitting/test/PlotPeakByLogValueTest.h b/Code/Mantid/Framework/CurveFitting/test/PlotPeakByLogValueTest.h index c94af2789dac1b146785a132707b9fb8acba2294..cc9be62a8b6aec56c8c2d4c3603c9be2f5208be9 100644 --- a/Code/Mantid/Framework/CurveFitting/test/PlotPeakByLogValueTest.h +++ b/Code/Mantid/Framework/CurveFitting/test/PlotPeakByLogValueTest.h @@ -14,6 +14,7 @@ #include "MantidAPI/ParamFunction.h" #include "MantidAPI/FunctionFactory.h" #include "MantidAPI/WorkspaceGroup.h" +#include "MantidAPI/BinEdgeAxis.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/UnitFactory.h" @@ -222,7 +223,6 @@ public: WorkspaceCreationHelper::removeWS("PlotPeakResult"); } - void testWorkspaceList_plotting_against_ws_names() { createData(); @@ -249,7 +249,32 @@ public: deleteData(); WorkspaceCreationHelper::removeWS("PlotPeakResult"); + } + + void testSpectraList_plotting_against_bin_edge_axis() + { + auto ws = createTestWorkspace(); + AnalysisDataService::Instance().add( "PLOTPEAKBYLOGVALUETEST_WS", ws ); + + PlotPeakByLogValue alg; + alg.initialize(); + alg.setPropertyValue("Input","PLOTPEAKBYLOGVALUETEST_WS,i0;PLOTPEAKBYLOGVALUETEST_WS,i1"); + alg.setPropertyValue("OutputWorkspace","PlotPeakResult"); + alg.setPropertyValue("Function","name=LinearBackground,A0=1,A1=0.3;name=Gaussian,PeakCentre=5,Height=2,Sigma=0.1"); + alg.execute(); + + TWS_type result = WorkspaceCreationHelper::getWS<TableWorkspace>("PlotPeakResult"); + TS_ASSERT_EQUALS(result->columnCount(),12); + std::vector<std::string> tnames = result->getColumnNames(); + TS_ASSERT_EQUALS(tnames.size(),12); + TS_ASSERT_EQUALS(tnames[0],"axis-1"); + + TS_ASSERT_EQUALS(result->Double(0,0),0.5); + TS_ASSERT_EQUALS(result->Double(1,0),3.0); + + WorkspaceCreationHelper::removeWS("PlotPeakResult"); + WorkspaceCreationHelper::removeWS("PLOTPEAKBYLOGVALUETEST_WS"); } void test_passWorkspaceIndexToFunction() @@ -549,6 +574,14 @@ private: } testWS->setX(0, xdata); testWS->setX(1, xdata); + + std::vector<double> edges; + edges.push_back(0.0); + edges.push_back(1.0); + edges.push_back(5.0); + BinEdgeAxis *axis = new BinEdgeAxis(edges); + testWS->replaceAxis(1, axis); + return testWS; } diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/MSDFit.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/MSDFit.py index 7285abe4f676d36f3d0c687c4fe9d785843d07b1..de147bde8f794a7a787b822a0e9c8c5def0b3e0c 100644 --- a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/MSDFit.py +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/MSDFit.py @@ -99,13 +99,18 @@ class MSDFit(DataProcessorAlgorithm): input_params = [self._input_ws + ',i%d' % i for i in xrange(self._spec_range[0], self._spec_range[1] + 1)] input_params = ';'.join(input_params) - PlotPeakByLogValue(Input=input_params, OutputWorkspace=self._output_msd_ws, - Function=function, StartX=self._x_range[0], EndX=self._x_range[1], - FitType='Sequential', CreateOutput=True) + PlotPeakByLogValue(Input=input_params, + OutputWorkspace=self._output_msd_ws, + Function=function, + StartX=self._x_range[0], + EndX=self._x_range[1], + FitType='Sequential', + CreateOutput=True) DeleteWorkspace(self._output_msd_ws + '_NormalisedCovarianceMatrices') DeleteWorkspace(self._output_msd_ws + '_Parameters') - RenameWorkspace(self._output_msd_ws, OutputWorkspace=self._output_param_ws) + RenameWorkspace(self._output_msd_ws, + OutputWorkspace=self._output_param_ws) params_table = mtd[self._output_param_ws] diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ElasticWindowMultiple.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ElasticWindowMultiple.py index 918abd99d95b19c7b6bd7e82b3ba080c29cad760..8e046158a12cc9ac8c222cf45149bc8ab9b344be 100644 --- a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ElasticWindowMultiple.py +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ElasticWindowMultiple.py @@ -209,10 +209,11 @@ class ElasticWindowMultiple(DataProcessorAlgorithm): logger.notice('Vertical axis is in run number') unit = ('Run No', 'last 3 digits') - q_ws_axis = mtd[self._q_workspace].getAxis(1) + # Create a new vertical axis for the Q and Q**2 workspaces + q_ws_axis = NumericAxis.create(len(input_workspace_names)) q_ws_axis.setUnit("Label").setLabel(unit[0], unit[1]) - q2_ws_axis = mtd[self._q2_workspace].getAxis(1) + q2_ws_axis = NumericAxis.create(len(input_workspace_names)) q2_ws_axis.setUnit("Label").setLabel(unit[0], unit[1]) # Set the vertical axis values @@ -224,6 +225,10 @@ class ElasticWindowMultiple(DataProcessorAlgorithm): q_ws_axis.setValue(idx, float(run_numbers[idx][-3:])) q2_ws_axis.setValue(idx, float(run_numbers[idx][-3:])) + # Add the new vertical axis to each workspace + mtd[self._q_workspace].replaceAxis(1, q_ws_axis) + mtd[self._q2_workspace].replaceAxis(1, q2_ws_axis) + # Process the ELF workspace if self._elf_workspace != '': logger.information('Creating ELF workspace')