From 1c9d4c6c8bfeb7721dbef47870b53c3e8465ee80 Mon Sep 17 00:00:00 2001 From: Jose Borreguero Date: Tue, 9 Dec 2014 17:05:27 -0500 Subject: [PATCH] Refs #10742 veriable renaming and comments added --- .../algorithms/WorkflowAlgorithms/Fury.py | 10 ++-- .../MantidQt/CustomInterfaces/src/Fury.cpp | 2 +- .../scripts/Inelastic/IndirectCommon.py | 51 ++++++++++++++++++- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/Fury.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/Fury.py index a8f1f1b0cd0c..aad88ea68563 100644 --- a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/Fury.py +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/Fury.py @@ -22,7 +22,7 @@ def PyInit(self): self.declareProperty(name='EnergyMin', defaultValue=-0.5, doc='Minimum energy for fit. Default=-0.5') self.declareProperty(name='EnergyMax', defaultValue=0.5, doc='Maximum energy for fit. Default=0.5') - self.declareProperty(name='NumBins', defaultValue=10, doc='Binning value (integer) for sample. Default=1') + self.declareProperty(name='NumBins', defaultValue=1, doc='Decrease total number of spectrum points by this ratio through merging of intensities from neighbouring bins. Default=1') self.declareProperty(MatrixWorkspaceProperty('ParameterWorkspace', '', direction=Direction.Output, optional=PropertyMode.Optional), @@ -76,7 +76,7 @@ def _setup(self): self._e_min = self.getProperty('EnergyMin').value self._e_max = self.getProperty('EnergyMax').value - self._num_bins = self.getProperty('NumBins').value + self._number_points_per_bin = self.getProperty('NumBins').value self._parameter_table = self.getPropertyValue('ParameterWorkspace') if self._parameter_table == '': @@ -117,8 +117,8 @@ def _calculate_parameters(self): CropWorkspace(InputWorkspace=self._sample, OutputWorkspace='__Fury_sample_cropped', Xmin=self._e_min, Xmax=self._e_max) x_data = mtd['__Fury_sample_cropped'].readX(0) number_input_points = len(x_data) - 1 - number_points_per_bin = number_input_points / self._num_bins - self._e_width = (abs(self._e_min) + abs(self._e_max)) / number_points_per_bin + num_bins = number_input_points / self._number_points_per_bin + self._e_width = (abs(self._e_min) + abs(self._e_max)) / num_bins try: instrument = mtd[self._sample].getInstrument() @@ -158,7 +158,7 @@ def _calculate_parameters(self): param_table.addColumn('float', 'Resolution') param_table.addColumn('int', 'ResolutionBins') - param_table.addRow([number_input_points, self._num_bins, number_points_per_bin, + param_table.addRow([number_input_points, self._number_points_per_bin, num_bins, self._e_min, self._e_max, self._e_width, resolution, resolution_bins]) diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Fury.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Fury.cpp index 3de005a6d887..f0f30f8741ea 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Fury.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Fury.cpp @@ -70,7 +70,7 @@ namespace IDA m_furTree->addProperty(m_properties["SampleBins"]); m_furTree->addProperty(m_properties["ResolutionBins"]); - m_dblManager->setValue(m_properties["SampleBinning"], 10); + m_dblManager->setValue(m_properties["SampleBinning"], 1); m_furTree->setFactoryForManager(m_dblManager, doubleEditorFactory()); diff --git a/Code/Mantid/scripts/Inelastic/IndirectCommon.py b/Code/Mantid/scripts/Inelastic/IndirectCommon.py index 46460de73526..bf18a33e6029 100644 --- a/Code/Mantid/scripts/Inelastic/IndirectCommon.py +++ b/Code/Mantid/scripts/Inelastic/IndirectCommon.py @@ -212,6 +212,20 @@ def PadArray(inarray,nfixed): #pad a list to specified size return outarray def CheckAnalysers(in1WS,in2WS,Verbose): + '''Check workspaces have identical analysers and reflections + + Args: + @param in1WS - first 2D workspace + @param in2WS - second 2D workspace + @param Verbose - whether to log information regarding the analysers + + Returns: + @return None + + Raises: + @exception Valuerror - workspaces have different analysers + @exception Valuerror - workspaces have different reflections + ''' ws1 = mtd[in1WS] a1 = ws1.getInstrument().getStringParameter('analyser')[0] r1 = ws1.getInstrument().getStringParameter('reflection')[0] @@ -227,6 +241,23 @@ def CheckAnalysers(in1WS,in2WS,Verbose): logger.notice('Analyser is '+a1+r1) def CheckHistZero(inWS): + '''Retrieves basic info on a worskspace + + Checks the workspace is not empty, then returns the number of histogram and + the number of X-points, which is the number of bin boundaries minus one + + Args: + @param inWS 2D workspace + + Returns: + @return nhist - number of histograms in the workspace + @return ntc - number of X-points in the first histogram, which is the number of bin + boundaries minus one. It is assumed all histograms have the same + number of X-points. + + Raises: + @exception ValueError - Worskpace has no histograms + ''' nhist = mtd[inWS].getNumberHistograms() # no. of hist/groups in WS if nhist == 0: raise ValueError('Workspace '+inWS+' has NO histograms') @@ -237,6 +268,21 @@ def CheckHistZero(inWS): return nhist,ntc def CheckHistSame(in1WS,name1,in2WS,name2): + '''Check workspaces have same number of histograms and bin boundaries + + Args: + @param in1WS - first 2D workspace + @param name1 - single-word descriptor of first 2D workspace + @param in2WS - second 2D workspace + @param name2 - single-word descriptor of second 2D workspace + + Returns: + @return None + + Raises: + Valuerror: number of histograms is different + Valuerror: number of bin boundaries in the histograms is different + ''' nhist1 = mtd[in1WS].getNumberHistograms() # no. of hist/groups in WS1 X1 = mtd[in1WS].readX(0) xlen1 = len(X1) @@ -283,8 +329,9 @@ def CheckElimits(erange,Xin): def getInstrumentParameter(ws, param_name): """Get an named instrument parameter from a workspace. - @param ws The workspace to get the instrument from. - @param param_name The name of the parameter to look up. + Args: + @param ws The workspace to get the instrument from. + @param param_name The name of the parameter to look up. """ inst = mtd[ws].getInstrument()