LoadMcStas v1

../_images/LoadMcStas-v1_dlg.png

LoadMcStas dialog.

Summary

Loads a McStas NeXus file into an workspace.

Properties

Name Direction Type Default Description
Filename Input string Mandatory The name of the Nexus file to load. Allowed extensions: [‘.h5’, ‘.nxs’]
OutputWorkspace Output Workspace Mandatory An output workspace.
ErrorBarsSetTo1 Input boolean False When this property is set to false errors are set equal to data values, and when set to true all errors are set equal to one. This property defaults to false

Description

Reads a McStas Nexus file into a Mantid WorkspaceGroup with a user-supplied name. Data generated by McStas monitor components are stored in workspaces of type Workspace2D and/or EventWorkspace.

For information about how to create McStas outputs that can readily be read by this loader, see here. For more information about McStas, and combined McStas and Mantid analyses see references below.

The ErrorBarsSetTo1 property applies to event data, but not to histogram data.

LoadMcStas replaces LoadMcStasEventNexus. LoadMcStas can be used for reading McStas 2.1 histogram and event data. LoadMcStasNexus v1 can be used for reading McStas 2.0 histogram data.

Information about the required structure of the input Nexus file

The input file must have an /entry1/simulation/name item whose value is "mccode".

The output workspace will contain one workspace for each group of class NXdata in the input NeXus file, which is not of name "content_nxs" found in a group of class NXDetector of name "Data". The name of the workspace is the same as the name of the group, but with __mcstas_event_hist added to the end.

Description of Data Found in Nexus file (within ‘run’) Placed in Workspace (Workspace2D) or output
All data Group of class NXDetector of name "data" See below
Generic group including either event or histrogram data each group of class NXdata in "data", henceforth referred to as [DATA] one workspace each
Event data item in a [DATA] with a long_name attribute containing "Neutron_ID" and name "events" event data
Histrogram data items in a [DATA] with a long_name attribute not containing "Neutron_ID" histogram data
Instrument /instrument loaded into workspace, only if events are loaded
Instrument definition /instrument/instrument_xml/data is needed for events to be loaded loaded into workspace, only if events are loaded

The event data of the McStas file occurs in a NeXus table with six columns:

  1. Weight
  2. X coordinate
  3. Y coordinate
  4. Number of previous events
  5. Detector ID
  6. Time

References

For more information about McStas and its general usage for simulating neutron scattering instruments and experiments visit the McStas homepage .

For examples of how combined McStas and Mantid analyses can help instrument simulation and data treatment/analysis tasks see Nielsen., T.R. et al., McStas and Mantid integration, Journal of Neutron Research, vol. 18, no. 2-3, pp. 61-77, 2015 DOI: 10.3233/JNR-160026 [arXiv].

Usage

Note

To run these usage examples please first download the usage data, and add these to your path. In MantidPlot this is done using Manage User Directories.

Example - Load McStas data containing both event and histogram data:

# Load the data into tuple
ws = LoadMcStas('mcstas_event_hist.h5')

# workspace group is first entry in tuple
group = ws[0]
print "Number of entries in group: " + str(group.getNumberOfEntries())

eventData = ws[1]
print "Number of histograms in event data: " + str(eventData.getNumberHistograms())
print "Name of event data: " + str(eventData.getName())

someHistogramData = ws[2]
print "Number of histograms in hist data: " + str(someHistogramData.getNumberHistograms())
print "Name of hist data: " + str(someHistogramData.getName())

Output:

Number of entries in group: 5
Number of histograms in event data: 8192
Name of event data: EventData_ws
Number of histograms in hist data: 1
Name of hist data: Edet.dat_ws

Categories: Algorithms | DataHandling\Nexus

Source

C++ source: LoadMcStas.cpp

C++ header: LoadMcStas.h