HORACE: software for the analysis of data from single crystal spectroscopy experiments at time-of-flight neutron instruments

The HORACE suite of programs has been developed to work with large multiple-measurement data sets collected from time-of-flight neutron spectrometers equipped with arrays of position-sensitive detectors. The software allows exploratory studies of the four dimensions of reciprocal space and excitation energy to be undertaken, enabling multi-dimensional subsets to be visualized, algebraically manipulated, and models for the scattering to simulated or fitted to the data. The software is designed to be an extensible framework, thus allowing user-customized operations to be performed on the data. Examples of the use of its features are given for measurements exploring the spin waves of the simple antiferromagnet RbMnF$_{3}$ and ferromagnetic iron, and the phonons in URu$_{2}$Si$_{2}$.


I. INTRODUCTION
Neutron spectrometers at central facilities around the world are routinely used to measure the wave-vector, Q, and energy, ω, dependency of the spectrum of lattice dynamics and magnetic excitations, S(Q, ω).These data can provide detailed information about the strength, range and symmetry of the interatomic and magnetic interactions, and consequently are highly sensitive tests of theoretical models.The triple-axis spectrometer (TAS) at research reactors has traditionally been the instrument of choice because of its controllability and flexibility 1 , whereby the S(Q, ω)dependency is explored point-by-point.Over the past 15-20 years time-of-flight spectrometers with position-sensitive detectors (PSDs) have established themselves as extraordinarily effective instruments for measuring excitations in single crystals where the interactions are strong in one or two dimensions, for example in the cuprate and ironbased superconductors [2][3][4][5][6][7][8][9][10][11][12][13] and quasi one-and two-dimensional model magnetic systems [14][15][16][17][18][19][20] .However, until recently there have been relatively fewer measurements in systems where there are significant interactions in all three spatial dimensions.By combining many separate runs, each with a different crystal orientation, into a single data set, complete measurements of the four-dimensional scattering function S(Q, ω) can be made.This has become possible through the combination of the latest instruments with large solid angle position sensitive detector arrays [21][22][23][24][25] and, crucially, optimized software to visualize and manipulate the massive data sets that are created.
Here the software application Horace is described, which is in routine use at several neutron facilities and by their users for the visualization and analysis of such data sets.This paper describes the background to the experimental method, and the principles of Horace are outlined.The features of the software are described in detail, together with a summary of how it is practically used, with examples that illustrate its operation and features.Details of computer hardware requirements, download and installation are also summarized.

