Skip to content
Snippets Groups Projects
Commit c1061498 authored by Roman Tolchenov's avatar Roman Tolchenov
Browse files

Re #9579. Added Usage section to ChangeBinOffset doc

parent 0eba20b3
No related merge requests found
......@@ -20,4 +20,32 @@ selectively using the IndexMin and IndexMax properties.
The output workspace will be an exact copy of the input workspace except
for the changed time bins.
Usage
-----
.. testcode:: ExOffset
import numpy as np
# Create a workspace
ws = CreateSampleWorkspace()
# Offset the time bins by 1.0
wsOffset = ChangeBinOffset(ws,Offset=1.0)
# Check the offset
x1 = ws.readX(0)
x2 = wsOffset.readX(0)
# Test that all elements of arrays x2 and x1 differ by 1.0
print np.all( x2 - x1 == 1.0 )
y1 = ws.readY(0)
y2 = wsOffset.readY(0)
# Test that arrays y2 and y1 are equal
print np.all( y2 == y1 )
.. testoutput:: ExOffset
True
True
.. categories::
......@@ -22,19 +22,26 @@ Usage
import numpy as np
# Create a workspace with some data
# Fill array x with 100 float values equally spaced in the interval [-10, 10]
x = np.linspace(-10,10,100)
# Fill array y with values of a function for each number in array x. y has the same length as x
y = 1.0 / (x**2 + 10)
# Create array e of the same length as x and fill it with ones (1.0)
e = np.ones_like(x)
# Uses the above arrays to create a workspace
ws = CreateWorkspace( x, y, e )
# Run algorithm with low number of spline coefficients
out = SplineBackground(ws, WorkspaceIndex=0, NCoeff=4)
yout = out.readY(0)
# Sum the squares of the differences of elements of arrays y and yout
print 'Fit quality is',np.sum( (y - yout)**2 )
# Increase the number of spline coefficients
out = SplineBackground(ws, WorkspaceIndex=0, NCoeff=20)
yout = out.readY(0)
# Sum the squares of the differences of elements of arrays y and yout
print 'Fit quality is',np.sum( (y - yout)**2 )
.. testoutput:: ExampleSpline
......
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