Warning: Trying to access array offset on value of type null in /home/site/wwwroot/lib/plugins/move/action/rename.php on line 42

Warning: Cannot modify header information - headers already sent by (output started at /home/site/wwwroot/lib/plugins/move/action/rename.php:42) in /home/site/wwwroot/inc/actions.php on line 38
automating_multiple_refinements [topas wiki]

User Tools

Site Tools


automating_multiple_refinements

Automating Refinements

There are lots of ways to set topas up to perform multiple refinements. There's some information in chapter 13 of the manual. The tips below make things extremely easy to control.

This page was written for version 4-5 of Topas. With version 6 we have the #list command which makes things far far easier. Read about it here. The method below still works but requires an external script to run Topas so is more involved.

There is a tutorial example which works with either versions 4-5 or version 6 here.


The key to automation is to use the command line version of topas: tc.exe. This can be run from a dos prompt or via a .bat file. The main “tricks” are to:

  1. Set up refinements so that you can use the same input file in gui mode as dos mode
  2. Be able to “send in” information (e.g. experimental details) to each refinement
  3. Be able to write out results automatically.


1. Ideally you want to use the same input file for performing a single refinement in gui mode as you're going to use in batch or command line mode. You therefore need an input file which contains all the commands needed for a gui (ta or tb) refinement but which can also be “told” similar information in a command line refinement. The #ifdef…#endif statements below do this. The syntax means that topas reads this lines after the “#ifdef !GUI_LINES” flag unless it has specifically been told not to. These lines therefore set the filename, the range to refine (if Bruker file) and parameters defining experimental details via the “information” macro when doing a normal gui mode (ta or tb) refinement.

#ifdef !GUI_LINES 'use these lines when in gui mode
macro filename {d8_02339} 
macro rangeuse { 12} 
macro information {prm !te 0 prm !time 0 } 
#endif 
 
information
 
'-------------------------------------------------- 
'instead of giving the raw filename and range number in the input file use the words 'filename' and 'rangeuse' which get replaced by information in the macros above.
'-------------------------------------------------- 
 
RAW(filename) 
range rangeuse

2. You can then run topas from the command line with the format below. The macros feed key information about filename, experimental details in to the refinement from the dos line. The input filename is seed.inp in this example. The #define flag at the end of the line effectively tells topas to ignore the lines given after #ifdef GUI_LINES in the input file and to take information from the command line instead. I always run tc from the topas directory and keep the input files and datafiles in a separate directory for neatness. Note that you don't specify .inp after the input filename (here seed.inp) or for the raw file name (here d9_02592.raw).

tc C:\directory\seed "macro filename {C:\directory\d9_02592} macro rangeuse {22} macro information {prm !te 300 } #define GUI_LINES"

3. You can easily put a whole sequence of instructions like this in a command file. You can generate such files with a short program or e.g. using excel. I always call the first input file “seed.inp”. This then gets copied at the end of the refinement ready for the next refinement. A .bat file would need to contain:

tc seed (+ macros defining things for refinement one)
copy seed.out seed.inp
tc seed (+ macros defining things for refinement two)
copy seed.out seed.inp
etc

4.Information can be output directly to a results file in a number of ways. A typical results outputting section is below. You can format the output file however you like. Using the append command means that the results file just gets added to. It's therefore sensible to delete any old results file before you run multitopas. The format below will write out esd's if do_errors is defined.

'-------------------------------------------------- 
'set up the output file stuff here 
'put a \n on last output information to force a new line
'-------------------------------------------------- 
 
out "results.txt" append 
 
Out(rangeuse, " %11.5f") 
Out(te, " %11.5f")
Out(Get (r_wp), " %11.5f")
Out(lpa_al, " %11.5f", " %11.5f")
Out(lpa_si, " %11.5f", " %11.5f")
Out(lpa_sample, " %11.5f", " %11.5f")
Out(height_al, " %11.5f", " %11.5f")
Out(height_sample, " %11.5f", " %11.5f")
Out(height_si, " %11.5f", " %11.5f")
Out(bvalue1, " %11.5f", " %11.5f")
Out(bvalue2, " %11.5f", " %11.5f")
Out(scale_sample, " %18.9f", " %18.9f")
Out(scale_si, " %18.95f", " %18.9f")
Out(rangeuse, " %11.5f ") 
Out_String(filename\n)

8. wgnuplot can be a very quick way to plot results. Try using a command file like the one below. It will automatically produce .gif files. Use “preview” in windows and print out a “contact” sheet of all of them.

set term gif
set output 'plots\plot01.gif';plot 'results.txt' using 2:3 w p
set output 'plots\plot02.gif';plot 'results.txt' using 2:4:5 w errorbars
set output 'plots\plot03.gif';plot 'results.txt' using 2:6:7 w errorbars
set output 'plots\plot04.gif';plot 'results.txt' using 2:8:9 w errorbars
set output 'plots\plot05.gif';plot 'results.txt' using 2:10:11 w errorbars
set output 'plots\plot06.gif';plot 'results.txt' using 2:12:13 w errorbars
set output 'plots\plot07.gif';plot 'results.txt' using 2:14:15 w errorbars
set output 'plots\plot08.gif';plot 'results.txt' using 2:16:17 w errorbars
set output 'plots\plot09.gif';plot 'results.txt' using 2:18:19 w errorbars
set output 'plots\plot10.gif';plot 'results.txt' using 2:20:21 w errorbars
set output 'temp.gif'
set term win
replot
automating_multiple_refinements.txt · Last modified: 2022/11/03 15:08 by 127.0.0.1