Commit e0ebb9c6 authored by Zhang, Chen's avatar Zhang, Chen
Browse files

add example code to docs

parent 1dd622f5
......@@ -174,30 +174,46 @@ where :math:`x = -\lambda / \lambda_d`.
Usage
-----
.. Example ddd
but if you cannot avoid it then the (small) files must be added to
autotestdata\UsageData and the following tag unindented
.. include:: ../usagedata-note.txt
**Example - CalculatePlaczek**
.. testcode:: CalculatePlaczekExample
# Create a host workspace
ws = CreateWorkspace(DataX=range(0,3), DataY=(0,2))
or
ws = CreateSampleWorkspace()
wsOut = CalculatePlaczek()
# Print the result
print "The output workspace has %%i spectra" %% wsOut.getNumberHistograms()
Output:
.. testoutput:: CalculatePlaczekExample
The output workspace has ?? spectra
The data files used in the following example code are available as part of the Mantid testing data.
.. code-block:: python
# Load the incident flux from file
Load(
Filename='fluxSmoothedNOM161959.nxs',
OutputWorkspace='influx',
)
# Load the input workspace
# - must have instrument
# - must have sample with valid chemical formula
Load(Filename='inputwsNOM_164109.nxs', OutputWorkspace='NOM_164109')
# Calculate first order
# NOTE: temperature is not needed for first order calculation
CalculatePlaczek(
InputWorkspace="NOM_164109",
IncidentSpectra="influx",
LambdaD=1.44,
Order=1,
ScaleByPackingFraction=False,
CrystalDensity=0.01,
OutputWorkspace="NOM_P1",
)
# Calculate first and second order
CalculatePlaczek(
InputWorkspace="NOM_164109",
IncidentSpectra="influx",
LambdaD=1.44,
Order=2,
SampleTemperature=943.15, # in Kelvin
ScaleByPackingFraction=False,
CrystalDensity=0.01,
OutputWorkspace="NOM_P2",
)
References
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment