Skip to content
Snippets Groups Projects
Commit 3ccb09ab authored by Arturs Bekasovs's avatar Arturs Bekasovs
Browse files

Refs #9568. Create workspaces instead of loading files

parent 673aca1c
No related branches found
No related tags found
No related merge requests found
...@@ -19,26 +19,42 @@ in a workspace use :ref:`algm-MuonGroupDetectors`. ...@@ -19,26 +19,42 @@ in a workspace use :ref:`algm-MuonGroupDetectors`.
Usage 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, Output:
FirstGoodValue=0.55,
LastGoodValue=12.0) .. 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: Output:
.. testoutput:: ExMUSRAlpha .. testoutput:: ExReversed
Alpha value of the first period: 1.339 Alpha value: 2.000
.. categories:: .. categories::
...@@ -36,33 +36,25 @@ the asymmetry and the asymmetry errors. ...@@ -36,33 +36,25 @@ the asymmetry and the asymmetry errors.
Usage 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 asymmetry = AsymmetryCalc(input, Alpha=0.5)
ws = LoadMuonNexus('MUSR0015189.nxs')
asymmetry = AsymmetryCalc('ws_1', # Use first period only print 'Asymmetry:', ', '.join('{:.3f}'.format(y) for y in asymmetry.readY(0))
ForwardSpectra=range(33,65), print 'Errors:', ', '.join('{:.3f}'.format(e) for e in asymmetry.readE(0))
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])
Output: Output:
.. testoutput:: ExMUSR .. testoutput:: ExSimple
No. of spectra in the resulting workspace: 1 Asymmetry: -0.200, -0.200, -0.200
For TOF of 7.450 asymmetry is -0.045 with error 0.080 Errors: 0.540, 0.382, 0.312
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
.. categories:: .. categories::
...@@ -22,36 +22,22 @@ fitted normalisation constant. ...@@ -22,36 +22,22 @@ fitted normalisation constant.
Usage 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 output = RemoveExpDecay(input)
input = LoadMuonNexus('MUSR0015189.nxs', EntryNumber=1)
# Remove uninteresting bins print "Exp. decay removed:", ', '.join(['{:.3f}'.format(y) for y in output.readY(0)])
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)
Output: Output:
.. testoutput:: ExMUSR .. testoutput:: ExSimple
Initial values 49.000, 17.000, 2.000, 3.000, 0.000 Exp. decay removed: -0.243, 0.791, -0.059, -0.703, -0.766
Exp. decay removed: 0.090, 0.127, -0.605, 0.768, -0.824
.. categories:: .. categories::
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment