It is recommended to write batch files to perform on-line data analysis. A batch file can be created by clicking on the "User Macros" button, or selecting "Edit/User batch files, MACROS" from the menubar. The resulting window is an editor for creating macros and command files. Enter the name of the batch file you wish to create (must end with .prox) in the file name field, e.g. test.prox. The first lines of your command file will usually consist of reading in run numbers, followed by calls to functions to process the data. A number of data processing functions have been written specifically for TOF data analysis which are described here.
a) without absolute normalisation
w1 = rdsum(7272,7280) ;
read sample run w1 = normalise(w1,/monitor) w2 = rdrun(7303) ; read empty run w2 = normalise(w2,/monitor) w3 = w1 - w2 ; Subtract the background e3 = sqrt(e1^2 + e2^2) ; Propagate the errors
w20 = rdrun(7271) ;
read vanadium run |
b) including absolute normalisation and attenuation corrections
w1 = rdsum(1055,1057) ;
read and sum sample runs w1 = normalise(w1,/monitor) w2 = rdsum(917,918) ; read and sum empty runs w2 = normalise(w2,/monitor) w3 = rdsum(966,967) ; read and sum cadmium runs w3 = normalise(w3,/monitor)
|
w1 = rdsum(7272,7280)
; read and sum sample runs (50K) w20 = rdrun(7271) ;
read vanadium run w8 = vnorm(w7,w20,min=150,max=170)
; Normalise w7 to vanadium |
All the functions automatically look up the name of the instrument associated with the LAMP session and process the data accordingly. The energy transfer convention is the usual one : neutrons losing energy at the sample (down-scattering) arrive at positive energy transfer, up-scattered neutrons at negative energy transfer. The function source code can be found under the "TOF" heading in the file list at the left hand side of the "User Macros" window. They are extensively commented and users (and instrument responsibles and local contacts) and encouraged to look at the source code for details. None of the routines use separate graphical interfaces. This enables them to run directly from a batch file, which then contains a complete record of the data reduction procedure. In addition, all workspace manipulations using these functions are recorded in the workspace subtitle (other_tit), which appears in print-outs for future reference.
corr_tof | remove_spectra |
elastic | rescale_t |
estrip | slab_tof |
input | smooth_bkgd |
lineup | sqw_interp |
normalise | sqw_rebin |
output | sumbank |
output_allqs | t2e |
qstrip | vnorm |
reb |
Corrects data in TOF for energy-dependence of detector efficiency, frame overlap and time-independent background. Calling procedure:
w6=corr_tof(w5[,/det_eff][,/frameoverlap][,/bkgd]) |
The three keywords (/det_eff, /frameoverlap and /bkgd) are optionally included to apply the corrections or not
![]() | /det_eff: For IN6, it uses the expressions given in ILL
internal report 83BL21G by Y. Blanc: ![]() ![]() ![]() ![]() ![]() ![]() ![]() For IN5, no accurate description is available, due to the large variation in quality between the detector tubes. I have taken the expression used on D7: ![]() The above expressions are all normalised to 1 at the elastic peak position. |
![]() | /frameoverlap: This correction is appropriate if there is no
frame overlap from short times over into long ones, i.e.
if the beginning of the time frame is chosen such that
the measurement starts at very large negative energy
transfer (up-scattering) compared to the temperature
scale of the sample. In this case, all up-scattered
neutrons arrive at the correct position in the time frame
and frame overlap occurs only for down-scattered neutrons
which appear at short times in the subsequent time frame.
It assumes that S(Q,![]() ![]() ![]() ![]() ![]() |
![]() | /bkgd: This is a
useful correction if there is no empty can measurement
available, to avoid the data "blowing up" at
large energy transfers after transforming from TOF to ![]() ![]() |
Finds the elastic peak position for each spectrum and puts them into the output workspace. Calling procedure:
w2 = elastic(w1, min=<min>, max=<max> [,/save]) |
The two arguments (min,max) specify the time channel range in which to search for the elastic peak. Time channels are defined to run from 1 to n, where n is the number of channels. If these arguments are omitted, the routine searches in the region (+/- 30 time channels) of the elastic peak position specified in the input workspace parameter block. The peak position is found by least-squares fitting a Gaussian plus a flat background to each spectrum. The optional keyword - /save - may be included to save the elastic peak positions for each detector in a file called "elastic.dat"
Rebins data to regular-grid S(Q,) at a single
constant-
value. Calling
procedure:
w2=estrip(w1,E=<evalue>,dE=<dE>,dQ=<dQ>) |
It extracts data lying on a single constant- strip in the Q-E
plane, centred at
= E. The three arguments (E,dE,dQ) specify
the Q-E range to extract as follows:
![]() | E: The centre of the constant-![]() ![]() |
![]() | dE: The full-width in ![]() ![]() |
![]() | dQ: width of Q-binning (= point spacing in Q of output data) in Å-1. |
The algorithm used is the same as that used in the qstrip and sqw_rebin routines. See qstrip for more details.
Reads standard format ASCII data into a workspace. The file format for 1-dimensional data is three columns: x-data, y-data and error bars, followed by x-caption, y-caption and two titles. For larger-dimensional data sets, another, less portable, format is used. These are the same formats used by output. Calling procedure:
w1=input(file='filename.dat') |
Lines up the elastic peaks in the spectra of a workspace. Calling procedure:
w2=lineup(w1) |
Because there are frequently small
differences between the distance from the sample to individual
detector-groups there can be slight differences in the
time-of-flight channel in which the elastic peak arises. This
function first smoothes each spectrum and then estimates
the position of the maximum. An average of these positions is
taken and then all spectra are shifted so that their elastic
peaks are at the average position. Any peak which is more than 10
channels away from the elastic-peak channel given in the
parameters is not shifted. The new average peak position is
entered in the parameters.
Bear in mind that the counting statistics in an individual
spectrum need to be adequate to enable the elastic peak to be
found. Otherwise the routine does nothing.
Normalises data to monitor or counting time. This should always be the first routine called after reading in the data. Calling procedure:
w2=normalise(w1[,/raw][,/monitor][,/time]) |
The optional keywords /raw,/monitor and /time specify what to normalise to:
![]() | /raw: no normalisation |
![]() | /monitor: normalise to 1000 monitor 1 counts (default) |
![]() | /time: normalise to counting time in minutes. This is dangerous, however, since the counting time is saved in the workspace parameter block. If several runs are added together before calling normalise, the counting time in the workspace parameter block will not be the sum of the counting times, but that of the first (or last) read run. |
normalise finds the monitor peak using a least-squares Gaussian fit and integrates the counts over the peak region, subtracting a flat background. It also sets up the workspace error bars (square root of the counts) and finds the elastic peak position by a Gaussian fit to the sum of all the detectors and puts the value into the output workspace parameter block. For IN5 the sum is performed only over the high-angle detectors (scattering angle > 10 degrees).
Saves workspace data into a standard format ASCII file. The file format for 1-dimensional data is three columns: x-data, y-data and error bars, followed by x-caption, y-caption and two titles. For larger-dimensional data sets, another, less portable, format is used. These are the same formats used by input. Calling procedure:
output, w1, file='filename.dat' |
Saves 2-dimensional workspace data in a series of standard format ASCII data files. The workspace should contain output data of the sqw_rebin routine. The data format for each file is identical to that of output for 1-dimensional data. Calling procedure:
output_allqs, w1, file='filename' |
The workspace data are saved in a series of files with names, e.g.
filename.q000
filename.q005
filename.q010
filename.q015, etc
where the numbers after the 'q' specify the Q-value of the data, i.e. filename.q010 contains the data at Q = 0.10 Å-1. Q-values for which no data exist in the workspace are not saved.
Rebins data to regular-grid S(Q,) at a single
constant-Q value. Calling procedure:
w2=qstrip(w1,Q=<Qvalue>,dQ=<dQ>) |
It extracts data lying on a single constant-Q strip in the Q-E plane, centered at Q = <Qvalue>. The two arguments (Q,dQ) specify the Q-E range to extract as follows:
![]() | Q: The centre of the constant-Q strip to extract, in units of Å-1. |
![]() | dQ: The full-width in Q of the strip to extract. |
The energy binning is unchanged from that of
the input data. The algorithm used to rebin to constant Q is
based on the fact that the detectors on both IN5 and IN6 lie very
close together. The part of the Q-E plane covered by a detector
is represented as a strip of constant scattering angle, centred
at the detector scattering angle and touching the strips from the
neighbouring detectors. Each strip is subdivided into a number of
parallelograms, representing the data points. The constant-Q
strip onto which the data are to be rebinned, is divided into a
number of rectangles, and the value for S(Q,) assigned to each
rectangle is given by
S(Q,
)=
ijS'(Qij,
ij)Aij
where S' is the measured scattering function at constant scattering angle. Subscripts i and j denote detector number and channel number, respectively. Aij is the overlap area between the rectangle in the chosen constant-Q strip and the parallelogram corresponding to point j of spectrum i. The same algorithm is used in the estrip and sqw_rebin routines.
Rebins data to regular steps in with error bar
propagation. Calling procedure:
w2=reb(w1,dE=<dE>[,/forcebin]) |
TOF data is transformed to energy transfer by the t2e routine. The spacing of the points once transformed to
hw is no longer constant. reb rebins the data
to constant energy bin width. The argument dE, and keyword /force specify the binning as follows:
![]() | dE: The desired bin width (= point spacing of output data) in meV. |
![]() | /forcebin : If this keyword is not set, the data are only rebinned where the original point spacing is less than dE. If set, the data are rebinned everywhere, which gives rise to strong correlations between the data points where the original point spacing is greater than dE. |
Removes suspect spectra from a workspace. Calling procedure:
w2=remove_spectra(w1,[s1,s2,s3,...]) |
Spectrum numbers are defined to run from 1 to n, where n is the number of spectra in the workspace. The spectrum numbers to remove should be given in square brackets, separated by commas.
Rescales data measured at one temperature to another temperature, using the Bose thermal population factor. Calling procedure:
w2=rescale_t(w1,Told=<Told>,Tnew=<Tnew>) |
The input data must have energy transfer h as x-axis, i.e.
they must have been passed through t2e.
Told gives the temperature that the data was measured at. Tnew specifies
the temperature that the data should be rescaled to. The idea is
that if nothing changes in the sample apart from the Bose thermal
population factor, rescale_t
can convert data taken at one temperature
to what you would have measured at another temperature. There are
two caveats: Firstly, the elastic peak should not rescale with
the Bose factor, but this routine simply rescales everything
regardless of physical origin. It is therefore incorrect for the
elastic peak and also in the region where the resolution-limited
tail of the elastic peak contributes to the scattering. This can
be an important effect on IN6 where the resolution function has
long tails in energy. Secondly, when rescaling from low to high
temperature, the ratio in Bose factor becomes a very large number
for high-energy up-scattering (large negative
). The rescaling
can then "blow up" any, otherwise negligible,
background effects in this energy range. Use with care.
Takes a 2-D time-of-flight workspace and corrects for sample attenuation of the scattered neutrons assuming slab sample geometry. Calling procedure:
w2=slab_tof(w1,angle=<ang>,inc_xs=<ixs>,abs_xs=<axs>,thick=<t>,N=<N>) |
The 5 arguments specify the angle, thickness, number density and cross-sections of the sample as follows:
![]() | angle: is the angle in degrees of sample plane relative to incident beam |
![]() | abs_xs: is the sample absorption cross-section per
f.u. for thermal neutrons (![]() |
![]() | inc_xs: is the sample spin-incoherent cross-section per f.u. |
![]() | thick: is sample thickness (mm) |
![]() | N: is the number density (×1022 cm-3) |
For IN5 data only. Performs a smoothing of a background measurement. Calling procedure:
w2=smooth_bkgd(w1,ismooth) |
Assumes that the signal in all spectra consists of an elastic peak plus broad background scattering. ismooth specifies how to perform the smoothing:
![]() | ismooth<0:replaces the elastic peak by a best-fit Gaussian and applies a moving filter of width ismooth on the rest. ismooth must be an odd number. |
![]() | ismooth=0: no smoothing (default) |
![]() | ismooth>0: applies a moving filter of width ismooth everywhere. ismooth must be an odd number. |
Interpolates data to regular-grid S(Q,) covering the
entire measured Q-E region. Calling procedure:
w2=sqw_interp(w1,dQ=<dQ>,dE=<dE>,Emin=<emin>) |
The three arguments (dQ,dE,Emin) specify the point spacing and Q-E range to extract as follows:
![]() | dQ: Point spacing in Q (in Å-1) of the output workspace. |
![]() | dE: Point spacing in ![]() ![]() |
![]() | Emin: the minimum value of energy transfer for which to extract data. A typical value is ~5 meV. The Emin argument can be omitted to give the full energy range. |
sqw_interp is a quick-and-dirty way of transforming to regular
S(Q,) grid.
It is useful for visualising the data in 3-D plots. However, the
interpolation algorithm used does not allow error bars to be
extracted reliably. Do not believe the error bars! For a better,
but slower, transformation to regular S(Q,
) grid which gets
the error bars right, use sqw_rebin, qstrip or estrip.
Rebins data to regular-grid S(Q,) covering the
entire measured Q-E region. Calling procedure:
w2=sqw_rebin(w1,dQ=<dQ>,Emin=<emin>) |
The two arguments (dQ,Emin) specify the point spacing and Q-E range to extract as follows:
![]() | dQ: width of Q-binning (= point spacing in Q of output data) in Å-1. |
![]() | Emin: the minimum value of energy transfer for which to extract data. A typical value is ~5 meV. The Emin argument can be omitted to give the full energy range. |
The energy binning is unchanged from that of
the input data. sqw_rebin is a slow, but sound way of transforming to regular
S(Q,) grid
and gives reliable error bars. The overlap algorithm used is the
same as that used in the estrip and qstrip routines. See qstrip for more
details.
Adds spectra together to improve statistics. Calling procedure:
w2=sumbank(w1,dQ=<dQ>) |
The dQ argument specifies how many spectra to add together. They are summed in order to give angular spacings between spectra corresponding to a Q-spacing of approximately dQ Å-1. For IN6, sumbank can be called without specifying dQ. It then adds together spectra lying at identical scattering angles (upper, middle and lower detector banks).
Transforms time-of-flight data to energy
transfer . Calling
procedure:
w2=t2e(w1[,/in5multi]) |
/in5multi is an optional argument for IN5 only. It specifies whether to use the data from the small-angle multidetector or the higher-angle 3He tube detectors. If /in5multi is set, t2e uses the flight path for multidetector for energy transformation. Higher-angle data (scattering angles greater than 10 degrees) are discarded. Otherwise t2e uses flight path for high-angle detectors for energy transformation (default). Small-angle data (scattering angles less than 10 degrees) are discarded.
The transformation Jacobian from time-of-flight
t to (dt/d
) is proportional
to t3. After applying this correction and transforming
the x-axis to
, one obtains the
double-differential scattering cross-section d2
/d
d
, which is then
multiplied by a factor of ki/kf to obtain
S(Q,
). This
factor is proportional to another factor of t. In total, the data
are thus multiplied by a factor proportional to t4 in t2e. This
means that any background, which may appear negligible in the
time-of-flight representation, is likely to "blow up"
at large (positive) energy transfer. The data should therefore
ideally be background-subtracted before calling t2e.
Alternatively, a flat background can be subtracted using the corr_tof routine first.
Normalises data to vanadium. Calling procedure:
w2=vnorm(w1,w20,min=<min>,max=<max>[,tv=<tv>,Ns=<Ns>,ts=<ts>]) |
In this example, w1 is the workspace containing the data to be normalised and w20 contains the vanadium data. The two workspaces must have the same number of spectra. The two arguments (min,max) specify the time-channel range to use for integrating over the vanadium elastic peak. Time channels are defined to run from 1 to n, where n is the number of channels.
The optional arguments (tv,Ns,ts) are used for absolute normalisation of the data as follows
![]() | tv : is the thickness of the vanadium (mm) |
![]() | Ns : is the number density of the sample ( ×1022 cm-3) |
![]() | ts : is the thickness of the sample (mm) |