Saving data from MSlice

I’m a novice user so forgive the perhaps obvious questions:

When saving data from mslice plot window, it only saves the data that were first opened in that window, not the data that are displayed currently. This means to save a series of data sets each dataset needs to be opened, and then the window closed. If this is the intended behaviour I couldn’t find it documented.

When plotting a cut, the data are described as integrated in the documentation, but it seems that the data are averaged over the integration range instead: is that the case? If so, could the documentation be clarified and an integration option be included?

Additionally, is there a way to save datasets using the command line? | couldn’t find it in the documentation.



Hi Matt,

Sorry, the first issue (MSlice just saves first cut plotted) is a bug. I’ve open an issue for it: Bug: saving cut only works for first cut plotted to that window · Issue #472 · mantidproject/mslice · GitHub - I’ll try to fix it asap and hopefully get it into the next Mantid release (due mid-July).

the data are averaged over the integration range instead

You’re right - sort of: Behind the scenes, MSlice uses this algorithm: SofQWNormalisedPolygon v1 internally for both cuts and slices - so both operations are in effect a rebinning, where the output counts are scaled to the output area - that is, the output intensity and errors are:

Y_i’ = sum_i (Y_i * F_i) / sum_i F_i
E_i’ = sqrt( sum_i (E_i^2 * F_i) ) / sum_i F_i

where F_i are the fractional areas of the ith bin used in the rebinned output.

I’ll amend the documentation.

The reason we do this is because at the edges of the detectors, the rebinned fractional area is small, so we don’t want the counts in these areas to give an outsized contribution to the cut. For the pure integration option, this would just mean removing the denominator [sum_i F_i] but that might give you quite a strange output.

is there a way to save datasets using the command line?

Yes, but not so straightforward - we’re going to fix it in the next version of Mantid ( Add file I/O commands to mslice.cli namespace · Issue #468 · mantidproject/mslice · GitHub ) but for now, you can use something like:

import mslice.cli as mc
import mslice.models.workspacemanager.file_io as mio

ws = mc.Load('file')
cut_ws = mc.Cut(ws, CutAxis="DeltaE,5.0,55.0,0.3", IntegrationAxis="|Q|,0.0,9.0,0.0", NormToOne=False)
slice_ws = mc.Slice(ws, Axis1="|Q|,0.27356,11.0351,0.04671", Axis2="DeltaE,-241.97,469.41,2.42,cm-1", NormToOne=False)

mio.save_ascii(cut_ws, '/tmp/cut.txt', is_slice=False)
mio.save_ascii(slice_ws, '/tmp/slice.txt', is_slice=True)

Hope this helps,


Hi Duc,

Thanks! I’ll test the ascii code (is there a matlab function too? I can work with both, but it would be a small time saver).

Is there a way to get this without the area normalisation? I’m trying to put some data on an absolute scale (by quantitative Rietveld refinement of the elastic line to scale the total data-set) and so this area averaging is not quite what I’d want.