From aabc0c0189575328005e47a711eb86c8850577b0 Mon Sep 17 00:00:00 2001 From: Dan Nixon Date: Thu, 11 Sep 2014 12:27:14 +0100 Subject: [PATCH] Small refactoring, small docs change Refs #7860 --- .../plugins/algorithms/Symmetrise.py | 23 ++++++++----------- .../docs/source/algorithms/Symmetrise-v1.rst | 2 +- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/Symmetrise.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/Symmetrise.py index 178740b3e1ee..02a4e28019e8 100644 --- a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/Symmetrise.py +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/Symmetrise.py @@ -58,39 +58,36 @@ def PyExec(self): sample_x = mtd[self._sample].readX(0) self._calculate_array_points(sample_x, sample_array_len) - copy_lhs = sample_x[0] < -sample_x[self._positive_max_index] - if copy_lhs: + if self._negative_max_index is not None: lhs_cut_index = self._negative_max_index output_cut_index = lhs_cut_index + (self._positive_max_index - self._positive_min_index) new_array_len = output_cut_index + (sample_array_len - self._negative_min_index) + 1 else: - new_array_len = 2 * sample_array_len - (self._positive_min_index + self._negative_min_index) - (sample_array_len - self._positive_max_index) + 1 output_cut_index = sample_array_len - self._positive_min_index - (sample_array_len - self._positive_max_index) + new_array_len = 2 * sample_array_len - (self._positive_min_index + self._negative_min_index) - (sample_array_len - self._positive_max_index) + 1 if self._verbose: logger.notice('Sample array length = %d' % sample_array_len) - logger.notice('Negative X min at i=%d, x=%f' - % (self._negative_min_index, sample_x[self._negative_min_index])) logger.notice('Positive X min at i=%d, x=%f' % (self._positive_min_index, sample_x[self._positive_min_index])) + logger.notice('Negative X min at i=%d, x=%f' + % (self._negative_min_index, sample_x[self._negative_min_index])) - if self._negative_max_index is None: - logger.notice('No negative X max found') - else: - logger.notice('Negative X max at i=%d, x=%f' - % (self._negative_max_index, sample_x[self._negative_max_index])) logger.notice('Positive X max at i=%d, x=%f' % (self._positive_max_index, sample_x[self._positive_max_index])) - logger.notice('New array length = %d' % new_array_len) + if self._negative_max_index is not None: + logger.notice('Negative X max at i=%d, x=%f' + % (self._negative_max_index, sample_x[self._negative_max_index])) - if copy_lhs: logger.notice('LHS: Copy + Reflect') logger.notice('LHS cut index = %d' % lhs_cut_index) else: + logger.notice('No negative X max found') logger.notice('LHS: Reflect Only') + logger.notice('New array length = %d' % new_array_len) logger.notice('Output array LR split index = %d' % output_cut_index) x_unit = mtd[self._sample].getXDimension().getUnits() @@ -123,7 +120,7 @@ def PyExec(self): y_out = np.zeros(new_array_len) e_out = np.zeros(new_array_len) - if copy_lhs: + if self._negative_max_index is not None: # Left hand side (reflected) x_out[lhs_cut_index:output_cut_index] = -x_in[self._positive_max_index:self._positive_min_index:-1] y_out[lhs_cut_index:output_cut_index] = y_in[self._positive_max_index:self._positive_min_index:-1] diff --git a/Code/Mantid/docs/source/algorithms/Symmetrise-v1.rst b/Code/Mantid/docs/source/algorithms/Symmetrise-v1.rst index f256f0dfdabb..19e496055dfc 100644 --- a/Code/Mantid/docs/source/algorithms/Symmetrise-v1.rst +++ b/Code/Mantid/docs/source/algorithms/Symmetrise-v1.rst @@ -15,7 +15,7 @@ moduli of xmin & xmax are different. Typically xmax is > mod(xmin). Two values, XMin and XMax, are chosen to specify the section of the positive side of the curve to be reflected onto the negative side. -Depending on the input curve and EMax parameter the algorithm can behave in +Depending on the input curve and XMax parameter the algorithm can behave in two ways: Reflect Left Hand Side