II. THEORY
FIG. 1. Schematic of the Merlin chopper spectrometer, at the ISIS spallation neutron source.A white beam of neutrons from the source moderator are incident from the bottom left in this schematic.The principles of operation are described in the text.Such instruments are ideally suited for the technique of combining multiple datasets, with their high flux and large solid angle detector coverage enabling rapid surveys of the 4D scattering function S(Q, ω) to be undertaken.
Fig. 1 shows a schematic diagram of the Merlin spectrometer 22 at the ISIS spallation neutron source at the STFC Rutherford Appleton laboratory in the UK, an example of the latest generation of direct geometry spectrometers.In this example, a pulse of protons hits the spallation target every 20 ms to produce a pulse of neutrons.These are rapidly slowed down in a moderator to produce a pulse of neutrons with characteristic width measured in microseconds, but with a spread of useable energies in the instrument of ∼ 10 meV -∼ 3 eV.A monochromatic pulse of neutrons with the desired energy E i is selected by correctly choosing the phase of a rotating collimator (Fermi chopper), or system of disk choppers, just before the sample.The sample scatters neutrons, and on Merlin these are collected by a three steradian position sensitive detector array.The time of arrival with respect to the proton pulse of each scattered neutron is recorded together with its location on the detector array.Because the moderator-to-sample distance x 1 is known, as is the sample-to-detector distance x 2 for each detector element, the magnitude of the scattered wave vector for each recorded neutron is determined by the time-of-arrival at the detector, t det : where t samp = (m N / ) • (x 1 / k i ), is the time the monochromatic pulse hits the sample, k i is the magnitude of the incident wave vector given by E i = 2 k 2 i / 2m N , and m N is the mass of the neutron.The momentum and energy transferred to the sample are then computed as For a chosen k i and sample orientation, there are three independent degrees of freedom, corresponding to the spherical polar angles θ and φ that define the direction of k f , and the time-of-arrival t det which in turn has a oneto-one correspondence with energy transfer, ω, or equivalently with k f ≡ |k f |.In consequence, the momentum and frequency dependent scattering function S(Q, ω) is measured on a 3D manifold in the four dimensions of Q and ω, with the volume defined by the ranges of θ and φ set by the size of the detector array, and −∞ ≤ ω ≤ E i .Equivalently, in any particular choice of coordinate frame for Q, then of the four coordinates only three components are independent, with the fourth an implicit function of the other three.We note that a similar line of reasoning can be used for indirect geometry spectrometers, for which the final energy E f is fixed and the time-of-flight is used to determine k i .
The physically relevant coordinate frames in which to express the components of Q are ones that are fixed with respect to the crystal lattice.For example, one may choose the components along the reciprocal lattice vectors a*, b* and c*.A good choice of coordinate frame and of which component of {Q α } is the implicit coordinate will depend on the material being studied.For example, in some magnetic materials such as the parent high temperature superconductor compound La 2 CuO 4 26 , the magnetic ions are arranged in layers, with the magnetic exchange parameters between the layers orders of magnitude weaker than those within the layers.In this case, the best choice of coordinate frame is one with components Q 1 and Q 2 within the layers and Q 3 perpendicular to the layers.Because the interactions between the layers are negligible, S(Q, ω) has negligible dependence on Q 3 .In this instance, Q 3 is taken to be the implicit variable, and the intensity as a function of (Q 1 , Q 2 , ω) gives the relevant information of S(Q, ω).Typical plots of S(Q, ω) at a constant energy are thus projected along the physically uninteresting Q 3 -axis.In quasi-1D magnets, where the interactions are strong only along one direction -label it Q 1 for definiteness -then Q 3 can be ignored as the implicit variable and the intensity integrated along Q 2 to improve the statistical quality of the data, and intensity as a function of {Q 1 , ω} gives the full information of S(Q, ω).These techniques have been used for many years to study quasi-1D and quasi-2D materials [2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19][20] , and there are established software applications to visualize the data 27,28 .Though it is possible to use the same techniques and software tools to analyze data from 3D materials 29,30 , such analysis is far from routine.
In the case of Merlin the number of detector elements is ≈ 70, 000, which is is typical of the number for similar instruments at other sources, and the energy transfer axis is typically divided into ≈ 200 energy bins, so that the 3D manifold is divided into O(10 7 ) voxels.Typically there will be six 8-byte numbers associated with each voxel -{Q α }, α = 1 − 4, intensity and error on the intensity -which accounts for the bulk of any representation of the data set, which in the case of MERLIN amounts to ≈ 0.5 GBytes.This is sufficiently small to fit easily into the memory of a commodity PC.
To map S(Q, ω) fully in materials with interactions in all three spatial directions requires an extra degree of freedom.A sequence of data sets is collected, in which an additional parameter is successively incremented between each data collection, or 'run', and the entire collection of data sets is treated as one.Two approaches are possible for use with Horace: 1. Rotate the sample about an axis (usually vertical) by some angle, Ψ, typically 0.5 • − 2 • between each run, while keeping the incident neutron energy E i fixed (in the case of an indirect geometry spectrometer the final neutron energy E f is fixed).The range of the angular scan is usually determined by the reciprocal space coverage of the instrument's detectors and the symmetry of the crystal lattice.This method of operation is the one most frequently used.
2. Keep the sample orientation fixed, but increment the incident energy E i by a small amount between runs.This mode is very rarely used, since the scan range in E i must be kept small in order to avoid too much variation in the instrumental resolution between runs, and this results in rather limited reciprocal space coverage.For the following we shall ignore this option in our description of the method, and focus on sample rotation.
Although the program does allow runs with different orientation and incident energy to be combined, this is generally not advisable since this can result in a multi-valued resolution function for a given (Q, ω) voxel with different E i and ψ, making interpretation and analysis or the data much more difficult.
With these choices is measured in a 4D manifold.The choice of increment in the additional parameter is based on consideration of the resolution of the instrument.The angular divergence of both the incident and scattered neutron beams is 0.5 • − 1 • for current chopper spectrometers, and the energy resolution is typically ∆ ω / E i = 1 − 6%.With continuous streaming of data to disk as a function of absolute time rather than time relative to the most recent proton pulse (that is, event mode collection), then Ψ can in principle be varied continuously, avoiding discretization of data along the corresponding coordinate axis 31,32 .In practice, however, runs at different Ψ usually are discretized in order to simplify matters in case of equipment failure part-way through a set of measurements, so that 'bad' runs may be easily eliminated.

