Skip to content

Commit

Permalink
Refs #9568. Create workspaces instead of loading files
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbekasov committed Jun 6, 2014
1 parent 673aca1 commit 3ccb09a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 54 deletions.
38 changes: 27 additions & 11 deletions Code/Mantid/docs/source/algorithms/AlphaCalc-v1.rst
Expand Up @@ -19,26 +19,42 @@ in a workspace use :ref:`algm-MuonGroupDetectors`.
Usage
-----

.. include:: ../usagedata-note.txt
**Example - Calculating Alpha:**

**Example - Calculating Alpha of a MUSR run:**
.. testcode:: ExSimple

.. testcode:: ExMUSRAlpha
y = [1,1,1,1,1] + [2,2,2,2,2]
x = [1,2,3,4,5,6] * 2
input = CreateWorkspace(x,y, NSpec=2)

loaded = LoadMuonNexus('MUSR0015189.nxs', AutoGroup=True)
alpha = AlphaCalc(input)

first_period = loaded[0].getItem(0)
print 'Alpha value: {:.3f}'.format(alpha)

alpha = AlphaCalc(first_period,
FirstGoodValue=0.55,
LastGoodValue=12.0)
Output:

.. testoutput:: ExSimple

Alpha value: 0.500

**Example - Calculating Alpha, reversing forward and backward spectra:**

.. testcode:: ExReversed

y = [1,1,1,1,1] + [2,2,2,2,2]
x = [1,2,3,4,5,6] * 2
input = CreateWorkspace(x,y, NSpec=2)

alpha = AlphaCalc(input,
ForwardSpectra=[2],
BackwardSpectra=[1])

print 'Alpha value of the first period: {:.3f}'.format(alpha)
print 'Alpha value: {:.3f}'.format(alpha)

Output:

.. testoutput:: ExMUSRAlpha
.. testoutput:: ExReversed

Alpha value of the first period: 1.339
Alpha value: 2.000

.. categories::
32 changes: 12 additions & 20 deletions Code/Mantid/docs/source/algorithms/AsymmetryCalc-v1.rst
Expand Up @@ -36,33 +36,25 @@ the asymmetry and the asymmetry errors.
Usage
-----

.. include:: ../usagedata-note.txt
**Example - Calculating asymmetry:**

**Example - Calculating assymetry for a MUSR run:**
.. testcode:: ExSimple

.. testcode:: ExMUSR
y = [1,2,3] + [3,6,9]
x = [1,2,3,4] * 2
e = [1,1,1] * 2
input = CreateWorkspace(x, y, e, NSpec=2)

# Load some arbitrary MUSR run
ws = LoadMuonNexus('MUSR0015189.nxs')
asymmetry = AsymmetryCalc(input, Alpha=0.5)

asymmetry = AsymmetryCalc('ws_1', # Use first period only
ForwardSpectra=range(33,65),
BackwardSpectra=range(1,33),
Alpha=1.0)

print 'No. of spectra in the resulting workspace:', asymmetry.getNumberHistograms()

output_format = 'For TOF of {:.3f} asymmetry is {:.3f} with error {:.3f}'
for i in [500, 1000, 1500]:
print output_format.format(asymmetry.readX(0)[i], asymmetry.readY(0)[i], asymmetry.readE(0)[i])
print 'Asymmetry:', ', '.join('{:.3f}'.format(y) for y in asymmetry.readY(0))
print 'Errors:', ', '.join('{:.3f}'.format(e) for e in asymmetry.readE(0))

Output:

.. testoutput:: ExMUSR
.. testoutput:: ExSimple

No. of spectra in the resulting workspace: 1
For TOF of 7.450 asymmetry is -0.045 with error 0.080
For TOF of 15.450 asymmetry is -0.333 with error 0.609
For TOF of 23.450 asymmetry is 1.000 with error 1.414
Asymmetry: -0.200, -0.200, -0.200
Errors: 0.540, 0.382, 0.312

.. categories::
32 changes: 9 additions & 23 deletions Code/Mantid/docs/source/algorithms/RemoveExpDecay-v1.rst
Expand Up @@ -22,36 +22,22 @@ fitted normalisation constant.
Usage
-----

.. include:: ../usagedata-note.txt
**Example - Removing exponential decay:**

**Example - Removing exponential decay from a MUSR run:**
.. testcode:: ExSimple

.. testcode:: ExMUSR
y = [100, 150, 50, 10, 5]
x = [1,2,3,4,5,6]
input = CreateWorkspace(x,y)

# Load first period of a MUSR run
input = LoadMuonNexus('MUSR0015189.nxs', EntryNumber=1)
output = RemoveExpDecay(input)

# Remove uninteresting bins
input = CropWorkspace('input', XMin=0.55, XMax=12)

# Remove exp. decay
output = RemoveExpDecay('input')

# Bins to compare
bins_to_compare = [0, 150, 300, 450, 600]

# Get values before&after and format them as strings for output
init_values = ["{:.3f}".format(input.readY(0)[bin]) for bin in bins_to_compare]
exp_dec_removed = ["{:.3f}".format(output.readY(0)[bin]) for bin in bins_to_compare]

print "Initial values", ", ".join(init_values)
print "Exp. decay removed:", ", ".join(exp_dec_removed)
print "Exp. decay removed:", ', '.join(['{:.3f}'.format(y) for y in output.readY(0)])

Output:

.. testoutput:: ExMUSR
.. testoutput:: ExSimple

Initial values 49.000, 17.000, 2.000, 3.000, 0.000
Exp. decay removed: 0.090, 0.127, -0.605, 0.768, -0.824
Exp. decay removed: -0.243, 0.791, -0.059, -0.703, -0.766

.. categories::

0 comments on commit 3ccb09a

Please sign in to comment.