The PeaksWorkspace is a special Workspace that holds a list of single crystal Peak objects.
The PeaksWorkspace is a special Workspace that holds a list of single crystal Peak objects.
Creating a PeaksWorkspace
## Creating a PeaksWorkspace
-------------------------
* :ref:`FindPeaksMD <algm-FindPeaksMD>` will find peaks in reciprocal space in a :ref:`MDWorkspace <MDWorkspace>`.
* :ref:`FindPeaksMD <algm-FindPeaksMD>` will find peaks in reciprocal space in a :ref:`MDWorkspace <MDWorkspace>`.
* :ref:`FindSXPeaks <algm-FindSXPeaks>` will find peaks in detector space.
* :ref:`FindSXPeaks <algm-FindSXPeaks>` will find peaks in detector space.
...
@@ -15,16 +13,15 @@ Creating a PeaksWorkspace
...
@@ -15,16 +13,15 @@ Creating a PeaksWorkspace
* The :ref:`SaveIsawPeaks <algm-SaveIsawPeaks>` algorithm will save a PeaksWorkspace to a file.
* The :ref:`SaveIsawPeaks <algm-SaveIsawPeaks>` algorithm will save a PeaksWorkspace to a file.
* :ref:`CreatePeaksWorkspace <algm-CreatePeaksWorkspace>` will create an empty PeaksWorkspace that you can then edit.
* :ref:`CreatePeaksWorkspace <algm-CreatePeaksWorkspace>` will create an empty PeaksWorkspace that you can then edit.
Viewing a PeaksWorkspace
## Viewing a PeaksWorkspace
------------------------
* Double-click a PeaksWorkspace to see the full list of data of each Peak object.
* Double-click a PeaksWorkspace to see the full list of data of each Peak object.
* In MantidPlot, you can drag/drop a PeaksWorkspace from the list of workspaces onto the `Instrument View <http://www.mantidproject.org/MantidPlot:_Instrument_View>`__ . This will overlay the peaks onto the detector face.
* In MantidPlot, you can drag/drop a PeaksWorkspace from the list of workspaces onto the `Instrument View <http://www.mantidproject.org/MantidPlot:_Instrument_View>`__ . This will overlay the peaks onto the detector face.
* Right-click a PeaksWorkspace and select the menu to show the peak positions in 3D in the `VatesSimpleInterface <http://www.mantidproject.org/VatesSimpleInterface>`__ .
* Right-click a PeaksWorkspace and select the menu to show the peak positions in 3D in the `VatesSimpleInterface <http://www.mantidproject.org/VatesSimpleInterface_v2>`__
* In paraview, you can load a .Peaks file loader plugin to view a PeaksWorkspace.
* In paraview, you can load a .Peaks file loader plugin to view a PeaksWorkspace.
* `PeaksViewer <http://www.mantidproject.org/PeaksViewer>` in the `SliceViewer <http://www.mantidproject.org/SliceViewer>`
The Peak Object
## The Peak Object
---------------
Each peak object contains several pieces of information. Not all of them are necessary:
Each peak object contains several pieces of information. Not all of them are necessary:
...
@@ -34,14 +31,24 @@ Each peak object contains several pieces of information. Not all of them are nec
...
@@ -34,14 +31,24 @@ Each peak object contains several pieces of information. Not all of them are nec
* Goniometer rotation matrix (for finding Q in the sample frame)
* Goniometer rotation matrix (for finding Q in the sample frame)
* Integrated intensity and error (optional)
* Integrated intensity and error (optional)
* Row/column of detector (only for :ref:`RectangularDetectors <RectangularDetector>` )
* Row/column of detector (only for :ref:`RectangularDetectors <RectangularDetector>` )
* An integration shape (see below)
Using PeaksWorkspace's in Python
### The Peak Shape
--------------------------------
Each Peak object contains a PeakShape. Only the integration algorithms which act on, and return PeaksWorkspaces set the shape of the peaks. The PeakShape is owned by the Peak, not the PeaksWorkspace, so when PeaksWorkspaces are split, or concatinated, the integration shapes are unaltered. Aside from the Null Peak Shape, each peak shape contains at least the following information.
* The algorithm used to perform the integration
* The version of the algorithm used to perform the integration
* The frame in which the integration has been performed
Subtypes of PeakShape will then provide additional information. For example PeakShapeSpherical provides the radius as well as background inner, and background outer radius.
## Using PeaksWorkspace's in Python
The PeaksWorkspace and Peak objects are exposed to python.
The PeaksWorkspace and Peak objects are exposed to python.
PeaksWorkspace Python Interface
### PeaksWorkspace Python Interface
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. code-block:: python
.. code-block:: python
...
@@ -50,8 +57,7 @@ PeaksWorkspace Python Interface
...
@@ -50,8 +57,7 @@ PeaksWorkspace Python Interface
p = pws.getPeak(12)
p = pws.getPeak(12)
pws.removePeak(34)
pws.removePeak(34)
Peak Python Interface
### Peak Python Interface
~~~~~~~~~~~~~~~~~~~~~
You can get a handle to an existing peak with:
You can get a handle to an existing peak with:
...
@@ -64,7 +70,7 @@ Or you can create a new peak in this way:
...
@@ -64,7 +70,7 @@ Or you can create a new peak in this way:
.. code-block:: python
.. code-block:: python
qlab = V3D(1.23, 3.45, 2.22) # Q in the lab frame of the peak
qlab = V3D(1.23, 3.45, 2.22) # Q in the lab frame of the peak
detector_distance = 2.5 # sample-detector distance in meters
detector_distance = 2.5 # sample-detector distance in meters. Detector distances are optional. Calculated in not provided.
p = pws.createPeak(qlab, detector_distance)
p = pws.createPeak(qlab, detector_distance)
# The peak can later be added to the workspace
# The peak can later be added to the workspace
pws.addPeak(p)
pws.addPeak(p)
...
@@ -89,4 +95,4 @@ Once you have a handle on a peak "p" you have several methods to query/modify it
...
@@ -89,4 +95,4 @@ Once you have a handle on a peak "p" you have several methods to query/modify it