lamp_mac/D17/
d17mono.pro
MONO.PRO: Monochomatic data analysis for D17 -------------------------------------------- (Stephen Brown, 16/09/2001) Notes: This programme calculates the reflectivity against q for monochromatic data. This is done by dividing the reflected and direct beam intensities for various combinations of polariser/analyser (up to 4 in total). Because monochromatic data usually consists of a large number of numors, once the data is loaded it is stored in heap structures to allow the analysis to be repeated using different parameters. Most of the analysis is accomplished using "fpeak" (which finds intensity of a peak) and "analysis" (which does everything else). Most common blocks in the programme are used to store the widget id's for the user interface. The important common blocks (with regards to calcs.) are "COMMON detector", which contains the "useful area of detector" (xmin,xmax) and an array of 4 elements pointing to the approximate position of the reflected beam for each of the 4 possible polariser/analyser combinations; and "COMMON loaded_data" which contains pointers to the loaded data.
Routines
result = getint(numstring, errstr, MAX_VALUE=MAX_VALUE, ALLOW_EMPTY=ALLOW_EMPTY, QUIET=QUIET)
result = getfloat(str, MIN_VALUE=MIN_VALUE, MAX_VALUE=MAX_VALUE)
msgwin, msgstr, TITLE=TITLE, ERROR=ERROR, NOSENSITIZE=NOSENSITIZE
msgwin_event, event
result = data_readm(path, num, dataptr)
result = fpeak(arr, errarr, fgwidth, bgleft, bgright, fitbg, PEAK_NEAR=PEAK_NEAR)
analysis, user
group_monodata, x, y, e, dq, a, b, c
attcorrwin_event, event
pixels_event, event
mono_event, event
d17mono
Routine details
top getint
result = getint(numstring, errstr, MAX_VALUE=MAX_VALUE, ALLOW_EMPTY=ALLOW_EMPTY, QUIET=QUIET)
=============================================================================== Function to get an integer. numstring is the string containing the integer. errstr should containt the a string with the name of the field that is being entered (e.g 'Direct Beam, 1st Numor') this is used to display an error message if something goes wrong (in which case -1 is returned). The key word MAX_VALUE allows a maximum value to be specified. If not then the max value is the largest positive integer that can be stored in a signed long integer. The keyword ALLOW_EMPTY allows the field to be empty. If it is empty then 0 is returned rather than the ususal -1 (error). The keyword QUIET stops the printing out of error messages. -1 is still returned to signal error, though. This keyword is used to disable the error messages that are used when getting integers from fields in the main window so that this routine may be used to get integers from other windows. ===============================================================================
Parameters
- numstring
- errstr
Keywords
- MAX_VALUE
- ALLOW_EMPTY
- QUIET
top getfloat
result = getfloat(str, MIN_VALUE=MIN_VALUE, MAX_VALUE=MAX_VALUE)
=============================================================================== getfloat. Simple function to return a float from a string. Minimum amount of error detection is done, i.e it only signals an error if the function FLOAT(...) fails. This is done to stop a silly IDL error message coming up on the console making the programme look unprofessional as if it had been written by ILL stagiare. Returns NaN (IEEE 'Not a number') on conversion error. Keywords MIN_VALUE and MAX_VALUE specify the minimum and maximum respectively. ===============================================================================
Parameters
- str
Keywords
- MIN_VALUE
- MAX_VALUE
top msgwin
msgwin, msgstr, TITLE=TITLE, ERROR=ERROR, NOSENSITIZE=NOSENSITIZE
=============================================================================== Procedure to display a message (msgstr) window with a title (msgtit) supplied as an optional keyword. Keyword ERROR causes msgwin to print error message (title set to 'Error!' and error message printed on console.) The keyword NOSENSTIZE stops changes in sensitisation of the main window useful if msgwin is called from a child of the main window (such as the (modal) direct beam attenuator-correction window. Otherwise msgwin performs necessary changes in sensitisation of main window. ===============================================================================
Parameters
- msgstr
Keywords
- TITLE
- ERROR
- NOSENSITIZE
top msgwin_event
msgwin_event, event
=============================================================================== Event handler for message window. Destroys window if ok is pressed. ===============================================================================
Parameters
- event
top data_readm
result = data_readm(path, num, dataptr)
=============================================================================== Reads a data numor 'num' in directory 'path'. The data is stored in a heap stucture which is allocated at the end. The pointer to the struct. is returned in dataptr. The structure contains not only the (1d) data, but also the instrument parameters. 2D data is summed in the y-direction. ===============================================================================
Parameters
- path
- num
- dataptr
top fpeak
result = fpeak(arr, errarr, fgwidth, bgleft, bgright, fitbg, PEAK_NEAR=PEAK_NEAR)
=============================================================================== FUNCTION fpeak: Finds the peak of a 1d array 'arr' using a centre of mass calculation over a width 'fgwidth' around the peak. Errors aree passed through the array errarr and propagated through the calculation. Background may be subtracted by specifying the vectors 'bgleft' and 'bgright' (which have 2 elements [0]=width of LHS/RHS background, [1]= shift). If 'fitbg' is 0 (false) then the background is averaged, otherwise it is fitted to a straight line. Keyword PEAK_NEAR tells where to do the c.o.m calculation. If not specified then the calculation is done about the maximum pixel. ===============================================================================
Parameters
- arr
- errarr
- fgwidth
- bgleft
- bgright
- fitbg
Keywords
- PEAK_NEAR
top analysis
analysis, user
=============================================================================== THE MAIN ANALYSIS ROUTINE! This routine is called whem the analyse button is pressed. All user inputted fields are passed through the structure 'user' (defined in mono_event, below). If no data is loadec then this procedure first loads all data and a window is displayed to allow the user to check/ modify the direct beam attenuation. Then the "approximate" position of the reflected beam peak is found. This is done because can't simply find max of reflected beam data in places where reflectivity is low so need an area to look for it. After data is loaded (or if data has already been loaded) the analysis is done. First the reflectivity is calculated by using fpeak to find the intensity of the direct and reflected beam peaks-these are then divided. Then q (and its resolution) is calculated. Finally the data is stored to a file and plotted. The plotted data is first bundled/grouped using group_monodata. ===============================================================================
Parameters
- user
top group_monodata
group_monodata, x, y, e, dq, a, b, c
=============================================================================== Procedure to group data. Combines data from points which are, within the resolution, too close to each other. Also takes logarithm of the data and propagates the errors accordingly x = q values. y = Reflectivity values. e = error on reflectivity data dq = error on q values a = groupd reflectivity. b = groupd q values. c = groupd refl. errors ===============================================================================
Parameters
- x
- y
- e
- dq
- a
- b
- c
top attcorrwin_event
attcorrwin_event, event
=============================================================================== Event handler for Direct beam attenuation correction window. The attenuation correction is done using the attenuator number written to the numor (recommeded) or by specifying a start attenuator and looking for drops. The user can change the attenuation factor. By pressing the "do again" button the user can inspect the graph of intensity versus numor to see if it is correct (the intensity should increase continuously as the slits are opened). When the user is satisfied the "done" button is pressed and the direct beam data are corrected using the selected parameters. ===============================================================================
Parameters
- event
top pixels_event
pixels_event, event
=============================================================================== Event handler for peaks/ranges window. This gets the values for the useful area of the detector and the approx. positions of the reflected beam peaks performing the necessary error checks. ===============================================================================
Parameters
- event
top mono_event
mono_event, event
=============================================================================== Event handler for main window. This gets all the text from the text widgets and converts them to the appropriate types (integers/floats etc). Numerous error checks are made to ensure that the fields are correctly formatted and within range. Other checks are performed, eg to check that the number of db and ref. numors correspond, given the number of polarisations. If the fields are all okay then the defaults file is written. ===============================================================================
Parameters
- event
top d17mono
d17mono
=============================================================================== Main procedure "PRO mono". Loads defaults file. Displays main window. 'nuff said. ===============================================================================
File attributes
Modification date: | Tue Oct 1 14:43:02 2013 |
Lines: | 2,087 |