III. PROGRAM DESCRIPTION A. Main Purpose
The main purpose of Horace is to allow easy visualization, manipulation and analysis of inelastic neutron scattering data, gathered from multiple crystal orientations or incident energies as described above, in the four dimensions of vector momentum and energy.Horace provides a comprehensive set of elemental functions as an extensible framework for analyzing the data, in which more complex scripts or functions can be rapidly written by users.A guiding principle in the design of Horace was that it should be possible to run on a high specification laptop or commodity desktop computer, and would pre-process the data to minimize the time to create and visualize subsets cut from the data, despite that hardware constraint.

B. Architecture and key features
Horace has been written with an object oriented architecture in the commercial high-level technical programming language Matlab 33 .The primary object is the sqw object: this contains the signal and variance for each individual detector-energy voxel, meta information describing the detector locations, crystal lattice and crystal orientation for each contributing measurement, and the mapping of the voxels into a Cartesian grid that defines the current plot axes and bin sizes in one, two, three or four dimensions.In addition there is the dnd object: an abbreviated version of the sqw object that does not retain the information of the individual voxels or the detector locations.Generally a dnd object will occupy several orders of magnitude less computer memory than the equivalent sqw object.
The operations that are supported on sqw and dnd objects include: • Construction of 4D sqw data from multiple measurements of inelastic neutron scattering data.
• Creating new sqw objects by taking 1D, 2D, 3D and 4D sub-manifolds from the original sqw object, or any other sqw object created by cutting from a previously created sqw object.We define these as cuts; the axes of the cuts can be chosen to be in arbitrary directions in momentum space, or energy.
• Unary operations e.g.correction for the detailed balance factor, as well as the standard operations such as sign inversion and trigonometrical functions.
• Replication of a lower dimensional cut along the additional axes of a higher dimensional cut .This is useful e.g. for creating background estimates to be subtracted from the higher dimensional cut.
• Simulation and fitting of models of the scattering function S(Q, ω).
In addition, there is a tool for planning the range of crystal orientations at which to make measurements in order to map a desired volume of momentum and energy, and utilities for plotting data or models of dispersion relations and the scattering function as a function of energy and momentum along a sequence of high-symmetry directions in reciprocal space.Examples of the use of these operations on illustrative data sets will be given in Section V.
In order to satisfy the requirement that Horace can operate on a commodity personal computer and to minimize the time to make a cut, the data are coarse-grain sorted on to a regular 4D grid in the (Q, ω)-space (by default fifty steps along each dimension), and then saved into a single (generally large) file with the extension .sqw.The advantage of this sorting when the data are saved to file is that to access a particular volume of reciprocal space and energy window, which is typically the case when visualizing and analyzing a 1D or 2D cut, the entire large sqw file need not be read from disk to search for contributing detector voxels.Instead, just the data in those bins in the grid which intersect the reciprocal space volume and energy window of the cut need to be read.This provides a significant saving of time when extracting such subsets, and is one of the key features of Horace compared to its predecessors.

C. Interface
Every operation that Horace can perform has been written as a Matlab function.There are two possible ways of interacting with the program.The first, and most common, is through the Matlab command line, or for more complex sequences of commands through the user's own Matlab scripts or functions.An example of Horace in use with the Matlab command line is shown in Fig. 2(a), together with two plots generated during the series of commands shown.In this particular case a cut is taken from a file and plotted.The cut is then symmetrized in two planes, and the result of this operation is also plotted.The second method for interacting with Horace is through a graphical user interface (GUI), shown in Fig. 2(b), which allows access to a subset of the functionality of the main program chosen to allow execution of the most common and / or simplest tasks.Note that use of the GUI still requires Matlab to be installed on one's computer.

