Skip to content

Commit

Permalink
Copied in modified documents without other changes re #9762
Browse files Browse the repository at this point in the history
Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
  • Loading branch information
KarlPalmen committed Apr 28, 2015
1 parent 17bef3d commit cabebd8
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 3 deletions.
33 changes: 32 additions & 1 deletion Code/Mantid/docs/source/algorithms/ClearUB-v1.rst
Expand Up @@ -10,7 +10,38 @@ Description
-----------

Clears the OrientedLattice of each ExperimentInfo attached to the intput
:ref:`Workspace <Workspace>`. Works with both single ExperimentInfos and
`Workspace <http://www.mantidproject.org/Workspace>`_. Works with both single ExperimentInfos and
MultipleExperimentInfo instances.

Usage
-----

.. testcode:: ExClearUB

# create a workspace (or you can load one)
ws=CreateSingleValuedWorkspace(5)

#set a UB matrix using the vector along k_i as 1,1,0, and the 0,0,1 vector in the horizontal plane
SetUB(ws,a=5,b=6,c=7,alpha=90, beta=90, gamma=90, u="1,1,0", v="0,0,1")

#check that we do have a UB matrix
from numpy import *
mat=array(ws.sample().getOrientedLattice().getUB())
print "UB matrix size", mat.size

ClearUB(ws)

#check that it removed UB matrix & orientated lattice
if( ws.sample().hasOrientedLattice() ):
print "ClearUB has not removed the orientated lattice."
else:
print "ClearUB has removed the oriented lattice."

Output:

.. testoutput:: ExClearUB

UB matrix size 9
ClearUB has removed the oriented lattice.

.. categories::
Expand Up @@ -17,4 +17,30 @@ only in their phi rotation.
If the phi angles are known, this algorithm attempts to find the common
chi and omega rotations.

Usage
-----

.. include:: ../usagedata-note.txt

.. testcode:: exGoniometerAnglesFromPhiRotation

# Load Peaks found in SXD23767.raw
ws1 =Load(Filename='SXD23767.peaks')
ws2 = ws1.clone()

#Set orientated lattice
ublist = [-0.06452276, 0.2478114, -0.23742194, 0.29161678, -0.00914316, -0.12523779, 0.06958942, -0.1802702, -0.14649001]
SetUB(Workspace=ws1,UB=ublist)

# Run Algorithm
result = GoniometerAnglesFromPhiRotation(ws1,ws2,Tolerance=0.5,MIND=0,MAXD=2)

print "Chi: %.1f, Omega: %.1f, Indexed: %i, AvErrIndex: %.4f AvErrAll: %.4f" % ( result[0], result[1], result[2], result[3], result[4] )

Output:

.. testoutput:: exGoniometerAnglesFromPhiRotation

Chi: 90.0, Omega: 90.0, Indexed: 300, AvErrIndex: 0.2114 AvErrAll: 0.2114

.. categories::
25 changes: 25 additions & 0 deletions Code/Mantid/docs/source/algorithms/IndexPeaks-v1.rst
Expand Up @@ -25,4 +25,29 @@ from an integer will have its (h,k,l) set to (0,0,0). The calculated
Miller indices can either be rounded to the nearest integer value, or
can be left as decimal fractions.

Usage
-----

**Example - a simple example of IndexPeaks**

.. testcode:: ExIndexPeaksSimple

# Load Peaks found in SXD23767.raw
Load(Filename='SXD23767.peaks',OutputWorkspace='peaks_qLab')

#Set orientated lattice
ubMatrix = [-0.06452276, 0.2478114, -0.23742194, 0.29161678, -0.00914316, -0.12523779, 0.06958942, -0.1802702, -0.14649001]
SetUB('peaks_qLab',UB=ubMatrix)

# Run Algorithm
indexed =IndexPeaks(PeaksWorkspace='peaks_qLab',Tolerance=0.12,RoundHKLs=1)

print "Number of Indexed Peaks: ", indexed[0]

Output:

.. testoutput:: ExIndexPeaksSimple

Number of Indexed Peaks: 147

.. categories::
26 changes: 26 additions & 0 deletions Code/Mantid/docs/source/algorithms/MDHistoToWorkspace2D-v1.rst
Expand Up @@ -19,4 +19,30 @@ This tool is useful as many algorithms in Mantid only apply to
Workspace2D. After conversion with MDHistoToWorkspace2D such algorithms
can also be applied to MD data.

Usage
-----

**Example - Flatten a small workspace:**

.. testcode:: ExMDHistoToWorkspace2D

# Create input workspace
CreateMDWorkspace(Dimensions=3, Extents='-10,10,-10,10,-10,10', Names='A,B,C', Units='U,U,U', OutputWorkspace='demo')
FakeMDEventData(InputWorkspace='demo', PeakParams='32,0,0,0,1')
input = BinMD(InputWorkspace='demo', AlignedDim0='A,-2,2,4', AlignedDim1='B,-2,2,4', AlignedDim2='C,-2,2,4')

# Run the algorithm
output = MDHistoToWorkspace2D(InputWorkspace='input')

# print 6th group of 4 bins in both input and output workspaces
print "part of MD workspace",input.getSignalArray()[1,1]
print "corresponding part of 2D workspace",output.dataY(5)

Output:

.. testoutput:: ExMDHistoToWorkspace2D

part of MD workspace [ 0. 4. 5. 0.]
corresponding part of 2D workspace [ 0. 4. 5. 0.]

.. categories::
68 changes: 66 additions & 2 deletions Code/Mantid/docs/source/algorithms/ThresholdMD-v1.rst
Expand Up @@ -9,7 +9,71 @@
Description
-----------

Threshold an MDHistoWorkspace to overwrite values below or above the
defined threshold.
This algorithm applies a simple linear transformation to a
:ref:`MDWorkspace <MDWorkspace>` or
:ref:`MDHistoWorkspace <MDHistoWorkspace>`. This could be used, for
example, to scale the Energy dimension to different units.

Each coordinate is tranformed so that :math:`x'_d = (x_d * s_d) + o_d`
where:

- d : index of the dimension, from 0 to the number of dimensions
- s : value of the Scaling parameter
- o : value of the Offset parameter.

You can specify either a single value for Scaling and Offset, in which
case the same m\_scaling or m\_offset are applied to each dimension; or
you can specify a list with one entry for each dimension.

Notes
#####

The relationship between the workspace and the original
:ref:`MDWorkspace <MDWorkspace>`, for example when the MDHistoWorkspace is
the result of :ref:`algm-BinMD`, is lost. This means that you cannot
re-bin a transformed :ref:`MDHistoWorkspace <MDHistoWorkspace>`.

No units are not modified by this algorithm.

Performance Notes
#################

- Performing the operation in-place (input=output) is always faster
because the first step of the algorithm if NOT in-place is to clone
the original workspace.
- For :ref:`MDHistoWorkspaces <MDHistoWorkspace>` done in-place,
TransformMD is very quick (no data is modified, just the
coordinates).
- For :ref:`MDWorkspaces <MDWorkspace>`, every event's coordinates gets
modified, so this may take a while for large workspaces.
- For file-backed :ref:`MDWorkspaces <MDWorkspace>`, you will find much
better performance if you perform the change in-place (input=output),
because the data gets written out to disk twice otherwise.

Usage
-----

**Example - Threshold a small workspace:**

.. testcode:: ExThresholdMD

# Create input workspace
CreateMDWorkspace(Dimensions=3, Extents='-10,10,-10,10,-10,10', Names='A,B,C', Units='U,U,U', OutputWorkspace='demo')
FakeMDEventData(InputWorkspace='demo', PeakParams='32,0,0,0,1')
threshold_input = BinMD(InputWorkspace='demo', AlignedDim0='A,-2,2,4', AlignedDim1='B,-2,2,4', AlignedDim2='C,-2,2,4')

# Run the algorithm to set all values greater than 4 to zero
threshold_output = ThresholdMD(InputWorkspace='threshold_input', Condition='Greater Than', ReferenceValue=4)

# Print selection before and after
print "selected bins before threshold greater than 4",threshold_input.getSignalArray()[1,1]
print "same bins after threshold greater than 4",threshold_output.getSignalArray()[1,1]

Output:

.. testoutput:: ExThresholdMD

selected bins before threshold greater than 4 [ 0. 4. 5. 0.]
same bins after threshold greater than 4 [ 0. 4. 0. 0.]

.. categories::

0 comments on commit cabebd8

Please sign in to comment.