{'fraction_non_alphanumeric': 0.029815010118860986, 'fraction_numerical': 0.011971610181569422, 'mean_word_length': 4.6441441441441444, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
VESUVIO Data Analysis Goes MANTID

This paper describes ongoing efforts to implement the reduction and analysis of neutron Compton scattering data within the MANTID framework. Recently, extensive work has been carried out to integrate the bespoke data reduction and analysis routines written for VESUVIO with the MANTID framework. While the programs described in this document are designed to replicate the functionality of the Fortran and Genie routines already in use, most of them have been written from scratch and are not based on the original code base.


Introduction
Neutron Compton scattering (NCS) may be regarded as a mass spectroscopic technique in which each atomic mass contributes to the overall time-of-flight (TOF) spectrum in the form of a Doppler-broadened recoil peak. The width of such recoil peak in the energy domain can be related to the momentum distribution of the target nucleus prior to the scattering effect. NCS has been successfully applied in a wide variety of condensed matter systems and molecules. This includes fluid and solid hydrogen [1,2,3]; water [4,5], proton glasses [6], biological molecules [7,8], hydrogen storage materials [9,10], helium ( 3 He and 4 He) [11,12,13,14,15,16], noble gases in solid and fluid phases [17,18], graphite [19], metal hydrides [20], etc.
NCS data-reduction schemes can be conveniently subdivided into two groups: (i) those that aim solely at the determination of scattered intensities [21,22], and (ii) those that serve the purpose of the determination of kinetic energies and momentum distributions of individual nuclei in a mass-selective manner [23,24,25,26,27,28]. The use of existing NCS data treatment schemes usually requires remote access to a variety of different computing environments with routines compiled for different operational systems and hardware infrastructures. These requirements substantially increase the complexity and time for the data analysis and reduction stage. The first step towards decreasing this complexity was made by extending the capabilities of the first generation of NCS data reduction routines by translating them into a set of MATLAB routines within a common NCS toolbox where computation, visualization, and programming can be completed within the same environment. Nevertheless, both FORTRAN and MATLAB versions of the NCS software have been developed and maintained in a closed environment resulting with suboptimal code development. Therefore, consolidation and translation of the NCS data reduction routines into the MANTID framework has become a prerequisite both for further code and technique development. MANTID, with extensive use of PYTHON and C++, uses a common interface which is seamless between the facility, beam line and home institution when performing the final analysis and fitting of the data [29]. Furthermore, this approach increases transparency between the developer and user community. This has been the main motivation behind the work presented here. In this paper, we briefly describe VESUVIO data-reduction and analysis as implemented in Fortran, MATLAB, and MANTID, and use the example of zirconium hydride as a test bed to demonstrate their equivalence. Examples of the NCS data-reduction routines using the MANTID graphical user interface and PYTHON scripts are presented. In the final section additional functionalities are discussed in the context of their potential of providing new insights in the analysis of NCS data.

Neutron Compton scattering and the impulse approximation
In NCS, the energy and momentum transfers imparted by the neutron to the target nucleus are so high that the scattering process can be treated within the (IA) [30,31,23]. The IA effectively treats NCS as billiard-ball scattering with conservation of kinetic energy and momentum of the neutron and a given (struck) nucleus. Under the IA, the scattering function, S M (q, ω) for a given nucleus of mass M reduces to a single peak centered at the recoil energy E r =h 2 Q 2 /2M . In this limit, S M (q, ω) has the form [23]: where n M (p) is the nuclear radial momentum distribution for mass M . Consequently we can write S M (q, ω) = M h 2 q J (y,q), where: whereq is a unit vector in the direction of the momentum transfer. Hereinafter, momentum transfer will be given in units ofÅ −1 , energy transfer ω in meV, and atomic mass in amu. With this choice of units, Plank's constant is given byh = 2.0446 (meV amu) 1/2Å . J (y,q) is the so called neutron Compton profile [31,30] and is formally the result of a Radon transformation of the radial momentum distribution n M (p). The relationship given by Eq. (2) is formally known as 'y-scaling' or the 'West-Scaling' [32,31,23]. It implies that q and ω are no longer independent variables and that for samples with no preferred orientation any scan in q − ω space crossing the recoil line, defined by the relation ω r =h 2 q 2 2M , gives a measurement of the neutron Compton profile J (y,q). For a harmonically bound isotropic system where the momentum distribution n M (p) depends only on the magnitude of the radial momentum, p = |p|, and the neutron Compton profile J (y,q) in the IA limit, hereinafter denoted as J IA (y), can be written as a normalized Gaussian [33,34,35,36,23] of the form where σ p is the standard deviation. Equation is exactly correct when the atoms are bound by isotropic harmonic forces. In real data, the anisotropy and anharmonicity of the local binding potential both give a non-Gaussian J IA (y). Equation (3) is generally good when small atomic displacement from the mean position sample the harmonic region. The current resolution  [31,36,23]. To account for FSEs the method of Sears is routinely incorporated into standard NCS data treatments [31,36,23] by expressing the measured neutron Compton profile J(y) to first order as where J IA (y) is the IA result. ⟨∇ 2 V ⟩ is the mean value of the Laplacian of the potential energy of the nucleus expressed in meVÅ −2 (cf. Refs. [19,36,23]. In an NCS experiment performed on an isotropic sample within the IA limit, a given NCS profile J IA (y) can be related to a spherically averaged three-dimensional nuclear momentum distribution (NMD) n IA (p) by the following expression [23] n IA (p) = −1 2πy where the radial NMD n IA (p) can be represented as where L 1/2 n denotes a generalised Laguerre polynomial. Equation (6) can be used for the reconstruction of n IA (p) from the measured J (y) after subtraction of the FSE contribution where H 2n denotes a Hermite polynomial. In the above expression, the coefficients c n are identical to the expansion coefficients for the radial momentum distribution, which is tantamount to an inversion procedure between J IA (y) and n IA (p). The expansions are in fact over complete: σ can be arbitrary and the series in Eq. (7) will still converge satisfactorily to an arbitrary function [27]. However, if the first term is omitted in the fitting (that is c 1 is fixed at zero), σ necessarily determines the kinetic energy, independently of any other terms in the series.

Count rate on an inverse-geometry instrument
On an inverse geometry instrument like VESUVIO at ISIS [27], the time-of-flight (TOF), t, of each detected neutron is determined by where L 0 is the source-sample distance, L 1 is the sample-detector distance, v 0 = √ 2E 0 /m is the incident neutron velocity, and E 0 the incident neutron energy, v 1 = √ 2E 1 /m, the velocity corresponding to detected (and thus fixed) neutron energy E 1 , and m is the neutron mass. The incident energy E 0 , can be calculated from the measured TOF, t (Eq. 8), given L 0 , L 1 , and E 1 . Hence the energy transfer and the momentum transfer can both be determined from t. The count rate as a function of t on an inverse-geometry neutron spectrometer can be written as [27] C where I (E 0 ) dE 0 is the number of incident neutrons per second per unit area with energies between E 0 and E 1 + dE 0 . D (E 1 ) is the probability that a neutron energy E 1 is detected, d 2 σ dE 1 dΩ is the double differential cross-section, N is the number of atoms in the beam, and dΩ is the detector solid angle.
The spectra are, however, recorded and represented as a function of t instead of E 0 with C(t) = C(E 0 )dE 0 /dt. The Jacobian dE 0 /dt is given by the following expression [36]: Using the Jacobian dE 0 /dt the count rate C θ (t) in a given TOF channel t becomes [36] : where A ′ is another mass-independent experimental constant. If atoms of different masses M are present in the sample, the total count rate can be generalised to [36] : where both the experimental constant A ′ and the factor (t) are mass independent and can be written in front of the sum over M . The integrated peak intensity I M for a given mass M is given by M is the total bound scattering cross section and N M is the number density. [36]

Instrument resolution
In a real experimental situation the measured count rate C θ (t) for every TOF, t, is an average over the possible values of all geometrical parameters characterising neutron trajectories and scattering angles as well as the final neutron energy weighted by its probability of occurrence. In case of NCS data reduction the most frequently adopted formalism to account for the effects of instrument resolution is to replace the multiple integrals over distributions of the abovementioned parameters that would have been required to be calculated for each data point in a TOF spectrum for a given mass by convolution with a mass-dependent resolution function. In the framework of the so-called 'convolution approximation' (CA) it is assumed that a TOF spectrum for a given mass is described by a convolution of a mass-dependent resolution function of the instrument R [y M (t)] and the neutron Compton profile of the scatterer J[y M (t)] [36]. Typically, the resolution function R [y M (t)] is assumed to be described by a Voigt line shape as it is the case for the gold foil used on VESUVIO [36]. The convolution is performed in y-space for each mass M and then the sum over contributions from different masses is performed to account for the total count rate recorded in a given TOF spectrum. Thus, for a total of N different masses present in the sample, the total count-rate at a fixed scattering angle θ, C θ (t) is given by [36] : where A ′ is a mass-independent experimental constant and the mass-independent factor (t) depends on the incident neutron spectrum, I [E 0 (t)] the initial neutron energy, E 0 (t), and the momentum transfer q(t), all functions of the TOF, t [36]. The difference between the instrument resolution function implemented in [27] and the instrument resolution function implemented in the NCS reduction routine used in the MANTID environment is a convolution in y-space rather than t [27].
FSE contributions to both Gaussian and non-Gaussian J M are accounted for by including terms proportional to 1/qH 3 . The resulting expression to fit the entire TOF spectrum is of the following form [37] : where J H is the longitudinal nuclear momentum distribution for the first mass (i. e. the mass for which the recoil peak is centered at the lowest TOF value) and J M is the longitudinal nuclear momentum distribution for any other subsequent mass M , where y0 M is the shift of the position of the maximum of a nuclear momentum distribution from the center of the recoil line and σ M is the standard deviation of the momentum distribution for a mass M . The FSE expansion in the limit of a local effective harmonic potential for a given mass M leads to a very useful expression of the FSE coefficient k in the expansion given by k = σ √ 2 12 [37]. Thus, fitting of the recoil peaks in a harmonic approximation does not require any extra fitting parameter to describe FSEs.

VESUVIO data analysis in MANTID
The MANTID development team in combination with VESUVIO instrument scientists have created a data analysis package to help aid with the analysis of VESUVIO data. This is still a work in progress and under heavy development. Currently it is in the form of a separate PYTHON module called ncs.py which provides a collection of helper functions and classes for data analysis which builds upon the existing MANTID framework. This module is publicly available in the MANTID GITHUB scripts repository in the development\inelastic folder [38]. The simplest way of including the NCS PYTHON module in MANTID is to place the files ncs.py and ncs plotting.py in the MANTID Install\scripts folder. This will allow the NCS PYTHON module to be imported directly into the MANTID script window.

Data loading and pre-treatment options
The original data analysis package [39] used two separate commands to process the raw timeof-flight data, one for the front scattering detectors and one for the back scattering. In the MANTID implementation this has been replaced with a single algorithm called LoadVesuvio which performs all of the processing for raw files from the instrument. This includes options for handling each of the different foil positions and difference techniques available with VESUVIO [40,36] and handles the summing multiple runs. It also contains a flag for summing each spectrum in the desired range into a single spectrum. The results of this loading operation are output as a single workspace in MANTID with units in time-of-flight which can be plotted using both MANTID built in visualisation tools and custom plotting commands described in Ref. [39](see Fig. 1). Like all inelastic instruments at ISIS, VESUVIO uses time of flight measurements to determine the momentum and energy transfer to the neutron in each scattering event. The neutron counting chain assigns a time of flight to the arrival of each neutron at the detector according to Eq. (7). On VESUVIO the values of geometrical parameters defining the TOF, L0, L1, v1, t0, and the scattering angle, θ, can be characterised by mean values, with associated distributions about the mean. Given these mean values and the value of TOF assigned to the neutron, the incident velocity, v0, of each neutron detected and hence the momentum and energy transfer in the scattering process can be determined from Eq. (7). The distributions of these parameters about their mean values determine the resolution function of the instrument. The main task instrument calibration procedure is to determine these distributions and store them in the instrument parameter (IP) file. The parameter file is usually generated by the instrument scientist using a set of reference runs using the calibration program outlined in section 5.8 and does not need to be regenerated for every analysis session.
The data pre-treatment procedure in the MANTID NCS reduction scheme includes: definition of differencing technique for final-energy analysis (i.e., single or double differencing) [40,41]  followed by smoothing and truncation of data points. Residual γ-background correction, multiple-scattering correction and baseline fitting complete the data pre-treatment procedure.

Definition of differencing technique
γ−ray signals are detected on VESUVIO neutron detectors at forward-scattering angles [42]. These are made to function both as neutron detectors and energy selectors. In forward scattering, a foil-cycling (FC) technique is employed whereby two foils of the same resonance material are used, one stationary analyzer foil and one cycling foil that alternates in and out of the scattered neutron beam [40]. The energy E 1 of detected neutrons is by a large neutron absorption resonance peak at E 1 = 4.9 eV. By placing a primary gold foil on the YAP detector surface, the foil absorbs neutrons of energy E 1 ≈ 4.9 eV and emits a γ-ray cascade which can be detected, thereby determining both the TOF and the final energy of the neutron. These measurements are called 'foil-out' measurements because neutrons do not have to pass through the secondary gold foil. The γ-ray signal produced from the 'foil-out' measurements sits on a background, which may be due to γ-ray rays produced when neutrons initially scattered by the sample are then absorbed by the surrounding shielding. By positioning the secondary foil between the sample and the detector, the signal produced from these scattered neutrons are significantly reduced as neutrons of energy E 1 ≈ 4.9eV have to first pass through the secondary foil (or filter) to reach the primary foil. Through the use of this secondary gold foil, the energy resolution is also improved and the background almost eliminated. The VESUVIO 'raw' data is the difference between these two counts ('foil-out' minus 'foil-in') [42,43]. In backscattering, gold foils are placed in front of 6 Li-doped neutron detectors. In this case, a double-difference (DD) technique [41] is used to remove the background and sharpen the energy resolution. This method is based on a linear combination of two measurements recorded with filter foils of the same resonance material of different thickness. Both the FC and DD methods give a value of 4.897eV for the mean value of E 1 [44]. Detailed descriptions of the energy resolution functions can be found in Refs [41,40,45,46].
On VESUVIO, typically the first step after loading the raw data in time-of-flight is to crop the workspace to a sensible range for data analysis. This can be done by using the MANTID CropWorkspace algorithm. The typical time-of-flight range is commensurate with the size of a data vector used in an FFT-based convolution routine used fitting, i.e., 50.0 -562.0 µs (see Table 1). 1 import ncs 2 runs = "14188-14195" 3 spectra = "134" 4 diff type="SingleDifference" # Allowed values=Single, Double, Thick 5 ip file = "IP0004 10.par" 6 raw ws = LoadVesuvio(Filename=runs, SpectrumList = spectra, 7 Mode=diff type, InstrumentParFile = ip file) 8 raw ws = CropWorkspace(raw ws, XMin=50.0, XMax=562.0) The ncs.py module also provides a preprocessing function for further preparing the data for analysis. This method provides options for masking data points in the raw workspace given an error threshold as well as an option to smooth the workspace using the SmoothData algorithm. This requires a FitOptions object to be supplied (see section 5.5).

γ-background corrections in forward scattering
The γ-background correction utilizing the differencing techniques described above significantly reduces the γ-ray signals arising from the absorption of nuclei from the boron shielding on VESUVIO. However, the data from the YAP detectors in forward scattering still needs to be corrected for potential, sample-dependent (residual) γ-backgrounds because the intensity of the γ-background from the secondary foils in the instrument is dependent upon their position, which differs in the foil-in and foil-out measurements. This may result in spurious broad peaks in the baseline of the spectrum. Therefore the residual γ-background is calculated from the measured data [42] as: where C out is the 'foil-out' count-rate from the primary gold foil, C in is the 'foil-in' count-rate from the secondary gold foil, A (E 1 ) is the analyzer-foil neutron absorption coefficient at final energy E 1 , and η is the probability that the subsequent γ-ray cascade is registered by the YAP detector. B out is the γ-background with the secondary foil in the 'out' position, and B in is the background with the secondary foil in the 'in' position.
Corrections for the gamma background are implemented using the MANTID algorithm framework as an algorithm called CalculateGammaBackground. This takes a single workspace in time-of-flight, and a fit function describing the mass spectrum of the input data and a list of workspace indices to include as part of the correction. The fit function for the mass spectrum is typically one which has been created as part of the fit routines described in section 5.5. This algorithm results in two workspaces: one that contains the calculated background and a copy of the input time-of-flight workspace with the background subtracted. This function loosely corresponds to the bcorr command in the old data analysis package. There are helper functions for this implemented in ncs.py. The gamma background can be computed from a workspace simply by using the gamma correct function and passing the raw workspace to correct, the required fitting options, and the parameter workspace produced from a fit (see section 5.5). Table 2 shows the code to perform a gamma correction on a workspace that has already been fitted. The result of the code application is shown in Figure 2. Table 2. Example script for performing a gamma correction to the ZrH 2 sample using ncs.py.

Multiple-scattering correction
Multiple scattering (MS) occurs because there is always a finite probability that neutrons will scatter more than once in the sample before being detected. MS must be subtracted from the TOF spectra before accurate results for the momentum distribution can be obtained. MS corrections are calculated using the Monte-Carlo method described in reference [47]. Currently, the multiple scattering corrections for VESUVIO in MANTID are under development and will be available in future releases.

Fitting Routine
The majority of the work to integrate VESUVIO into MANTID has been concerned with the development of the fitting procedures required to measure the neutron Compton profile following the theory described in Section 3. Development in this area has focussed on two major additions to the MANTID framework. First was the creation a new suite of fit functions which could accurately describe the results of a neutron Compton scattering experiment. The second was the creation of a collection of supporting data analysis functions which allow the user to easily set up a fit given the appropriate parameters for the sample and are available in the ncs.py module. These will eventually be folded into a GUI for VESUVIO (see section 5.9). There are two major fit functions used in the analysis of VESUVIO data. The GaussianComptonProfile defines a function for fitting the simpler Gaussian approximation to mass peaks. The GramChalierComptonProfile is for the more complex fitting case described by Gram-Charlier expansion [5,6]. Both functions are implemented as standard MANTID fit functions and are therefore directly accessible through the fit wizard. Currently, in order to run a fit a FitOptions object must be created from ncs.py and set up with the appropriate options for the sample being fitted. This includes a set of parameters for each mass describing it's atomic weight, the function it should be fitted with and any additional options specific to the model used. Table 3 shows an example of how to set up the parameters of a fit using the ncs.py FitOptions class. Table 4 lists all of the current fitting options available in the FitOptions class, while Table 5 describes each of the options for defining the masses to be fitted.
The simplest mode of analysis is to assume that each of the peaks in momentum space is of Gaussian shape [36]. Using the amplitudes and widths obtained for the fit the composition of the sample and the atomic kinetic energies may be determined. Table 6 shows a basic example of how to use the FitOptions class to set up fit for the aluminium and zirconium masses in the sample.
Fitting the data shown in Figure 2 with the parameters defined in Table 3 produces three workspaces: one containing the fit of the composite function and individual mass profiles to the raw data, a table workspace of parameters for the fit, and a table workspace for the normalised covariance matrix of the fit. These workspaces are in fact just the standard output from the   Number of data points to use in the SmoothData algorithm in the pre-processing function. If not set the data will not be smoothed.

bad data error
If set, the data will be masked if it falls outside of this error tolerance.

background function
The type of background to use in fitting. By default this is set to use the Polynomial background function.

background order
The order of the background to use. masses A dictionary of parameters for each mass supplied to the fit. This should include the atomic weight, function to fit (either Gaussian or GramCharlier ) any other parameters required by the function. constraints Constraints on the intensity of each mass peak.

workspace index
The index in the workspace to fit to.

output prefix
String which is prefixed to output workspaces created from the fitting.

global fit
Whether or not to perform a multi-dataset (global) fitting of the data.
MantidFit algorithm. A plot of the fit using the Gaussian approximation function to two mass peaks for aluminium and zirconium is shown in Figure 3. Comparing this to the original example in Ref. [44] shows a good correlation between implementations. The fitted amplitudes and widths of the sample can be examined by looking at the parameters table produced by the fit. In the original VMS data analysis package a routine called ke was used to calculate the kinetic energy in meV and K and the fundamental frequency in meV and cm −1 [39]. There is currently no direct implementation of this program in MANTID The momentum distribution of atoms has a strictly Gaussian shape only when bound by isotropic harmonic forces. The shape of the nuclear momentum distribution is of interest as this contains information about the anisotropy of the binding and anharmonic effects [23]. In this case the data can be fitted using the Gram Charlier expansion [28]. Setting up such a fit is  The atomic weight of the mass in amu widths The width of the peak. If this is set to a single number the width will be fixed to that value. If it is set to an iterable (tuple or list) of three values the middle value is the starting value and the first and last values are the constraints on the parameters fit. function The function to use to fit this mass. Options are currently either Gaussian or GramCharlier.

hermite coeffs
Only applicable when using GramCharlier. This is a list of coefficients for each mass being fitted. If set to one the term is included within the fit. If set to zero it is excluded from the fit.

k free
Only applicable when using GramCharlier. If this flag is set to true the FSE ("Final State Effects") coefficient is not tied to a value. If false it is set to a value dependent on the sears flag.

sears flag
Only applicable when using GramCharlier. If the k free flag is set to false, this flag will control what the FSE coefficient gets tied too. If set to one it is tied to σ √ 2 12 which is harmonic limit of the magnitude of the FSEs.  very similar to the procedure described for the Gaussian approximation. Each mass being fitted using the expansion requires some additional parameters describing the Hermite coefficients to be used in the fit and what the Final State Effects (FSE) coefficient should be tied too. Table 6 shows an example of setting up such a fit using the data for the ZrH 2 sample. In order to fit the data to determine the momentum distribution the raw data needs to first be normalised by the area of the peak. This removes the effects of different detector efficiencies and solid angles. The MANTID algorithm NormaliseByPeakArea has been created to handle this step. This algorithm effectively directly replaces the implementation of the isofile command in the original data analysis package [39]. This algorithm will: (i) Transform the fitted data to y-space using the algorithm ConvertToYSpace for a single mass. (ii) Fit the peak in y-space. (iii) Divide the time of flight data by the area of the fitted peak in momentum space.
The NormaliseByPeakArea algorithm (see Table 7) produces four workspaces: • OutputWorkspace -This workspace is the time-of-flight workspace supplied as input to the algorithm normalised by the area of the fitted peak. • YSpaceDataWorkspace -This is the time-of-flight workspace converted to y-space using the ConvertToYSpace algorithm.  The final step in analysis is to simultaneously fit data across all detectors using the normalised workspace created as part of the previous section while keeping the widths of each peak tied (see Figure 4). This roughly emulates the program isofileu described in Ref. [39]. This global fitting option is still currently under development.

Diffraction
Diffraction on VESUVIO is not yet fully implemented within MANTID. As the reduction of diffraction data is fairly trivial in comparison to the other requirements of VESUVIO data analysis, this can be handled by the existing IndirectDiffractionReduction routine that is used by other indirect geometry instruments. Preliminary trials with the existing implementation for other indirect instruments have shown that this should simply be a matter of adding the appropriate parameters for monitor thickness, attenuation, and area to VESUVIO's instrument parameter file.

Resolution Calculation
Calculation of the resolution of a particular mass in a sample can be performed using the calculate resolution function in ncs.py. This uses the same method to calculate the resolution that is used in the fit function described in Section 5.5. The output of running this function is a workspace with a single spectrum for the calculated resolution. Figure 5 shows a plot of the resolution for hydrogen and Table 8 shows the PYTHON code that generated the workspace shown in the plot.

Calibration of Instrument Parameters
The calibration routines for VESUVIO have been implemented as two MANTID algorithms following the procedures described originally in Ref. [44].
The first algorithm, called  Figure 5. Plot of the resolution workspace generated using data in Table 8. 1 import ncs 2 runs = "14188-14195" 3 spectra = "135-198" 4 diff type="SingleDifference" # Allowed values=Single, Double, Thick 5 ip file = "IP0004 10.par" 6 raw ws = LoadVesuvio(Filename=runs, SpectrumList=spectra, 7 Mode=diff type, InstrumentParFile=ip file) 8 raw ws = CropWorkspace(raw ws, XMin=50.0, XMax=562.0) 9 mass = 1.0079 10 raw ws = ConvertToYSpace(raw ws, mass) 11 ncs.calculate resolution(raw ws, mass) EVSCalibrationFit, is used to fit sample data in order to accurately obtain the values of the parameters for the instrument. A second MANTID algorithm built on top of the first is used to set up and run the fitting does the actual calculation of the instrument parameters called EVSCalibrationAnalysis. These two algorithms should only be run by instrument scientists and a calibration parameter file does not need to be recreated for every data analysis session. The calibration fit program can either fit using a list of incident energies to calculate the expected centre point of a recoil peak in time-of-flight data or by taking a list of d-spacings and calculating the position of Bragg peaks. The algorithm also requires a file containing a set of reference parameters with which to calculate the expected peak positions. This is analogous to the procedures described in Ref. [7] where hand measured parameters were used as starting values and the fitting program used these to incrementally converge on the true value of the instrument parameters.
The analysis program makes use of the fit program to fit all of the parameters in the order defined by the original VESUVIO calibration paper [44], starting with the incident flight path and time delay using well defined uranium sample runs, then computing the values of the final energy and hence the final flight path and finally the scattering angles for all detectors (see Fig. 6).

GUI
VESUVIO does not currently have any GUI support within MANTID. Focus on development has been to get the underlying reduction and analysis routines working before focusing on usability. The current plan is for VESUVIO to have a completely new GUI listed under the indirect geometry section of MANTID. The current design would be to have a series of three tabs on the interface which would each deal with a separate part of reduction and analysis.
• Loading: This tab would broadly handle the procedures described in section 5.1 and would provide a user interface for using the LoadVesuvio algorithm to get raw data into MANTID as well as providing plotting functions for examining the captured time-of-flight data. • Corrections: The corrections tab would provide a user interface for calculating both multiple scattering and gamma background corrections and applying them to data loaded in the first tab. • Fitting: The fitting interface is the most complex in the series. This will provide support for setting up a fit using the same procedures used in the ncs.py module, but in a more user friendly manner than the current implementation achieves. This would provide support for both the Gaussian and Gram-Charlier functions as well as the ability to set the intensity constraints and Hermite polynomial expansion coefficients. This is simply a loose plan based on previous discussions. The number and function of the tabs on the interface may change as development progresses. A proper design cannot be produced until the underlying framework is finalised. For example, there is a currently goal to support fitting a sample directly in y-space. It may be possible to integrate this with the fitting tab mentioned above, or depending on requirements, may be split to a fourth tab. Global fitting may well also require yet another separate interface. Plot of some raw time-of-flight data using the NCS plotting module using the script in 9. Checking the spectrum numbers in the key shows that the scattering angles of 33 and 32 degrees have been plotted.

Visualisation
VESUVIO analysis requires a few custom plotting commands to display data in ways which are not currently supported by the general MANTID framework. The final tab in the series would provide a user interface to allow the user to examine their data more easily with some helper functions which exist in the NCS plotting.py module. This is provides a single plot function with options to plot data by spectra, scattering angles, or detector banks. This replicates the functionality for the various plotting routines of the old data analysis package [39]. Table 9 shows a basic example of plotting some spectra from a raw workspace by angle using the NCS plotting module. Figure 7 shows the resulting plot. Table 9. Example PYTHON code showing how to plot spectra in a workspace within the scattering range of 30-35 degrees using the NCS plotting module.

Conclusion
MANTID, the Manipulation and Analysis Toolkit for Instrument Data, is an open source and cross platform data analysis application specialising in neutron and muon scattering data. Recent development work undertaken to improve support for the indirect geometry spectrometer VESUVIO at ISIS, described in this work, demonstrates how MANTID can contribute to the success of neutron Compton scattering at providing unique insights into nuclear quantum dynamics of light nuclei in condensed matter and Mass-selective Neutron Spectroscopy of heavier nuclei important in the studies of functional materials.