D. Operation
Practical operation of Horace is a two-stage procedure.The first, pre-processing, stage is the creation of the sqw files, which is done for on-the-fly analysis during experiment as data accumulate, and then usually once at the end of an experiment to create reference sqw files for later analysis.These are created from multiple individual run files, which contain the measured scattering intensity S(Q, ω) for each detector as a function of energy transfer.Such files are created from the raw time-of-flight data, with correction for detector efficiency, absorption by the sample, etc. using, for example, the Mantid software 34 .Each individual run file is sorted on to a common 4D grid, and then the sorted files are combined a piece at a time into the final sqw file.This file-backed combination limits the memory that is required, which is crucial when one considers the size of the final sqw file, which can typically range in size from 10 to 500 GB.
Once the sqw file has been created, cuts of any dimensionality can be taken and any of the manipulations detailed in Sec.III B applied to them.We include in this the ability to plot 1D, 2D, and 3D cuts, since this is the way in which the user typically interacts with the data.A typical workflow might be to take a series of cuts and plot them to investigate some region of interest, apply some corrections (e.g.magnetic form factor, background subtraction, or Bose-Einstein population factor), then simulate and fit a model to these data in order to extract some physically meaningful parameters.

IV. ILLUSTRATIVE EXAMPLES -RBMNF3, FE AND URU2SI2
We will give a basic illustration of some of the functionality of Horace with reference to data taken on the following three examples, RbMnF 3 , iron and URu 2 Si 2 .RbMnF 3 has a cubic crystal structure and is very close to being an ideal 3D Heisenberg antiferromagnet.It has a large spin (S = 5/2) on its Mn 2+ sites, making it a strong magnetic scatterer of neutrons.It has a nearest-neighbor isotropic exchange constant of J = 0.29 meV, and a nextnearest-neighbor exchange constant that is an order of magnitude smaller 35 .Iron is the canonical example of an itinerant-electron metallic magnet.Below about 100 meV sharp spin waves have been shown to exist 36 , but timeof-flight inelastic neutron scattering experiments have also shown that spin fluctuations persist up to much higher energies of at least 550 meV 37 .The data shown here will be the subject of future scientific reports, and are used here for illustrative purposes only.URu 2 Si 2 has been actively studied for many years due to the mysterious 'hidden order' that it exhibits 38 , which is responsible for a large change in entropy but cannot be explained by a conventional order parameter such as dipolar magnetic order.Recent interest has focused on whether the lattice is coupled to the hidden order parameter, and several studies of the phonons have been published 39,40 .The data we show here are in agreement with the already-published work, but cover a much larger volume of reciprocal space by virtue of the fact that we used the method of data collection outlined in this paper.

V. USE OF THE PROGRAM
We now provide a more comprehensive discussion of how the program is typically used.The first step when performing an experiment is often to determine an appropriate choice of instrument parameters, such as incident neutron energy and range of sample orientations to be scanned.Different combinations give access to different regions of reciprocal space, and with the limited time available to run an experiment it is crucial to decide quickly the right instrumental configuration.To help with this a standalone GUI is provided with Horace, the 'scan planner'.Given a set of basic inputs concerning the lattice parameters and angles, sample orientation, instrument detector positions and incident neutron energy, the program plots the volume of Q-space covered by those detectors for a given energy transfer.To aid the planning process the volume is semi-opaque and colored according to the sample orientation angle, and the positions of integer (H, K, L) are plotted as black spheres.An example screenshot is shown in Fig. 3.

