Mantid
is framework for processing and analyzing neutron and muon scattering data. Eevery now and then, I found myself having difficulties in using some of the algorithms in Mantid
and every time I keep forgetting what the solution is. So, in this blog, I will try to note down the solution to those commonly encountered difficulties that I came across along the way, presented in the FAQ format.
▶️ How to do the time filtering and save the filtered workspace properly?
# Answer: Time filtering can be done with the following snippet, by specifying the absolute time for start and end. Relative time can be used as well, but it seems that the algorithm is not behaving as documented in the Mantid
documentation [1] – when an integer is used as the input for the StopTime
parameter, it seems that the algorithm still treat it as seconds
but not nanoseconds
as given in the documentation.
FilterByTime(
InputWorkspace=’dia’,
OutputWorkspace=’wsFiltered’,
AbsoluteStartTime=”2024-08-21T13:30:00”,
AbsoluteStopTime=”2024-08-21T14:00:00”
)
To save the filtered to a NeXus file to be used later outside the currently running Mantid Workbench
instance, we can use the following snippet,
SaveNexusProcessed(
InputWorkspace=”wsFiltered”,
Filename=”/SNS/NOM/IPTS-33585/shared/dia_filtered/diamond_198917.nxs”,
Title=”diamond”,
Append=False,
PreserveEvents=True,
WorkspaceIndexList=range(mtd[“wsFiltered”].getNumberHistograms())
)
The critical input parameter here for running the SaveNexusProcessed
algorithm is WorkspaceIndexList
. It seems that if we don’t specify it explicitly, the algorithm would save the workspace to a very small file, and later on when we try to load in the saved NeXus file, Mantid
would crash, throwing out segmentation fault
error.