Skip to content

Commit

Permalink
Refs #10742 veriable renaming and comments added
Browse files Browse the repository at this point in the history
  • Loading branch information
jmborr committed Dec 9, 2014
1 parent 0b002bc commit 1c9d4c6
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 8 deletions.
Expand Up @@ -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),
Expand Down Expand Up @@ -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 == '':
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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])

Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidQt/CustomInterfaces/src/Fury.cpp
Expand Up @@ -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());

Expand Down
51 changes: 49 additions & 2 deletions Code/Mantid/scripts/Inelastic/IndirectCommon.py
Expand Up @@ -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]
Expand All @@ -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')
Expand All @@ -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)
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 1c9d4c6

Please sign in to comment.