Skip to content

Commit

Permalink
Refs #9584 Add examples for Stitch1D.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Jackson committed Jun 6, 2014
1 parent 7ef08b9 commit f4cb058
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Code/Mantid/docs/source/algorithms/Stitch1D-v3.rst
Expand Up @@ -22,4 +22,53 @@ The workspaces must be histogrammed. Use
:ref:`algm-ConvertToHistogram` on workspaces prior to
passing them to this algorithm.

Usage
-----
**Example - a basic example using stitch1D to stitch two workspaces together.**

.. testcode:: ExStitch1DSimple

import numpy as np

def gaussian(x, mu, sigma):
"""Creates a gaussian peak centered on mu and with width sigma."""
return (1/ sigma * np.sqrt(2 * np.pi)) * np.exp( - (x-mu)**2 / (2*sigma**2))

#create two histograms with a single peak in each one
x1 = np.arange(-1, 1, 0.02)
x2 = np.arange(0.4, 1.6, 0.02)
ws1 = CreateWorkspace(UnitX="1/q", DataX=x1, DataY=gaussian(x1[:-1], 0, 0.1)+1)
ws2 = CreateWorkspace(UnitX="1/q", DataX=x2, DataY=gaussian(x2[:-1], 1, 0.05)+1)

#stitch the histograms together
stitched, scale = Stitch1D(LHSWorkspace=ws1, RHSWorkspace=ws2, StartOverlap=0.4, EndOverlap=0.6, Params=0.02)

Output:

.. image:: /images/Stitch1D1.png
:scale: 65 %
:alt: Stitch1D output
:align: center


**Example - a practical example using reflectometry data and a scale factor.**

.. testcode:: ExStitch1DPractical

trans1 = Load('INTER00013463')
trans2 = Load('INTER00013464')

trans1_wav = CreateTransmissionWorkspaceAuto(trans1)
trans2_wav = CreateTransmissionWorkspaceAuto(trans2)

stitched_wav, y = Stitch1D(trans1_wav, trans2_wav, UseManualScaleFactor=True, ManualScaleFactor=0.85)

Output:

.. image:: /images/Stitch1D2.png
:scale: 65 %
:alt: Stitch1D output
:align: center


.. categories::
Binary file added Code/Mantid/docs/source/images/Stitch1D1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Code/Mantid/docs/source/images/Stitch1D2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f4cb058

Please sign in to comment.