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

Refs #9568. MuonCalculateAsymmetry

Plus a small fix for it in alg. property default value display
parent cfc10eb0
No related branches found
No related tags found
No related merge requests found
...@@ -24,4 +24,54 @@ For every mode, either one or two data acquisition period workspaces can ...@@ -24,4 +24,54 @@ For every mode, either one or two data acquisition period workspaces can
be provided. PeriodOperation determines in which way period data will be be provided. PeriodOperation determines in which way period data will be
merged at the end. merged at the end.
Usage
-----
**Example - Pair asymmetry for a single period:**
.. testcode:: ExPairAsymmetry
y = [1,2,3] + [4,5,6]
x = [1,2,3] * 2
input = CreateWorkspace(x, y, NSpec=2)
output = MuonCalculateAsymmetry(FirstPeriodWorkspace = input,
OutputType = 'PairAsymmetry',
PairFirstIndex = 1,
PairSecondIndex = 0,
Alpha = 0.5)
print 'Output:', ', '.join('{:.3f}'.format(y) for y in output.readY(0))
Output:
.. testoutput:: ExPairAsymmetry
Output: 0.778, 0.667, 0.600
**Example - Group asymmetry for two periods:**
.. testcode:: ExGroupAsymmetryMultiperiod
y1 = [100,50,10]
y2 = [150,20,1]
x = [1,2,3]
input1 = CreateWorkspace(x, y1)
input2 = CreateWorkspace(x, y2)
output = MuonCalculateAsymmetry(FirstPeriodWorkspace = input1,
SecondPeriodWorkspace = input2,
PeriodOperation = '-',
OutputType = 'GroupAsymmetry',
GroupIndex = 0)
print 'Output:', ', '.join('{:.3f}'.format(y) for y in output.readY(0))
Output:
.. testoutput:: ExGroupAsymmetryMultiperiod
Output: -0.286, 0.606, 0.263
.. categories:: .. categories::
from base import BaseDirective from base import BaseDirective
import string
class PropertiesDirective(BaseDirective): class PropertiesDirective(BaseDirective):
...@@ -140,6 +141,11 @@ class PropertiesDirective(BaseDirective): ...@@ -140,6 +141,11 @@ class PropertiesDirective(BaseDirective):
# Fall-back default for anything # Fall-back default for anything
defaultstr = str(default) defaultstr = str(default)
# A special case for single-character default values (e.g. + or *, see MuonLoad). We don't
# want them to be interpreted as list items.
if len(defaultstr) == 1 and defaultstr in string.punctuation:
defaultstr = "\\" + defaultstr
# Replace the ugly default values with "Optional" # Replace the ugly default values with "Optional"
if (defaultstr == "8.9884656743115785e+307") or \ if (defaultstr == "8.9884656743115785e+307") or \
(defaultstr == "1.7976931348623157e+308") or \ (defaultstr == "1.7976931348623157e+308") or \
......
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