Skip to content
Snippets Groups Projects
ReflectometrySliceEventWorkspace-v1.rst 2.49 KiB
Newer Older
.. algorithm::

.. summary::

.. relatedalgorithms::

.. properties::


ReflectometrySliceEventWorkspace
--------------------------------

This algorithm slices an input workspace into one or more grouped output workspaces based on input filtering properties.

It uses :ref:`algm-GenerateEventsFilter` to define the way splitting should be done and exposes the relevant input properties for that algorithm. It then performs the filtering using :ref:`algm-FilterEvents`.

The sliced workspaces are then rebinned to histogram data and combined with the given monitor workspace, to produce a workspace suitable for input to :ref:`algm-ReflectometryReductionOneAuto`. The monitors for each slice are scaled according to the percentage of ``proton_charge`` in that slice.

Usage
-------

**Example: slice by time interval**

.. testcode:: ExSliceByTime

    from __future__ import print_function
    input_ws = CreateSampleWorkspace("Event",BankPixelWidth=1,BinWidth=20000)
    AddTimeSeriesLog(input_ws, Name="proton_charge", Time="2010-01-01T00:00:00", Value=100)
    AddTimeSeriesLog(input_ws, Name="proton_charge", Time="2010-01-01T00:10:00", Value=100)
    AddTimeSeriesLog(input_ws, Name="proton_charge", Time="2010-01-01T00:20:00", Value=80)
    AddTimeSeriesLog(input_ws, Name="proton_charge", Time="2010-01-01T00:30:00", Value=80)
    AddTimeSeriesLog(input_ws, Name="proton_charge", Time="2010-01-01T00:40:00", Value=15)
    AddTimeSeriesLog(input_ws, Name="proton_charge", Time="2010-01-01T00:50:00", Value=100)
    monitor_ws = CreateSampleWorkspace(NumBanks=0, NumMonitors=3, BankPixelWidth=1, NumEvents=10000)

    output = ReflectometrySliceEventWorkspace(InputWorkspace=input_ws, MonitorWorkspace=monitor_ws,
                                              TimeInterval=600, StartTime='1800', StopTime='3300')

    print(str(output.getNumberOfEntries()) + ' slices')
    print(str(output[0].getNumberHistograms()) + ' spectra')
    print('Y values for first bin:')
    for i in range(output.getNumberOfEntries()):
        print('Slice '  + str(i))
        for j in range(output[i].getNumberHistograms()):
            print(output[i].dataY(j)[0])
.. testoutput:: ExSliceByTime
    3 slices
    5 spectra
    Y values for first bin:
    Slice 0
    0.173684210526
    0.173684210526
    0.173684210526
    4.0
    4.0
    Slice 1
    0.0726315789474
    0.0726315789474
    0.0726315789474
    4.0
    4.0
    Slice 2
    0.0631578947368
    0.0631578947368
    0.0631578947368
    1.0
    1.0

.. categories::

.. sourcelink::