\(\renewcommand\AA{\unicode{x212B}}\)

SaveMD v2

../_images/SaveMD-v2_dlg.png

SaveMD dialog.

Summary

Save a MDEventWorkspace or MDHistoWorkspace to a .nxs file.

Properties

Name Direction Type Default Description
InputWorkspace Input IMDWorkspace Mandatory An input MDEventWorkspace or MDHistoWorkspace.
Filename Input string   The name of the Nexus file to write, as a full or relative path. Optional if UpdateFileBackEnd is checked. Allowed extensions: [‘.nxs’]
UpdateFileBackEnd Input boolean False Only for MDEventWorkspaces with a file back end: check this to update the NXS file on disk to reflect the current data structure. Filename parameter is ignored.
MakeFileBacked Input boolean False For an MDEventWorkspace that was created in memory: This saves it to a file AND makes the workspace into a file-backed one.
SaveHistory Input boolean True Option to not save the Mantid history in the file. Only for MDHisto
SaveInstrument Input boolean True Option to not save the instrument in the file. Only for MDHisto
SaveSample Input boolean True Option to not save the sample in the file. Only for MDHisto
SaveLogs Input boolean True Option to not save the logs in the file. Only for MDHisto

Description

Save an MDEventWorkspace or a MDHistoWorkspace to a .nxs file. The workspace’s current box structure and entire list of events is preserved. The resulting file can be loaded via LoadMD.

If you specify MakeFileBacked, then this will turn an in-memory workspace to a file-backed one. Memory will be released as it is written to disk.

If you specify UpdateFileBackEnd, then any changes (e.g. events added using the PlusMD algorithm) will be saved to the file back-end.

Usage

ws = CreateMDHistoWorkspace(SignalInput='1,2,3,4,5,6,7,8,9', ErrorInput='1,1,1,1,1,1,1,1,1', Dimensionality='2',
                            Extents='-1,1,-1,1', NumberOfBins='3,3', Names='A,B', Units='U,T')
import os
savefile = os.path.join(config["default.savedirectory"], "mdhws.nxs")
SaveMD(ws, Filename=savefile)
print("File created: {}".format(os.path.exists(savefile)))

Output:

File created: True

Categories: AlgorithmIndex | MDAlgorithms\DataHandling

Source

C++ header: SaveMD2.h

C++ source: SaveMD2.cpp