Time-of-flight Supplement
Version 2.0
January 99
Supplement to the LAMP BOOK for
TOF spectrometers. Use the LAMP BOOK for other general aspects of LAMP
2.1 Reading data - selecting instrument, selecting data-base, selecting run-number, selecting workspace, reading the run.
2.2 Plotting - simple plot, below & beside, image/contour/surface, view angle, ranges, be good (preferences), colours, zoom, cursor, printing.
2.3 Working with
Workspaces - Adding/subtracting etc., extracting sub-spectra,
summing subspectra, getting s(Q).
3. Special Time-of-Flight Functions
LAMP is a program which allows you to read data into workspaces, and then to plot and treat these workspaces in a wide variety of ways. Each workspace contains data with its parameters, descriptive text, and axes information. The main LAMP interface is equipped with buttons and windows which allow you to manipulate workspaces as shown below. The sequence is not strictly cyclic and the steps can be performed in any sequence after data read-in. Workspaces adapt to the dimensions of the data read into them. To run LAMP type lamp.
2.1 READING,
2.2 PLOTTING,
2.3 WORKING WITH WORKSPACES
Data reading is controlled from the DATA COLLECTOR area at the top of the main LAMP interface. LAMP looks at the system on which it is running and tries to set the best default values for the instrument and data-base. Normally the correct instrument and data-base will already be set.
Selecting Instrument.
If the instrument button does not indicate the desired
instrument then press this button. A pull-down menu of instrument-groups
appears. Select the desired group then the desired instrument.
Selecting Data-Base.
The button to the right of the instrument-button
contains the name of the data base. Press this button and a pull-down menu
appears which normally offers:
'Instrument Name' Data on the instrument
computer.
Current Cycle Data for the current cycle
on the main ILL data-base
Previous Cycle Data from the previous cycle
on the main ILL data-base
Current Path Data will be read from the path
defined in the field at the top-right of the window. This path is editable.
Selecting a Work-Space.
The workspace selector is at the far-right of the
DATA
COLLECTOR area. At start-up w1
will be selected. You may change this by pressing the "<"
and ">" buttons on
the interface.
Selecting and reading a Run.
Enter the desired run number in the "Read"
field. To read in and sum several consecutive runs, use the ">"
symbol, e.g. 1234>1237.
Click "Read".
Tips:
1. The run will be read into the selected workspace if you hit carriage return in the "Read" field.
2. The selected run-number can be incremented by pressing the ">" button which is next to the run-number window.
3. The command w1=rdrun(1234) can be entered directly in the "formula entry" window. This example reads run number 1234 into w1.
4. The command w1=rdsum(1234,1237) will sum together runs 1234 to 1237 into w1, equivalent to entering 1234>1237 in the "Read" field.
5. It is often convenient to reserve w1, w2, and w3 for special purposes: e.g.. current run, vanadium, background runs. This allows you to use the programmable buttons to maximum advantage.
6. LAMP uses dynamic memory allocation so that empty
workspaces take no space. You can empty workspaces that are no longer required
by setting them equal to zero. NB LAMP may become slow when all the available
memory is used.
The area controlling display is in the centre of the LAMP interface.
Simple Plot
Any workspace can be plotted by selecting the workspace
number in the plot button with the neighbouring "<"
">" buttons. When
you press the plot button the plot will appear according to the setting
of the other buttons on the "DISPLAY WORKSPACE"
area. LAMP automatically selects the last workspace which was modified
as the default for plotting.
Below Beside
Plots made in the small display in the centre of
the LAMP interface are rapid, but small. This is the "below"
option. If the "beside"
button is selected plots will appear in a new window which can be rescaled
and scrolled. Each new plot makes a new window "beside"
which enables plots to be compared easily. The windows can be stored as
icons, but should be removed if they are not needed to avoid complication.
Image Contour Surface.
The type of plot is selected with the appropriate
button or buttons. These can be combined to obtain complex plots, but remember
that contour plots of noisy data can take a long time to generate. "Image"
is usually very fast.
View Angle
The view angle for surface plots is given in the
box next to the "surface"
button. This can be modified as desired.
Ranges.
The plot range can be chosen by the desired values
in the fields next to the "x-range"
...etc. buttons. If the buttons are deselected the full range will be taken.
Warning: When you change a workspace from channels to energy you may get
a shock if you have selected an x-range based on channels!
Be Good Button
This button brings up a "set
preferences" window. This allows you to change
titles, default printer and various plot options.
Colours
Colours can be changed in the "beside"
plot by pressing the colours button. This brings up the "XLOADCT"
utility which changes the colours of all plots interactively. Be careful
not to plot black on black.
Zoom
To zoom in on a region of a plot press the left
mouse-button and drag out a rectangle enclosing the area of interest. When
you release the mouse-button the zoomed area will be plotted. Data in the
zoomed area can be saved into a workspace with the command: trap,w4
(into w4 in this case). Unzoom by pressing "replot"
in the "beside" window
or "plot" in the
main LAMP interface.
Cursor.
The cursor cannot work on "surface"
plots. Press the left mouse-button on with the cursor arrow in the plot
and the values of x,y,z will appear. Areas can be integrated by "dragging"
an area with the right mouse-button pressed.
Printing.
Normally the correct printing device will be set
so that you simply press the "print"
button to obtain a hard-copy. If no device is set LAMP will make a postscript
file. The printing device is set in the "be
good" window.
Tips.
1. Use "below" with "image" for fast plots.
2. Press the "z-log" button to reveal small features with "image". Do not forget to unset "z log" afterwards!
3. For a small number of spectra the "vectors" style (in the "be good" window) gives a multiplot effect.
4. Use two "beside"
windows to compare runs.
What is in a workspace?
In addition to the counting intensities in, say
w1. Additional information is stored in the following arrays:
Adding, Subtracting, etc. Workspaces.
To add two runs which are in workspaces w1
and w2 simply type:
w3=w1+w2
in the "formula entry"
window. Subtraction, multiplication etc. are similar. In these operations
LAMP will transfer the parameters, axes values, titles (and monitors) of
the first workspace after the "=" sign into the new workspace. Effectively,
"w3=w1+w2" invokes:
p3=p1
x3=x1
y3=y1
x_tit(3)=x_tit(1)
& y_tit(3)=y_tit(1)
& w_tit(3)=w_tit(1)
which is what you would expect. However, it also
invokes
n3=n1
e3=e1
which is often not at all what you expect.
There are two very important points here, which
are often a source of error:
1) If you are adding together raw (unnormalised)
data, you should always explicitly add the monitors, i.e.
n3=n1+n2
in the above example
2) You should always explicitly perform the error
bar calculation when manipulating workspaces, i.e.
e3=sqrt(e1^2+e2^2)
in the above example. Note that you do not need
to do this when the manipulation is done by an existing TOF function, e.g.
w2=normalise(w1)
automatically gets the error bars right.
When multiplying or dividing two workspaces by a number, always remember
to perform the error bar calculation explicitly, e.g.
w2=w1/1.87 &
e2=e1/1.87
When dividing two workspaces by each other, a divide
function has been written to automatically work out the appropriate error
bars, in order to save tediously working out the expression every time,
i.e.
w3=divide(w1,w2)
does not require an explicit error bar calculation.
Extracting
sub-spectra.
To extract spectra 20 to 30 from w1 into w2:
w2=w1(*,19:29)
In this example the "*"
implies
all channels. If you were only interested in channels 300 to 400 for spectra
20 to 30:
w2=w1(299:399,19:29)
LAMP ensures that parameters, axes etc. are transferred
correctly but it does not update the values for the number of spectra and
number of channels in the new parameters. These can be edited with the
"data params" button.
Summing several spectra
If the sum of spectra collected at all different
scattering angles is required:
w2=total(w1,2)
Here the "2" means sum over the second dimension
i.e.. spectra. A sum of a range of spectra, say spectrum 50 to spectrum
100 can be made:
w2=total(w1(*,49:99),2)
Getting s(Q)
A sum of all channels (for s(Q)):
w2=total(w1,1)
If only elastic s(Q) is required and the elastic-peak
position is known to be from say 200 to 220:
w2=total(w1(199:219,*),1)
1. Use the history to cut out previous commands and paste them into "formula entry" for reuse.
2. The programmable buttons are often easier to use than the "formula entry"
3. Simple error messages appear between the "formula entry" and "history" windows.
4. General warning and error messages appear in the
winterm window from which LAMP was launched. Keep this window in view.
SPECIAL TOF FUNCTIONS:
3.1 BATCH FILES,
3.2 LIST OF FUNCTIONS
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. 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.
Example of standard data reduction batch file for IN6:
w1=rdsum(7272,7280) ; sample
w1=normalise(w1)
w2=rdrun(7303) ; empty
w2=normalise(w2)
w3=w1-w2 & e3=sqrt(e1^2+e2^2)
w20=rdrun(7271) ; vanadium
w20=normalise(w20)
w4=vnorm(w3,w20,100,110)
w5=remove_spectra(w4,[1,116,198,199])
w6=sumbank(w5)
w7=corr_tof(w6,1,1,0)
w8=t2e(w7)
w9=reb(w8,0.02)
w10=sqw_rebin(w9,0.05,-5)
output_allqs, w10,
'helium_T050K'
Example of more complex reduction batch file for IN5:
w1=rdsum(7272,7280) ; sample
at T=50K
w1=normalise(w1)
w2=rdrun(7303) ; empty
w2=normalise(w2)
w3=w1-w2 & e3=sqrt(e1^2+e2^2)
; sample signal at T=50K
w4=rescale_t(w3,50,10)
; rescale phonons to T=10K
w5=rdsum(7281,7288) ; sample
at T=10K
w5=normalise(w5)
w6=w5-w2 & e6=sqrt(e5^2+e2^2)
; sample signal at T=10K
w7=w6-w4 & e7=sqrt(e5^2+e4^2)
; use error bars before bkgd-sub.
w20=rdrun(7271) ; vanadium
w20=normalise(w20)
w8=vnorm(w7,w20,150,170)
w9=remove_spectra(w8,[116,198,199])
w10=sumbank(w9,0.1)
w11=corr_tof(w10,1,1,0)
w12=t2e(w11,1) ; use high-angle
detectors
w13=reb(w12,0.05)
w14=total(w13(*,0:2),2)
; magnetic signal at lowest angles
output, w14, 'magnetic.dat'
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 (the opposite
to that used in MAD): 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 "MACP"
heading
in 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.
Corrects data in TOF for energy-dependence of detector efficiency, frame overlap and time-independent background. Calling procedure:
w6=corr_tof(w5,ieff,iframe,ibkgd)
The three arguments (ieff,iframe,ibkgd) should be set to either 1 or 0, to apply the correction or not.
iframe: 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,w) is flat in energy between the highest measured energy transfer hw (end of the time frame) andhw= Ei In this case the intensity as a function of time t of the frame-overlap component should have a t-4 dependence. The magnitude of the frame overlap component is determined by integrating the counts over the last 10 time channels, and the continuation of this, scaled with t-4 is subtracted from the beginning of the time frame. This correction is applied independently for each spectrum.
ibkgd: 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 hw.
It estimates the minimum intensity level in each spectrum by applying a
moving filter 21 time channels wide and subtracts it.
Divides two workspaces by each other, with error propagation. Calling procedure:
w3=divide(w1,w2)
The two workspaces to be divided must have the same
dimensions and have associated error bar arrays of the same dimensions.
Finds the elastic peak position for each spectrum and puts them into the output workspace. Calling procedure:
w2=elastic(w1,xmin,xmax)
The two arguments (xmin,xmax)
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 (+/- 10 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.
Useful for data smoothing. Least-squares fits a polynomial function to the data. Calling procedure:
w2=fit_poly(w1,npoly)
The npoly argument
specifies the degree of the polynomial to fit. The fit is performed separately
for each spectrum. A standard IDL polynomial fitting routine is used which
does not always converge well. Use with caution!
Not intended for general use. It is used by other
routines that fit Gaussians (such as elastic.pro
and normalise.pro),
but is not set up in a way that allows it to be used to fit directly to
workspace data.
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.pro. Calling procedure:
w1=input('filename.dat')
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,inorm)
The inorm argument specifies what to normalise to:
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.pro. Calling procedure:
output, w1, '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.pro routine. The data format for each file is identical to that of output.pro for 1-dimensional data. Calling procedure:
output_allqs, w1, 'filename'
The workspace data are saved in a series of files with names, e.g.
filename.q000where 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.
filename.q005
filename.q010
filename.q015, etcÖ
Not intended for general use. It is used by the routines
sqw_rebin.pro
and
qstrip.pro
to rebin data to constant Q. It calculates the overlap area Aij
described for qstrip.pro.
Rebins data to regular-grid S(Q,w) at a single constant-Q value. Calling procedure:
w2=qstrip(w1,Qvalue,dQ,Emin)
It extracts data lying on a single constant-Q strip in the Q-E plane, centered at Q = Qvalue. The three arguments (Qvalue,dQ,Emin) specify the Q-E range to extract as follows:
S(Q,w)=SijS'(Qij,wij)Aijwhere 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 sqw_rebin.pro routine.
Rebins data to regular steps inhwwith error bar propagation. Calling procedure:
w2=reb(w1,dE,forcebin)
TOF data is transformed to energy transfer hw by the t2e.pro routine. The spacing of the points once transformed to hw is no longer constant. reb.pro rebins the data to constant energy bin width. The two arguments (dE,forcebin) specify the binning as follows:
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,Tnew)
The input data must have energy transfer hw
as
x-axis, i.e. they must have been passed through
t2e.pro.
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.pro
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 upscattering (large negative hw).
The rescaling can then "blow up" any, otherwise negligible, background
effects in this energy range. Use with careÖ
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.ismoothspecifies how to perform the smoothing:
Interpolates data to regular-grid S(Q,w) covering the entire measured Q-E region. Calling procedure:
w2=sqw_interp(w1,dQ,dE,Emin)
The three arguments (dQ,dE,Emin) specify the point spacing and Q-E range to extract as follows:
Rebins data to regular-grid S(Q,w) covering the entire measured Q-E region. Calling procedure:
w2=sqw_rebin(w1,dQ,Emin)
The two arguments (dQ,Emin) specify the point spacing and Q-E range to extract as follows:
Adds spectra together to improve statistics. Calling procedure:
w2=sumbank(w1,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.pro
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 hw. Calling procedure:
w2=t2e(w1,idet)
idet 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:
Normalises data to vanadium. Calling procedure:
w2=vnorm(w1,w20,xmin,xmax)
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 (xmin,xmax)
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.
Lines up the elastic peaks in the spectra of a workspace. Calling procedure:
w2=lineup(w1)
Because there are frequently small difference 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. The function lineup 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.
Please ask if there are aspects of LAMP that you cannot understand of find difficult.
1. Where are the monitor spectra?
When data are read in the monitor spectra are assumed to be the first
3 spectra in the raw data. These are stripped out and put into the array
n1
for w1,
n2
for w2 etc. Each
"n" contains all
three monitors and its dimensions are (number-of-channels,3). You can see
the monitor1 spectrum of workspace 2 by typing: plot,n2(*,1).
2. How does spectrum 1 in LAMP correspond to
the order of spectra in the data collection?
In order to simplify plotting runs as surfaces,
images and contours, LAMP removes monitors and other "non-detector" spectra
from the raw data. Each instrument has its own style in the raw data, and
to make things worse the first element in IDL arrays is element number
0.
For IN5 the first LAMP spectrum is instrument-spectrum
9
For IN6 the first LAMP spectrum is instrument-spectrum
7
For IN10 the first LAMP spectrum is instrument-spectrum
1
For IN16 the first LAMP spectrum is instrument-spectrum
1
3. When I press print I only get a PS file.
The LAMP default printer is set in the "be good"
menu. Press the "be good"
button (just above the plot window) and then enter the desired printer
name in the appropriate field. Instrument printers usually have their names
on a label somewhere on the printer.
4. Plots are wrong or badly scaled when I use
"plot" command in formula entry. (e.g. plot,n1).
The plot-range buttons only apply to workspaces.
When you issue the "plot" command manually you must set xrange, yrange
and zrange manually. To plot monitor 1 of workspace w3 from 200 to 250
channels: plot,n3(*,1),xrange=[200,250]
5. I see no plot!
The "color" options can be used to plot black-on-black,
blue-on-blue etc. A previous user may have made this selection. Also, colour-schemes
which are ideal for shaded surfaces may be poor for vectors or contours.
6. LAMP is stuck (no response)
Certain operations on large arrays can take a long
time. Contour plots of noisy data are very time-consuming. Using sqw_rebin
with small increments also requires patience. If you are convinced that
LAMP has gone "dead" then:
Either close the shell window which started LAMP
(if you can find it) or.....
a. Select "desktop" from the desk menu at the top
left of the screen. You may have to move LAMP or other windows out of the
way. With desktop selected take the option "Unix Shell".
b. A new window will open. Type ps
and a list of the processes running will appear. Note the number of the
process called IDL.
c. Type "kill 12345"
where in place of 12345 you put the number of the IDL process. If you got
it right LAMP will go out!
d. To restart LAMP type "lamp".