Commit cee10819 authored by Nick Draper's avatar Nick Draper
Browse files

more pages and fixes re #6875

parent f38d254d
.. _mantid.api.IEventWorkspace:
=================
IEventWorkspace
=================
......
.. _mantid.api.Run:
.. _mantid.api.Sample:
========
Sample
......
.. _EventWorkspace:
===============
Event Workspace
===============
.. contents::
:local:
Quick Summary For Users
-----------------------
......@@ -11,7 +15,7 @@ where the information about each individual neutron detection event is
maintained. For you as a user, this means that:
- You can :ref:`rebin <algm-rebin>` an EventWorkspace over and over and no
information is ever lost.
information is ever lost (as long as you choose the PreserveEvents option).
- The histogram (Y and E values) of an EventWorkspace are only
calculated when they are requested.
......@@ -35,6 +39,178 @@ maintained. For you as a user, this means that:
your data as an EventWorkspace for as much processing as is possible
(as long as you have enough memory!).
Working with Event Workspaces in Python
----------------------------------------
EventWorkspace is designed to be able to be read (but not written to)
like a :ref:`MatrixWorkspace <MatrixWorkspace>`. You can look at the :ref:`Event Workspace API reference <mantid.api.IEventWorkspace>` for a full list of properties and operations, but here are some of the key ones.
Accessing Workspaces
####################
The methods for getting a variable to an EventWorkspace is the same as shown in the :ref:`Workspace <Workspace-Accessing_Workspaces>` help page.
If you want to check if a variable points to something that is an Event Workspace you can use this:
.. testcode:: CheckEventWorkspace
from mantid.api import IEventWorkspace
eventWS = CreateSampleWorkspace(WorkspaceType="Event")
if isinstance(eventWS, IEventWorkspace):
print eventWS.getName() + " is an " + eventWS.id()
Output:
.. testoutput:: CheckEventWorkspace
:options: +NORMALIZE_WHITESPACE
eventWS is an EventWorkspace
Event Workspace Properties
###########################
In addition to the Properties of the :ref:`MatrixWorkspace <MatrixWorkspace>`, the Event Workspace also has the following:
.. testcode:: EventWorkspaceProperties
eventWS = CreateSampleWorkspace(WorkspaceType="Event")
print "Number of events:", eventWS.getNumberEvents()
print "Maximum time of flight:", eventWS.getTofMax()
.. testoutput:: EventWorkspaceProperties
:hide:
:options: +ELLIPSIS,+NORMALIZE_WHITESPACE
Number of events: ...
Maximum time of flight: ...
Event lists
###########
Event Workspaces store their data in event lists, one per spectrum. You can access them using:
.. testcode:: EventWorkspaceEventLists
eventWS = CreateSampleWorkspace(WorkspaceType="Event")
# get the number of event lists
evListCount = eventWS.getNumberHistograms()
# Get the first event list
evList = eventWS.getEventList(0)
# Get some basic information
print "Number of events in event List 0:", evList.getNumberEvents()
print "Minimum time of flight in event List 0:", evList.getTofMax()
print "Maximum time of flight in event List 0:", evList.getTofMax()
print "Memory used:", evList.getMemorySize()
print "Type of Events:", evList.getEventType()
# Get a vector of the pulse times of the events
pulseTimes = evList.getPulseTimes()
# Get a vector of the TOFs of the events
tofs = evList.getTofs()
# Get a vector of the weights of the events
weights = evList.getWeights()
# Get a vector of the errors squared of the weights of the events
weightErrors = evList.getWeightErrors()
# Integrate the events between a range of X values
print "Events between 1000 and 5000:", evList.integrate(1000,5000,False)
#Check if the list is sorted in TOF
print "Is sorted by TOF:", evList.isSortedByTof()
.. testoutput:: EventWorkspaceEventLists
:hide:
:options: +ELLIPSIS,+NORMALIZE_WHITESPACE
Number of events in event List 0: ...
Minimum time of flight in event List 0: ...
Maximum time of flight in event List 0: ...
Memory used: ...
Type of Events: TOF
Events between 1000 and 5000: ...
Is sorted by TOF: True
Changing EventLists
^^^^^^^^^^^^^^^^^^^
Please note these should only be done as part of a Python Algorithm, otherwise these actions will not be recorded in the workspace history.
.. testcode:: ChangingEventLists
import math
eventWS = CreateSampleWorkspace(WorkspaceType="Event")
# Get the first event list
evList = eventWS.getEventList(0)
# Add an offset to the pulsetime (wall-clock time) of each event in the list.
print "First pulse time before addPulsetime:", evList.getPulseTimes()[0]
seconds = 200.0
evList.addPulsetime(seconds)
print "First pulse time after addPulsetime:", evList.getPulseTimes()[0]
# Add an offset to the TOF of each event in the list.
print "First tof before addTof:", evList.getTofs()[0]
microseconds = 2.7
evList.addTof(microseconds)
print "First tof after addTof:", evList.getTofs()[0]
# Convert the tof units by scaling by a multiplier.
print "First tof before scaleTof:", evList.getTofs()[0]
factor = 1.5
evList.scaleTof(factor)
print "First tof after scaleTof:", evList.getTofs()[0]
# Multiply the weights in this event list by a scalar with an error.
print "First event weight before multiply:", evList.getWeights()[0], \
"+/-", math.sqrt(evList.getWeightErrors()[0])
factor = 10.0
error = 5.0
evList.multiply(factor,error)
print "First event weight after multiply:", evList.getWeights()[0], \
"+/-", math.sqrt(evList.getWeightErrors()[0])
# Divide the weights in this event list by a scalar with an error.
print "First event weight before divide:", evList.getWeights()[0], \
"+/-", math.sqrt(evList.getWeightErrors()[0])
factor = 1.5
error = 0.0
evList.divide(factor,error)
print "First event weight after divide:", evList.getWeights()[0], \
"+/-", math.sqrt(evList.getWeightErrors()[0])
# Mask out events that have a tof between tofMin and tofMax (inclusively)
print "Number of events before masking:", evList.getNumberEvents()
evList.maskTof(1000,5000)
print "Number of events after masking:", evList.getNumberEvents()
.. testoutput:: ChangingEventLists
:hide:
:options: +ELLIPSIS,+NORMALIZE_WHITESPACE
First pulse time before addPulsetime: 2010-01-01T00:32:55...
First pulse time after addPulsetime: 2010-01-01T00:36:15...
First tof before addTof: 118...
First tof after addTof: 121...
First tof before scaleTof: 121...
First tof after scaleTof: 181...
First event weight before multiply: 1.0... +/- 1.0...
First event weight after multiply: 10.0 +/- 3.34...
First event weight before divide: 10.0 +/- 3.34...
First event weight after divide: 6.6... +/- 2.73...
Number of events before masking: ...
Number of events after masking: ...
For Developers/Writing Algorithms
---------------------------------
......@@ -42,7 +218,7 @@ The following information will be useful to you if you want to write an
algorithm that is EventWorkspace-aware.
Individual Neutron Event Data (TofEvent)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
########################################
The TofEvent class holds information for each neutron detection event
data:
......@@ -54,7 +230,7 @@ data:
Note that this field can be converted to other units, e.g. d-spacing.
Lists of Events (EventList)
~~~~~~~~~~~~~~~~~~~~~~~~~~~
###########################
- The EventList class consists of a list of TofEvent's. The order of
this list is not significant, since various algorithms will resort by
......@@ -76,34 +252,34 @@ EventWorkpspace->makeSpectraMap to generate the spectra map (map between
spectrum # and detector IDs) by using the info in each EventList.
Most Recently Used List (MRUList)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#################################
An EventWorkspace contains a list of the 100 most-recently used
histograms, a MRUList. This MRU caches the last histogram
data generated for fastest display.
A note about workspace index / spectrum number / detector ID
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
############################################################
The loading algorithms **match** the workspace index and spectrum number
For event workspaces there is no benefit, and only a drawback to grouping detectors in hardware, therefore most of the loading algorithms for event data **match** the workspace index and spectrum number
in the EventWorkspace. Therefore, in an EventWorkspace, the two numbers
will be the same, and your workspace's Axis[1] is a simple 1:1 map. As
mentioned above, the detectorID is saved in EventList, but the
makeSpectraMap() method generates the usual SpectraDetectorMap object.
Workspace2D compatibility
~~~~~~~~~~~~~~~~~~~~~~~~~
#########################
EventWorkspace is designed to be able to be read (but not written to)
like a :ref:`Workspace2D <Workspace2D>`. By default, if an algorithm
like a :ref:`MatrixWorkspace <MatrixWorkspace>`. By default, if an algorithm
performs an operation and outputs a new workspace, the
WorkspaceFactory will create a Workspace2D *copy*
WorkspaceFactory will create a :ref:`Workspace2D` *copy*
of your EventWorkspace's histogram representation. If you attempt to
change an EventWorkspace's Y or E data in place, you will get an error
message, since that is not possible.
A Note about Thread Safety
~~~~~~~~~~~~~~~~~~~~~~~~~~
##########################
Thread safety can be surprising when using an EventWorkspace:
......
......@@ -136,9 +136,6 @@ You can get access to the :ref:`Instrument` for a workspace with
instrument = ws.getInstrument()
.. testoutput:: MatrixWorkspaceInstrument
:hide:
For the properties and operations of the instrument look at the :ref:`Instrument help <Instrument>`.
Run - to access logs, and other run information
......@@ -154,9 +151,6 @@ You can get access to the :ref:`Run` for a workspace with
instrument = ws.getRun()
.. testoutput:: MatrixWorkspaceRun
:hide:
For the properties and operations of the run object and how to access log data look at the :ref:`Run help <Run>`.
Axes
......@@ -396,10 +390,6 @@ The expected operations of +,-,*,/ are supported with either a single number or
# Multiply the new workspace by 2 and place the output into a new workspace
w4 = w3 * 2
.. testoutput:: MatrixWorkspaceAlgebra
:hide:
It is also possible to replace one of the input workspaces using one of +=,-=,*=,/= e.g.
.. testsetup:: MatrixWorkspaceAlgebra2
......@@ -415,15 +405,8 @@ It is also possible to replace one of the input workspaces using one of +=,-=,*=
# Add 'workspace2' to 'workspace1' and replace 'workspace1' with the output
w1 += w2
.. testoutput:: MatrixWorkspaceAlgebra2
:hide:
.. include:: WorkspaceNavigation.txt
.. categories:: Concepts
......@@ -119,7 +119,7 @@ to alter and those properties are detailed below.
| |will apply. | |
+-------------------------------------------+---------------------------------------------------+-----------------------+
|logging.channels.consoleFilterChannel.level|The lowest level messages to output to the console.|debug, information, |
| | The default is warning, but this can be |notice, warning, |
| |The default is warning, but this can be |notice, warning, |
| |lowered to debug for more detailed feedback. The |error, critical |
| |higher level of this and logging.loggers.root.level|or fatal |
| |will apply. | |
......
......@@ -37,19 +37,16 @@ Getting the Run Object from a Workspace
run = ws.getRun()
.. testoutput:: WorkspaceRun
:hide:
Run Properties
##############
.. testSetup:: RunPropertiestest
.. testsetup:: RunPropertiestest
ws = Load("MAR11060")
.. testcode:: RunPropertiestest
from mantid.kernel import DateAndTime
run = ws.getRun()
# Set the start and end time of a run
......@@ -69,8 +66,7 @@ Run Properties
2015-01-27T11:00:00
2015-01-27T11:57:51
121.470...
121...
Accessing Properties
####################
......@@ -103,7 +99,7 @@ Listing all properties
Getting a specific property
^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. testcode:: GetPropertytest
.. testcode:: RunGetPropertytest
ws = CreateSampleWorkspace()
......@@ -119,7 +115,7 @@ Getting a specific property
print "Property name: " + runStart.name
print "Property value: " + runStart.value
.. testoutput:: GetPropertytest
.. testoutput:: RunGetPropertytest
:hide:
:options: +ELLIPSIS,+NORMALIZE_WHITESPACE
......@@ -129,7 +125,7 @@ Getting a specific property
Property value: 2010-01-01T00:00:00
The Gonioneter
##############
##############
If the instrument conatains a Goniometer it can be accessed from the run object.
......@@ -141,12 +137,15 @@ If the instrument conatains a Goniometer it can be accessed from the run object.
print "Goniometer angles: ",wg.getRun().getGoniometer().getEulerAngles('YZY')
.. testoutput:: GetPropertytest
.. testoutput:: GetGoniometertest
:hide:
:options: +NORMALIZE_WHITESPACE
Goniometer angles: [50,0,0]
Listing all properties
^^^^^^^^^^^^^^^^^^^^^^
What information is stored here?
--------------------------------
......@@ -154,7 +153,7 @@ On loading experimental data there is a default set of properties that
are populated within the run. These are as follows:
ISIS (not including ISIS Muon data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
###################################
- **run\_header** - The complete header for this run
- **run\_title** - The run title
......@@ -183,7 +182,7 @@ ISIS (not including ISIS Muon data)
- **rb\_proposal** - The proposal number
ISIS Muon data
^^^^^^^^^^^^^^
##############
- **run\_title** - The run title
- **run\_start** - Start date and time. Format: YYYY-MM-DD HH:MM:SS (+)
......
......@@ -30,9 +30,6 @@ Getting the Sample Object from a Workspace
ws=CreateWorkspace(DataX='1,2',DataY='1')
s=ws.sample()
.. testoutput:: WorkspaceSample
:hide:
Sample Properties
#################
......@@ -89,9 +86,5 @@ The ``Sample()`` method actually returns a collection, however if you do not spe
# You can ask how many samples there are with
size = ws.sample().size()
.. testoutput:: MultiSample
:hide:
:options: +ELLIPSIS,+NORMALIZE_WHITESPACE
.. categories:: Concepts
\ No newline at end of file
......@@ -64,6 +64,7 @@ Working with Workspaces in Python
Workspace is an abstract description of an specific workspace implementation. It provides access to a few common properties without any knowledge of what the type of the workspace.
.. _Workspace-Accessing_Workspaces:
Accessing Workspaces
####################
......@@ -115,10 +116,6 @@ You can look at the :ref:`Workspace API reference <mantid.api.Workspace>` for a
print "getMemorySize = " + str(myWS.getMemorySize())
#You can also rename a workspace
Berty = myWS.rename()
print "my new name = " + myWS.getName()
Output:
.. testoutput:: WorkspaceProperties
......@@ -129,7 +126,6 @@ Output:
comment = This is my comment
id = Workspace2D
getMemorySize = ...
my new name = Berty
Workspace Types
......
......@@ -93,8 +93,8 @@ For texture focusing, the detector grouping file is a text (csv) file
with one line per bank. Each line must contain at least two numeric
fields, where the first one specifies the bank ID, and the second and
subsequent ones different spectrum numbers or ranges of spectrum
numbers. For example:
::
numbers. For example::
# Bank ID, spectrum numbers
1, 205-210
2, 100, 102, 107
......
......@@ -145,6 +145,7 @@ Raw data correction files
=========================
1. **Detector efficiency**:
- File name: *HB2A_exp0IJK__GE_abc_XY_vcorr.txt* where
- IJK is the experiment number
......
......@@ -128,7 +128,7 @@ The **Reflectometry** menu provides access to the following functionality:
| | by the :ref:`CalculateSlits <algm-CalculateSlits>` |
| | algorithm. |
+------------------+----------------------------------------------------------+
| Options | Opens the `Options`_ menu. |
| Options | Opens the `Options <ISIS_Reflectomety-Options>`_ menu. |
+------------------+----------------------------------------------------------+
The **Edit** menu provides access to the same actions found in the tool bar.
......@@ -343,9 +343,10 @@ Measure based search transfer uses the log-values within nexus files from the ex
placed into the same group.
- Any runs with the ``same measurement_id`` and the same ``measurement_subid`` logs, will be merged into a single row, with all the runs listed in the **Run(s)** column in the format, ``123+124+125``.
.. _ISIS_Reflectomety-Options:
Options
~~~~~~~
-------
Through the options menu, a small number of options may be configured to adjust
the behaviour of the interface.
......
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