|
|
|
The Computing for Science (CS) group supports ILL scientists, students and visitors in a number of activities including data analysis, instrument simulation and sample simulation.

6. Common Workspace FunctionsFormula-entry and Do text area syntax is IDLAll text entered in the formula-entry area is parsed and then sent by LAMP to the Interactive Data Language (IDL). The main reason for parsing is to enable blocks of related arrays in a source workspace (see Main Concepts) to be passed together to a target workspace. The passing rule is :- Extensive on-line help is available on this language by pressing the IDL? button. You can make any IDL command through the formula-entry area, and these will normally be operations on workspaces. LAMP provides maximum flexibility by giving you access to the majority of its working variables, either for one line commands or for command files. You can put data into any variable that you have declared and operate on it with IDL, but these variables will not be managed by LAMP, the variables a,b,c,...z are available for your use. 3.14159... can be obtained by typing in " !PI"
Note: In the following we refer to data in the x-dimension as "channels" and in the y-direction as " spectra". Appologies to crystalography. Simple Algebra with Workspaces ( +, -, /, * )To add two workspaces w1 and w2 simply type: w3=w1+w2
Extracting sub-arrays (channels/spectra)To extract spectra 1 to 40 from w1 into w4 w4=w1(*,0:39) In this example the * implies all channels. N.B. 1 has to be subtracted from the spectrum numbers to suit the IDL array numbering. To extract channels 250 to 500 for all spectra from w1 into w4 w4=w1(249:499,*) To extract channels 250 to 500 for spectra 30 to 40 from w1 into w4 w4=w1(249:499,29:39) N.B. 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 using the Data Params button. Integrating (total)To sum all the spectra of w4 into w5 w5=total(w4,2)
w2=w1(*,29:39) & w2=total(w2,2) To sum across all the channels, eg. for s(Q) w3=total(w1,1)
w3=w1(199:219,*) & w3=total(w3,1) Normalising on MonitorsMonitor spectra are stored in the array n (ie. n1 for w1, n2 for w2 etc.). If each channel is to be normalised with the corresponding channel in the monitor spectrum (diffraction instruments) then the data in w1 can be normalised using w1=w1/n1 If you need to normalise with the integrated monitor spectrum, for spectra of say 512 channels you must sum across the channels using (n1 can be two-dimensions) w1=w1/total(n1(*,0)) If the position of the peak in the monitor is known to be say 220 to 240 channels then a better result is obtained with w1=w1/total(n1(219:239,0))
Maths-functions These work on workspaces or arrays of any dimensions (including scalars):- Showing Values (show)The value of any variable or expression can be displayed in the formula-entry window with the command show,x eg. show,total(w1,1) show,a*5
print,x Minimum and maximum values of workspaces are available in the formula-entry area. Otherwise to get min and max values between say channels 250 to 500 for spectra 30 to 40 of w1 show,max(w1(249:499,29:39))
Shifting axesThe values of the x-axis, in time, energy channels etc., are stored in x1 for w1, and x2 for w2 etc. To shift spectra simply add (or subtract) the appropriate value from the x array. For example, to shift data in w1 (say in energy) by 0.15 x1=x1+0.15 Resizing an image (congrid)To resize w1 which may, for example, contain a 128 by 512 image to another size, say 64 by 256 pixels in w2 w2=congrid(w1,64,256) Putting Workspaces together (join) To join workspaces into first dimension(W4), second dimension(W5), third dimension(W6): w4=[ w1 , w2 , w3 ] Changing Data-typeMain data types are: Changing between data-typesd=long(a) convert 'a' to long-integer (limits: -2^31 to 2^32-1) (a=0L is long integer)
N.B. By default integers are 2 bytes. If you have numbers greater than 32768 you will get odd results unless you work with long-integers or floats, eg. enter w1=float(w1) in the formula-entry window. Graphicsplot,a,b oplot,a,b contour,a,b,c surface,a,b,c shade_surf,a,b,c plot,n3(*,1),xrange=[200,250] |