Skip to content

Commit

Permalink
Small refactoring, small docs change
Browse files Browse the repository at this point in the history
Refs #7860
  • Loading branch information
DanNixon committed Sep 11, 2014
1 parent 754fdaf commit aabc0c0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
Expand Up @@ -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()
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/docs/source/algorithms/Symmetrise-v1.rst
Expand Up @@ -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
Expand Down

0 comments on commit aabc0c0

Please sign in to comment.