Tobyfit examples
From Tobyfit
Contents |
Tobyfit examples
Running the demo example via the GUI
Loading the data
The directory "demo" in the tobyfit install area (default C:\e-science\TobyfitProject on Windows) contains 4 files which can be used to run a test case. The files are:
- demo_a.cut - A one dimensional cut through scattering data obtained on the HET instrument. This file was generated using the mslice tool. It contains point values and errors along a given direction. It also has details of the individual pixels that contribute to each data point.
- demo_b.cut - Another 1D cut file through the same data set.
- demo.par - A parameter file describing the run.
- demo.tft - A file describing the models and values to be used within tobyfit and the data files to be used.
When tobyfit is first started it has no information about any runs or models. A user with a new set of results to analyse can build this information up within the GUI by entering run files and model choices and data. This information can be stored and the format used for this is the "tft" file. This file format is not "user readable" and is only accessed via an interface such as the tobyfit GUI.
To look at the data in the file "demo.tft" it is necessary to load it into the GUI. This can be done using the "File" menu (top left of GUI) and selection "Load TFT". This should bring up a normal Matlab file browser window. Go into the sub-directory "demo", highlight "demo.tft" and click on "open".
As the GUI reads the TFT file, it finds that files are referenced as "demo:demo_a.cut", "demo:demo_b.cut", etc. The prefix "demo:" is used a reference to the actual directory the data is to be found in. A second browser window will appear asking for the location of the data files. By default the browser starts in the directory from which the TFT is being read, and in the case the data is in the same directory. Hence you can just select "OK" to use this directory and in general it is best to have the tft file and all the data files in one directory.
A further will then ask if you want to load history information, click "no" as no history should yet exist. If you have set up grid resources to run tobyfit with another box will ask if you wish to send data to the SRB. You should click "yes" the first time you run a job with new data files.
Viewing the data
To view the data, click on the "Runs" tab in the GUI. This brings up a data view where you can inspect each data set that is loaded. This should look like this tf_runs_tab. The default display shows Run 1 and data set 1 which in this example is the demo_a.cut data set. To see what the data looks like press the "plot" button on the right hand side of the GUI, next to "plotover" (the two other "plot" buttons on this window are related to data removal and should not used for viewing data). This will show the data in a separate plot window.
To see the data in the second data set of run 1, just change the "Data set" drop down item from "1" to "2" and then press "plot" again.
Simulation of the data
The demo.tft file describes the data files of interest along with instrument details and a model of the scattering process to be used. A simulation of this model over the range of points given in the cut files can be performed by going to the "Simulate" tab of the GUI. Just click on the "Do Simulate" button. A separate window will open asking for the system to run the simulation on and the number of processors to use. If you do not have grid access the only option of system will be "local", i.e. the machine you are using. If this is a dual processor you can select two processors. Then click on "OK" to start the simulation. After a few seconds details of the run should appear in the table giving the job number (an arbitrary number) and its status. Local jobs are started intermediately but remote jobs may be held in a queue until they are run. This particular job is very short and should only take a short time to complete. The job status is NOT automatically updated, so the "query" button has to be pressed repeatedly to see job progress. The status should change from "SUBMITTED" (not often seen for local jobs) to "ACTIVE" and finally to "COMPLETED".
When a job has completed the results of the simulation can be seen by use of the "plot" button on the Simulate tab. By default this will plot the simulation of the first data set (demo_a.cut in this case). The two drop-down menus above the "Plot" button allow selection of which data set to plot and which values to show. Using these and the "PlotOver" button it is easy to compare the original data to the simulation.
Fitting of the data
To fit the data it is first necessary to select the parameters which you wish to fit and the data sets to fit against. The CrossSection Model tab allows selection of the parameters to fit. While values P1 to P20 are listed, only a selection of these are used by any model. In this case we can select the first three values for fitting by putting a tick in the "Clear" box against P1, P2 and P3.
The background models can also be fitted at the same time. To do this, you should select the "Runs" tab. This TFT file has a separate background model for each data set, though this can easily be changed if desired. To fit the given independent models, first select Run 1, Data set 1 from the top left of the runs tab. Then select the b1 variable by clicking on its "clear" box. Then do the same for Run 1, Data set 2.
The fit will be done against both data sets since these are selected (have a tick against them) in the data summary table at the top of the GUI. If a fit against only one data set is required the user can deselect the undesired one by removing the tick.
To perform the fit, select the "Fit" tab and click on "Do Fit". The submission process is the same as for simulation and a host must be specified along with the number of processors to use.
Fitting will take longer than simulation. When the process is complete the results will be returned and can be viewed using the "plot" buttons.
Running the demo example via the command line
The following Matlab commands can be used to submit a simulation job on using the localhost (on a Windows machine):
tobyfit % start up tobyfit
tobyfit_load('demo/demo.tft','demo',0) % load demo.tft, set data dir, don't transfer to SRB
tf_tab('cross') % select the cross section tab
tf_set('model',-111) % set the sqw_broad model number
tf_set('param',1,22.5) % adjust a couple of parameters
tf_set('param',2,2.6)
tf_tab('sim')
tf_set('do_sim','local',2) % submit sim job to localhost (WINDOWS only)
Note that the GUI must be started first before the Matlab command line can be used.
