Skip to content
Snippets Groups Projects
CreatePeaksWorkspace-v1.rst 1.73 KiB
Newer Older
.. relatedalgorithms::
Zhang, Chen's avatar
Zhang, Chen committed
This algorithm can be used to create a:

- :ref:`PeaksWorkspace <PeaksWorkspace>` (Default, or when `OutputType` is set to `Peak`.)
- :ref:`LeanElasticPeaksWorkspace <LeanElasticPeaksWorkspace>` (when `OutputType` is set to `LeanElasticPeak`)

Use :ref:`algm-LoadIsawPeaks` or :ref:`algm-FindPeaksMD` to
create a peaks workspace with peaks.

This workspace can serve as a starting point for modifying the
:ref:`PeaksWorkspace <PeaksWorkspace>`, using the GUI or python scripting,
If the input workspace is a MDWorkspace then the instrument from the
first experiment info is used.

Usage
-----

Zhang, Chen's avatar
Zhang, Chen committed
**Example: An empty table, not tied to an instrument**

.. testcode:: ExEmptyPeaksworkspaceTable

    ws = CreatePeaksWorkspace()
    print("Created a {} with {} rows".format(ws.id(), ws.rowCount()))

Output:

.. testoutput:: ExEmptyPeaksworkspaceTable

    Created a PeaksWorkspace with 0 rows

**Example: Create an empty LeanElasticPeaksWorkspace, not tied to an instrument**
Zhang, Chen's avatar
Zhang, Chen committed
.. testcode:: ExEmptyLeanElasticPeaksworkspaceTable
Zhang, Chen's avatar
Zhang, Chen committed
    ws = CreatePeaksWorkspace(NumberOfPeaks=0, OutputType="LeanElasticPeak")
    print("Created a {} with {} rows".format(ws.id(), ws.rowCount()))
Zhang, Chen's avatar
Zhang, Chen committed
.. testoutput:: ExEmptyLeanElasticPeaksworkspaceTable
    Created a LeanElasticPeaksWorkspace with 0 rows

**Example: With a few peaks in place**

.. testcode:: ExTableWithRows

    sampleWs = CreateSampleWorkspace()
    ws = CreatePeaksWorkspace(InstrumentWorkspace=sampleWs,NumberOfPeaks=3)
    print("Created a {} with {} rows".format(ws.id(), ws.rowCount()))

Output:

.. testoutput:: ExTableWithRows

    Created a PeaksWorkspace with 3 rows