B. Combining multiple data files
The selection of individual run files to combine into an sqw file may be performed either in a Matlab script or through the GUI.Metadata about the experimental setup for each run must be manually provided by the user, specifically the incident energy, sample orientation, lattice parameters and lattice angles.For the RbMnF 3 data set we combined 85 individual measurements at different sample orientations, each of which was 122 MB, taken on the MAPS time-of-flight neutron spectrometer at ISIS 21 .The scattering plane was (1, 1, 0)/(0, 0, 1) and Ψ was scanned from 6 • to 90 • in 1 • steps.The resultant sqw file was 15 GB, and additional working space of about the same size on disk as the sqw file was required during its creation.For the iron data set, also obtained on the MAPS spectrometer, 186 runs were combined to make a sqw file of 36 GB.The scan was performed with the (1, 0, 0)/(0, 1, 0) scattering plane, and Ψ scanned from −92.5 • to 0 • in 0.5 • steps.The URu 2 Si 2 dataset was obtained on Merlin, and comprised 276 runs which combined gave an sqw file of size 136 GB.Generally speaking a larger number of runs and / or instruments with a larger number of detector elements give rise to larger sqw files, which take commensurately longer to generate.
Speed-up of the creation of the sqw file, and other computationally intensive operations such as taking cuts (see below), is achieved by using C++ routines in place of Matlab ones.These are invoked using Matlab's in-built mex file system 33 , whereby Matlab routines may call subroutines written in another language.The C++ routines utilize both multi-threaded processing as well as the intrinsic speed gains that are typically obtained when comparing an interpreted language (Matlab) with a compiled language (C++).
The time taken to perform the combination of files is highly dependent on the computer on which it is performed.For benchmarking we used a sqw file of size 142 GB, which comprised data from 231 runs.On a Windows 7 workstation with available disk space of several TB (i.e.much more than the sqw file size), with 48 GB RAM and running 12core Intel Xeon X5650 processors (2.67 GHz), the total time to generate the sqw file was 150 minutes when using Matlab 2015b (later versions of Matlab include internal multi-threading procedures, which offer similar speed to Mex acceleration in this case).On a machine running CentOS7 with the same hardware, and with Mex file acceleration enabled and running on 8 threads, the total optimized time was 52 minutes.However, recent versions of Horace contain extensions to the code that allow better utilization of high performance computing capabilities that are increasingly available.By way of example, the ISIScompute service available to ISIS facility users, which comprises a machine running RHEL 7 with 96 Intel Xeon E5-4657L processors (2.5 GHz), 512 GB of RAM and a 100 TB CEPH parallel file system 41 , is able to produce the same 142 GB file in around 8 minutes.
We have noted already that Horace has been designed to be operable on a typical commodity PC, which may well have a lower specification than that described above for our benchmarks.Provided sufficient disk space is available to store the sqw file and the temporary working space needed during its creation, lack of RAM and CPU speed need not prevent the operation of Horace.Options are provided whereby the size of chunks read from disk to memory for processing can be changed, so for a PC with less RAM these numbers can be reduced appropriately.The time taken to generate files and take cuts from them will increase, and the number of sqw objects that can be held in memory is smaller, but otherwise the full functionality of Horace is available.
During a typical experiment the user will often wish to examine data from a partially complete scan of sample orientations, in order to make decisions about what future measurements to make.Rather than regenerating the entire sqw file when more runs have been completed, it is possible to provide a list of planned runs and sample orientations, so that future data may be binned on to the same coarse-grained grid and inserted into the existing sqw file, thus saving time, especially with larger files.

C. Extracting and visualizing data
Once the sqw file has been created, Horace is also used to visualize and analyze the data.Typically users wish to sample 3D volumes, 2D slices and 1D cuts along specified trajectories in (Q, ω)-space.As mentioned in Sec.III B, we refer to such subsets in general terms as 'cuts'.Horace provides complete flexibility to cut along any Q-direction, or along the energy direction, irrespective of the orientation of the sample with respect to the instrument.When making a cut the user specifies a grid onto which data are binned, with the bin sizes chosen typically to contain data from many detector voxels.It is at this stage that the coarse grain sorting of the data during the generation of the sqw file, described earlier, provides a significant speed advantage since only a small fraction of the total (very large) file needs to be read to obtain all the information required for any given cut.Once these cuts from the data are read from disk they are stored in memory and are accessible as objects in the Matlab 'workspace', so that provided sufficient computer memory is available multiple cuts may be retained for future visualization and/or analysis.Every cut has the same structure as the data in the sqw file, so further cuts may be taken from objects in memory without loss of information.Horace provides tools to visualize 1D, 2D and 3D cuts as, respectively, marker plots with errorbars, colormaps, and multiple colormaps plotted on a 3D set of axes, examples of which are shown in Fig. 4.These plots are highly customizable, and because the plots are ultimately generated using Matlab's native graphics they can also be modified using the in-built routines.It is thus fairly common that Horace is used directly to produce figures that are used in publications, in addition to being used for the analysis [42][43][44][45][46][47][48][49][50][51][52] In order to survey a large section of reciprocal space (i.e. a 3D cut) the sliceomatic tool 53 is used.A screen-shot of sliceomatic in use is shown in Fig. 4a, with the intensity of the scattering given by a color map.Dispersive excitations with the same periodicity as the Brillouin zone are clearly visible.The user may move the visible slice planes on this interface, in order to explore a large section of the data very quickly.Fig. 4b shows a 2D slice, centered on the (1/2, 1/2, 1/2) position with axes of (1/2, 1/2, L) and neutron energy transfer.The slice clearly shows scattering from a band of dispersive magnetic excitations in the range 0 ≤ E ≤ 9 meV.The white lines at L = 0, L = 0.15, and L = 0.3 show where 1D cuts were made -these cuts are shown in Fig. 4c.The cuts were taken by averaging the signal along L, ±0.05 r.l.u.either side of the stated value.It can often be useful to view the dispersion along several high symmetry directions on a single plot, for example when investigating phonons and comparing to DFT calculations.The Horace tool spaghetti plot can be used for this purpose.An example of its use is shown in Fig. 5 in which we show the phonon dispersion around Q = (2, −2, 0) in URu 2 Si 2 .One can see, for example, the splitting of two different acoustic modes along the Γ -Σ trajectory as well as multifarious modes at higher energies which disperse differently along different symmetry directions.

D. Manipulating data
There are several different ways one can manipulate sqw and dnd objects.Unary operations that apply to the intensity, e.g.Bose-Einstein population factor or magnetic form factor correction of the intensity, and binary operations, e.g.subtraction of the intensity of one object from another (such as required for background subtraction), may be performed.
Data of dnd form may be smoothed by convolution with an appropriate dimensional Gaussian or hat function of a specified width.Such smoothed objects allow a simple way to visualize data part-way through an experiment, before sufficient statistical quality has been obtained through longer measurement times.By definition sqw data may not be smoothed, since the relationship between the intensity that is plotted and the underlying detector voxel information must be maintained for such objects.
It is possible to repeatedly tile a lower dimensional dnd data set into a higher dimensional one, e.g.replicate a 1D cut along the energy axis along some Q-axis to create a 2D cut with axes of Q and energy.This is useful when performing background subtractions, since in some cases the intrinsic background may depend on energy but weakly or not at all on Q.Thus a 1D cut along energy may be taken in some region where there is only background, and then this can be subtracted from another region of the data to leave just the contribution to the signal from the intrinsic S(Q, ω).An example of such a procedure is shown below in Fig. 6 for the iron dataset.Here, a region (highlighted by the dashed rectangle) is selected that is representative of the non-magnetic background and a 1D cut is performed (panel b).This cut is then replicated over the full Q-range of the original 2D slice (panel a) and then subtracted (panel c).

E. Simulating and fitting
Horace provides the ability to fit and simulate (which is simply a single evaluation of a fit function) the data for precisely the same values of (Q, ω) that were measured.Models for fitting can take two forms, either generic functions of the plot coordinates (e.g.Gaussian peaks and the like) or more physically meaningful models that calculate S(Q, ω) directly.The former is useful for fitting, for example, peak functions on 1D cuts to give a quick parameterization of a dispersion relation.The latter are much more powerful, and can be used to determine physical parameters directly from the data.
It is particularly for the fitting of S(Q, ω) models that the full detector voxel information retained in sqw objects is most useful.The model function is evaluated for all of the voxels, and then combined to give the intensity in a particular (Q, ω)-space bin, rather than just at the bin center as would be the case for a dnd object.For models where S(Q, ω) varies appreciably across the width of one bin, this can result in systematic problems if evaluating only using dnd objects, whereas sqw objects generally provide a more accurate fit.On the other hand, because there are usually many detector voxels contributing to the signal in a given bin, evaluation of a model using an sqw object can take much longer due to the greater amount of computer processing required.
The fitting routines provided with Horace are designed to work to a high level of abstraction.A key feature of the fitting capability of Horace is that fits can be performed on an arbitrary number of cuts of any dimensionality, using a global model with global parameters.The fit routines allow a distinction between 'foreground' (often global) and 'background' (usually local to each cut), with the former typically being a model of S(Q, ω) and the latter being generic function(s) such as a linear sloping background.This distinction is especially powerful when fitting multiple cuts, since a larger part of the overall dataset can be used to constrain a model, achieving higher accuracy, while allowing for the fact that the instrumental background often varies in unusual ways from cut to cut.Such a philosophy for the fitting was developed in recognition of the form that real data take.As is the case for most fitting procedures, one can specify which fit parameters can vary or remain fixed, and can also bind parameters together in a fixed ratio.Fit functions can take as inputs information of any form (e.g.lookup tables, as well as numeric parameters).Instrumental resolution broadening can at present be included in a crude way as part of the fit function, such a applying a Gaussian broadening in energy, but a specific model for instrumental resolution is not included in Horace at the moment.

VI. SUMMARY
We have written a suite of programs, Horace, to take multiple runs from time-of-flight neutron inelastic scattering experiments, and combine them in one single large data set that can be hundreds of GB in size.The program is designed to be an extensible framework that allows a range of sophisticated manipulations to be performed on the data.The program is also used to visualize subsections of the large data set, with a coarse grained sorting of detector voxels' (Q, ω) coordinate ensuring fast access to the relevant subsection of the large data file.The program may also be used for simulations and fits to the data with S(Q, ω)) models.This includes the ability to fit multiple datasets with a global foreground model and set of parameters, but independent background models and parameters.This is a method geared towards the physical origin of the measured signal, and provides a convenient framework for performing the kind of analysis which is often done in an ad-hoc fashion otherwise.

VII. DISTRIBUTION AND DOCUMENTATION
Other than sufficient disk space to store the spe and sqw files, whose sizes are rather dependent on the instrument used for the measurements, the main hardware requirement is to have at least 8 GB of RAM.It has been found that less than this severely hampers the user's ability to exploit Horace fully with their data.Horace has been tested on the following operating systems: 32-bit and 64-bit Microsoft Windows, 64-bit RHEL 6 and 7, and Ubuntu Linux 10.04 and later, and on Mac OS X 10.5.6 and later.Horace is written using Matlab, and has been tested on Matlab versions 2009a onwards.Horace will continue to be supported in the future for at least the most recent five years' worth of Matlab versions.Horace is actively maintained for the above operating systems, but in principle, provided one is able to run a sufficiently recent version of Matlab, it should be possible to run Horace no matter what the operating system (e.g.other Linux distributions) without Mex files.The C++ code is also available for the user to perform their own compilation of Mex files if desired.
Zip files containing the compiled Horace Matlab code can be downloaded from http://horace.isis.rl.ac.uk.The full source code is available on request.Users are requested to register an email address when they download the code from the website, so that they can be informed from time to time of new releases and bug-fixes.Installation involves simply unzipping the download into a suitable directory, adding this directory to the Matlab path, and running a short Matlab routine called horace on to initialize a more complete and self-consistent set of search paths for Matlab.A full manual, giving complete instructions on installation and use, is also available at this website.

FIG. 2 .
FIG. 2. (a) screen shot of the Matlab command window, showing a series of commands to extract a 2D cut from a file, plot it, symmetrize in two planes, and finally plot the result.The outputs from the various operations are also shown in the command window, as are the two plots of the unsymmetrized and symmetrized data.(b) screen shot of the Horace GUI, with fields filled in to make the same cut as shown in panel (a).

FIG. 3 .
FIG. 3. Screen shot of the Horace scan planner, illustrating how the reciprocal space coverage for a given instrument, incident energy and scan range combination may be calculated in advance of performing the measurements.

FIG. 4 .
FIG. 4. Plots of data from the experiment on RbMnF3.Panel (a) shows a screen-shot of the sliceomatic feature of Horace, which allows visualization of 3D cuts.Panel (b) shows a 2D slice in the (0.5, 0.5, L) -Energy plane.The white lines show regions where 1D cuts were taken.Panel (c) shows three 1D cuts for L = 0 (red circles), L = 0.15 (blue triangles), and L = 0.3 (black squares).

FIG. 6 .
FIG. 6.(a) Representative (Q, E)-slice showing dispersive magnetic excitations in iron, together with incoherent elastic and phonon scattering.The dashed rectangle shows an area expected to have negligible magnetic scattering and hence representative of the non-magnetic background.(b) Cut through the non-magnetic region in the dashed rectangle.(c) Result of replicating the 1D background cut and then subtracting this from the original data.