Skip to content

Commit

Permalink
Implemented X range selection, updated docs
Browse files Browse the repository at this point in the history
Refs #7860
  • Loading branch information
DanNixon committed Sep 11, 2014
1 parent f273d23 commit 1995783
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
Expand Up @@ -59,11 +59,15 @@ def PyExec(self):
self._calculate_array_points(sample_x, sample_array_len)

# Calculate number of elements needed for new array (per spectra)
new_array_len = 2 * sample_array_len - (self._positive_min_index + self._negative_min_index) + 1
# TODO: This can be simplified a lot
new_array_len = 2 * sample_array_len - (self._positive_min_index + self._negative_min_index) - 2 * (sample_array_len - self._positive_max_index) + 1

# Calculate the position in the output array to split between the LHS reflected betwen +XMin and +XMax and
# the LHS copied frim -XMin and +XMax
output_cut_index = sample_array_len - self._positive_min_index - (sample_array_len - self._positive_max_index)

if self._verbose:
logger.notice('No. points = %d' % sample_array_len)
logger.notice('New array size = %d' % new_array_len)
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]))
Expand All @@ -79,6 +83,9 @@ def PyExec(self):
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)
logger.notice('Output array LR split index = %d' % output_cut_index)

x_unit = mtd[self._sample].getXDimension().getUnits()

# Create an empty workspace with enough storage for the new data
Expand Down Expand Up @@ -109,15 +116,15 @@ def PyExec(self):
y_out = np.zeros(new_array_len)
e_out = np.zeros(new_array_len)

# Left hand side of cut
x_out[:sample_array_len - self._positive_min_index] = -x_in[sample_array_len:self._positive_min_index:-1]
y_out[:sample_array_len - self._positive_min_index] = y_in[sample_array_len:self._positive_min_index:-1]
e_out[:sample_array_len - self._positive_min_index] = e_in[sample_array_len:self._positive_min_index:-1]
# Left hand side
x_out[:output_cut_index] = -x_in[self._positive_max_index:self._positive_min_index:-1]
y_out[:output_cut_index] = y_in[self._positive_max_index:self._positive_min_index:-1]
e_out[:output_cut_index] = e_in[self._positive_max_index:self._positive_min_index:-1]

# Right hand side of cut
x_out[sample_array_len - self._positive_min_index:] = x_in[self._negative_min_index:]
y_out[sample_array_len - self._positive_min_index:] = y_in[self._negative_min_index:]
e_out[sample_array_len - self._positive_min_index:] = e_in[self._negative_min_index:]
# Right hand side
x_out[output_cut_index:] = x_in[self._negative_min_index:self._positive_max_index]
y_out[output_cut_index:] = y_in[self._negative_min_index:self._positive_max_index]
e_out[output_cut_index:] = e_in[self._negative_min_index:self._positive_max_index]

# Set output spectrum data
mtd[temp_ws_name].setX(output_spectrum_index, x_out)
Expand Down
11 changes: 8 additions & 3 deletions Code/Mantid/docs/source/algorithms/Symmetrise-v1.rst
Expand Up @@ -10,9 +10,14 @@ Description
-----------

Symmetrise takes an asymmetric :math:`S(Q,w)` - i.e. one in which the
moduli of xmin & xmax are different. Typically xmax is > mod(xmin). A
negative value of x is chosen (Xcut) so that the curve for mod(Xcut) to
xmax is reflected and inserted for x less than the Xcut.
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.

The output curve between negative XMin and XMax is unchnaged from the sample
curve, between negative XMax and negative XMin the curve is reflected from
the sample curve between XMin and XMax.

Usage
-----
Expand Down

0 comments on commit 1995783

Please sign in to comment.