source: trunk/doc/liveplot.html @ 408

Last change on this file since 408 was 406, checked in by toby, 11 years ago

# on 2001/06/29 18:34:32, toby did:
document bkgedit
add cumulative chi2 description (nice idea Bill!)

  • Property rcs:author set to toby
  • Property rcs:date set to 2001/06/29 18:34:32
  • Property rcs:lines set to +234 -45
  • Property rcs:rev set to 1.2
  • Property rcs:state set to Exp
  • Property svn:keywords set to Author Date Revision Id
File size: 20.7 KB
Line 
1<html>
2<head>
3   <META NAME="Author" CONTENT="Brian H. Toby">
4   <title>EXPGUI -- LIVEPLOT/BKGEDIT</title>
5</head>
6<BODY BGCOLOR="#FFFFFF">
7
8<A HREF=http://www.ncnr.nist.gov>
9<IMG SRC="http://www.ncnr.nist.gov/images/ncnrtrans.gif" 
10alt="Link to NIST Center for Neutron Research home page"
11ALIGN=RIGHT></A>
12<A HREF=http://www.nist.gov>
13<IMG SRC="http://www.ncnr.nist.gov/images/webidblue_2lineright.gif" 
14alt="Link to National Institute of Standards & Technology home page"
15ALIGN=LEFT></A>
16<CENTER>
17<A Href="http://www.ncnr.nist.gov/programs/crystallography/software/tclpkgs.html">
18<IMG SRC="tcltklogo100.gif" 
19alt="Link to Tcl/Tk information">
20</CENTER></A>
21<br clear=all><hr>
22
23<TABLE BORDER BGCOLOR="#FFFF40" ALIGN=RIGHT>
24<TR><TH><A  Href="expgui.html">EXPGUI top</A> 
25</TH></TR></TABLE><BR CLEAR=ALL>
26
27<center><h1>
28LIVEPLOT and BKGEDIT
29</h1></center>
30This page documents the LIVEPLOT and BKGEDIT utility programs
31in the EXPGUI package.
32LIVEPLOT and BKGEDIT are actually the same program, but perform
33different functions, depending on how they are invoked.
34LIVEPLOT is used to display the quality of the diffraction fit, while
35BKGEDIT is used to fit a background function to fixed background points
36that have been input by the user.
37<P>
38Both LIVEPLOT and BKGEDIT get the current diffraction information
39by running the TCLDUMP program, if installed, or
40HSTDUMP otherwise. The TCLDUMP program has been optimized for use
41with LIVEPLOT and offers a number of extra
42options that are not available when HSTDUMP is used. Since TCLDUMP has been
43included in GSAS since April of 2000, it is assumed that this is now the case.
44
45<a name="liveplot"></a>
46<H3>LIVEPLOT</H3>
47LIVEPLOT is started by pressing the LIVEPLOT button on the toolbar
48or via the Graphs/liveplot menu item.
49<P>
50Some of the features available in LIVEPLOT are:
51<UL>
52<LI>The plot is updated automatically after each refinement run
53<LI>The plot can be zoomed, by clicking on the corners of the
54area to be magnified.
55<LI>
56The units used for plotting histograms can be selected. Choices are:
57native units (2Theta/TOF/KeV); d-space (A) or Q (A<sup>-1</sup>)
58<LI>
59The background (fixed plus fitted) can be plotted or can be subtracted.
60<LI>
61Reflection tickmarks can be displayed in a variety of formats
62<LI>
63LIVEPLOT can be coupled to the LOGIC or CMPR programs, so that
64peak positions from an ICDD entry or for an arbitrary unit cell and
65spacegroup can be shown superimposed on the "Rietveld plot."
66<LI>
67<IMG SRC="note.gif" alt="Note!">
68Reflection indices (<I>hkl</I> values) can be shown for tickmarks
69<LI>
70<IMG SRC="new.gif" HEIGHT=13 WIDTH=36 alt="New!">
71The cumulative chi<sup>2</sup> function can be plotted.
72</UL>
73
74<a name="bkgedit"></a>
75<H3>BKGEDIT</H3>
76<IMG SRC="new.gif" HEIGHT=13 WIDTH=36 alt="New!">
77For most refinements, it is possible to simply select a background
78function (I find that the type 1 function,
79shifted Chebyschev polynomials, work well)
80and then refine, adding terms until a good fit is obtained.
81On occasion, poor initial fits are obtained in this manner. This is
82most common in cases where large numbers of peaks are poorly fit. Since
83significant sections of the data are not well fit, the refinement results in
84an unreasonable background function, because this yields better agreement
85with the observed data.
86In these cases,
87it may be best to fix the background to follow a "reasonable" curve in the
88initial stages and then refine the background in the final stages of
89refinement, when a good model has been obtained.
90<P>
91The BKGEDIT program, as shown below, is used to input a set a background
92points via the mouse. The points are then used to determine a type 1
93(Chebyschev) background function that fits the input background points. These
94terms can then be saved in the experiment file creating a background that
95is good enough for the initial stages of refinement and that can be
96refined once the model is adequate for the task.
97<P>
98<IMG SRC="b1.gif" align=TEXTOP alt="BKGEDIT screen image">
99<H4>Steps in fitting a background function</H4>
100The BKGEDIT program is started from
101via the Powder/bkgedit menu item or by pressing the
102"Fit Background Graphically" button on the
103<A href="http:expgui3.html#EditBackground">"Edit Background"</A>
104dialog box (invoked from the "Edit Background" button on the
105<A href="http:expgui3.html">Histogram pane</A>.)
106toolbar
107or
108<OL>
109<LI><a href="http:#zoom">Zoom in</a> on the lower intensity section of the
110plot, so that the background is clearly discernible. In some cases, the
111data will need to be handled in sections.
112<LI>Press the "Add" button to add background points.
113Note the cursor changes from cross-hairs to an arrow,
114when the "Add" button is pressed.
115<LI>Move the mouse to the first location
116where a background point will be added and click with the left
117mouse button. A magenta triangle will appear at the location.
118Points can be added in any order. It is best to make sure that the fixed points
119are placed over the entire range of the data, e.g. near the maximum and minimum
120data points in TOF, 2theta, etc.
121<DL><DL>
122Note that it is advisable to place many background points in areas where
123the background varies greatly.
124</DL></DL>
125As background points are entered, they are saved in a file named
126<I>EXPNAM</I><tt>.bkg</tt><I>N</I>, where
127<I>EXPNAM</I> is the experiment name and <I>N</I> is the histogram number.
128If BKGEDIT is restarted at some later time, these points are reread.
129<LI>If any points are placed in incorrect positions, they can be deleted by
130pressing the "Delete" button. The mouse cursor changes to a circle. When
131the mouse left clicked, the fixed background point closest to the mouse
132position (which may be outside the zoom range) is deleted.
133<LI>Background points can also be edited by entering numbers into the
134"Background points" area.
135<LI>After enough background points have been entered, the
136"Start Fit" button turns from gray to black. When pressed, the Chebyschev
137polynomial is fitted and the resulting curve is shown as a blue dashed line.
138<DL><DL>
139It is suggested that you start with relatively few
140terms and add terms and background points as needed.
141Note that the maximum number of Chebyschev terms increases as
142more background points are entered.
143</DL></DL>
144The "Improve Fit" button is black when the fit did not
145converge or the number of terms has been changed. "Improve Fit" causes the
146fit to be refined starting from the previous values.
147<LI>Editing the Chebyschev terms is possible. The curve is reevaluated as
148changes are made.
149<LI>Once a good background function is determined, it can be saved in the
150experiment file by pressing the "Save in EXP file & Exit" button. This will
151set the background type to 1, and save the Chebyschev terms.
152It will also turn off
153the background refinement flag for the appropriate histogram so that the
154terms are not refined inadvertently.
155</OL>
156
157<P>
158Note that POWPREF must be run at least once before BKGEDIT can be used,
159however, use of
160GENLES before BKGEDIT is optional. If the data range is changed, for example
161by excluding a section of the data at the lower end, or changing tmax (dmin),
162the Chebyschev polynomial terms must change to generate the same
163background values, so both POWPREF and BKGEDIT should be rerun to
164regenerate the Chebyschev terms.
165
166<H4>Why not use fixed background points?</H4>
167I personally feel that
168a refined background function is preferrable to use of a fixed model,
169if at all possible.
170One reason for this is that Rietveld refinements usually achieve better fits
171when the background is optimized. A second reason refining the background
172provides a
173feel for the interaction between background values and displacement
174(thermal) parameters.
175Usually, background and displacement parameters are fairly independent, but
176for some materials, where the high Q (high 2theta) portion of the pattern
177has many completely overlapped peaks, it is impossible to uniquely
178determine where the
179background should be placed, either by refinement or by manual placement.
180Under these circumstances, the background should be refined with the
181displacement parameters fixed at an appropriate value for the material. The
182background should then be fixed for all future refinements
183and the displacement parameters can then be refined. <I>Of course this
184means you have predjudiced the refinement to result in the expected
185average displacement parameter and this </I><B>must</B><I> be noted
186any publication. However, if this is necessary, the data simply do not
187contain sufficient information to independently determine
188background and displacement parameters. Use of fixed background points
189would not demonstrate this and would lead the researcher to a false
190sense of security (or fear, if the values are unreasonable)
191that the displacement parameters actually mean something.</I>
192<P>
193If you still want to use fixed background points, despite this tirade,
194be sure to set the estimated
195error on those points to be 0.0. Use of non-zero estimated errors, can
196result in artificially lowered R-factors and chi-squared values.
197In one test, I was able to lower the R<sub>wp</sub> and
198reduced chi<sup>2</sup> values,
199from the correct values of 0.042 and 3.0, respectively, to misleading
200values of 0.036 and 0.8,
201respectively. [As expected, the R(F<sup>2</sup>) stayed constant at 0.045;
202FYI, refining the background caused R(F<sup>2</sup>) to drop to 0.036.]
203<P>
204If the background is so truly irregular that only use of fixed background
205points will do,
206BKGEDIT can be used to generate these fixed background points.
207The file used by BKGEDIT to save these points,
208<I>EXPNAM</I><tt>.bkg</tt><I>N</I>,
209can be read into EXPEDT by typing "@R" at the initial prompt
210in EXPEDT:
211<PRE>
212   Is this the file you wish to use? (<?>,D,K,Q,R,Y) ><u>@r</u>
213</PRE>
214prompt and then supplying the name of the file, in response to the next prompt:
215<PRE>
216   Enter the name of your macro file: <u>GARNET.bkg1</u>
217</PRE>
218And this will enter the background points entered into BKGEDIT as GSAS
219fixed background points. If you do this you do not want to fit and enter
220Note that you are allowed to use both fixed and a refined background together,
221though this is seldom done.
222
223<hr><h2>LIVEPLOT/BKGEDIT Features</h2>
224<a name="zoom"></a>
225<B>Plot zooming</B>
226When the left (usual) mouse button is pressed, this defines one corner
227of a region to be magnified, as is shown to the right.
228If the mouse is then moved, the diagonal
229corner of this magnification region is defined. When the left mouse button
230is pressed a second time, the selected section of the plot is magnified to
231fill the entire plot.
232<P>
233Zoom settings are saved.
234If the right mouse button is pressed, the previous zoom setting is used,
235so that the left mouse button is used to "zoom in" and the right mouse
236button is used to "zoom out."
237
238<P>
239<h2>Features in LIVEPLOT only</h2>
240<img SRC="lz.gif" BORDER=3 align=RIGHT alt="EXPGUI Screen snapshot">
241<B>The cumulative chi<sup>2</sup></B>
242function was first suggested by
243Bill David as a way to see which reflections have the greatest influence on
244chi<sup>2</sup> [W.I.F. David, <I>Accuracy in Powder Diffraction-III</I>, 2001].
245It is defined for point j as
246<IMG SRC="cchi2.gif" alt="equation for cumulative chi2 function" ALIGN=TOP>
247where y<sub>obs,i</sub> and y<sub>calc,i</sub> are the observed and computed
248data points and sigma<sub>i</sub> is the expected error. Thus, the statistically
249expected value for
250[(y<sub>obs,i</sub>-y<sub>calc,i</sub>)/sigma<sub>i</sub>]<sup>2</sup> is 1
251and this function should rise in a smooth line if all points are fitted as
252statistically expected.
253<P>
254In the plot to the right, the cumulative chi<sup>2</sup> function is shown in
255purple. Note that first peak is not well fit, but the low angle "shoulder" is
256as important as the peak misfitting, with respect to the chi<sup>2</sup>.
257<br clear=all>
258<P>
259<img SRC="lind.gif" BORDER=3 align=RIGHT alt="EXPGUI Screen snapshot">
260<B>Reflection indices</B>
261are be displayed by pressing "H" or "h" while the
262mouse is near a reflection (holding the shift key while
263pressing the left mouse button also works). The indices are shown
264on the screen for phases with tick marks (as shown to the right).
265Indices are listed in the "Separate window for <I>hkl</I> labels"
266(as seen below) for all phases, regardless of the tickmark settings.
267Displayed indices will remain on the screen for a preset time and
268then will be deleted, unless the labeling options are changed.
269<img SRC="lind1.gif" align=LEFT alt="EXPGUI Screen snapshot">
270<P>
271<br clear=all>
272
273<hr><h2>LIVEPLOT/BKGEDIT Menu Contents</h2>
274A few of these options are omitted from BKGEDIT.
275<DL><DL>
276<img SRC="lm1.gif" align=RIGHT alt="EXPGUI Screen snapshot">
277<H3>File Menu</H3>
278<DT>Tickmarks
279<DD>Checkbuttons are provided for each phase to determine if tick marks
280are shown. See the Options/"Configure Tickmarks"menu item for information
281on tickmarks
282<DT>Histogram
283<DD>This allows a histogram to be selected to be loaded
284<DT>Update Plot
285<DD>The causes LIVEPLOT to read read the current histogram again from
286the datafile
287<DT>Make PostScript
288<DD>Creates a low quality PostScript file containing the LIVEPLOT
289output. See the Options/"Set PS output" button for where the file is created.
290<DT>Quit
291</DL></DL>
292<br clear=all>
293<DL><DL>
294<img SRC="lm2.gif" align=RIGHT alt="EXPGUI Screen snapshot">
295<H3>File Menu</H3>
296<DT>Configure Tickmarks
297<DD>Tickmarks can be placed automatically, similar to their
298 placement in POWPLOT or can be drawn one height to another. The default
299is for lines to be draw from "-Inf" to "Inf", which creates lines from the
300bottom to the top of the plot. The options for each phase allow the line to be changed between solid and dashed, color of the line can be specified and
301the vertical placement of the tickmarks can be specified. The "show" flag,
302set in the File/Tickmarks menu can also be changed here.
303<DT>Obs symbol
304<DD>This brings up a menu where the symbol type and size for the
305observed data points can be selected.
306<DT>X units
307<DD>The x units can be selected here. The choices are
308"as collected" (2Theta/TOF/KeV), d-space (A) or Q (A<sup>-1</sup>)
309<DT>Y units
310<DD>The intensity values can be normalized by the incident spectrum
311(for energy dispersive methods).
312<DT>HKL labeling
313<DD>This brings up a menu that selects how long <I>hkl</I> values are shown
314before they are erased (0 means that they are not erased), the size of the
315labels and the width around the mouse that is searched for matching
316reflections. If requested using the "Separate window for <I>hkl</I> labels"
317option, labels are also show in a separate window.
318<DT>Subtract background
319<DD>The background is always shown, even when subtracted
320<DT>Include legend
321<DD>The legend is the optional box in the upper left that defines the
322plot entries
323<DT>Set PS output
324<DD>For UNIX this allows the file to be sent directly to a printer
325or can be saved in a file. For Windows, a file must be written.
326<DT>Raise on update
327<DD>This causes the plot to be placed on top of other windows, if partially
328obscured, when the plot is updated. At this time, this option does not
329work in Windows-NT and -2000.
330<DT>Cumulative Chi2
331<DD>The causes the Cumulative chi<sup>2</sup> function to be defined
332(see below).
333<DT>Save Options
334<DD>Causes many of the options set in this menu to be saved in the <TT>.gsas_config</TT> file.
335</DL></DL>
336<br clear=all>
337
338<P>
339<hr><H2>Customization of LIVEPLOT & BKGEDIT</H2><A NAME="customize"></A>
340The <TT>localconfig</TT> and <TT>.gsas_config</TT> files are read, if present.
341The following variables control how LIVEPLOT, and in most cases BKGEDIT,
342function and can be
343customized by changing their values in the
344<TT>localconfig</TT> and <TT>.gsas_config</TT> files.
345Note that some of these options are relevant only if the tcldump program is
346present.
347<DL><DL>
348<DT><TT>peakinfo(flag<i>n</i>)</TT><DD>
349These variables define if peak positions will be shown
350for reflections in phase "<i>n</i>". Reflections will be shown if
351the value is non-zero.
352
353<DT><TT>peakinfo(color<i>n</i>)</TT><DD>
354These variables define the default colors for
355reflections in phase "<i>n</i>"
356
357<DT><TT>peakinfo(dashes<i>n</i>)</TT><DD>
358These variables define if peaks will be dashed for
359reflections in phase "<i>n</i>" (UNIX only). Lines will be dashed if
360the value is non-zero.
361
362<DT><TT>peakinfo(min<i>n</i>) and peakinfo(max<i>n</i>)</TT><DD>
363These variables dictate the placement vertical position for reflection
364markers, when manually placed (see expgui(autotick), below). To draw
365to the edge of the screen, use -Inf and Inf.
366</DL></DL>
367
368The following variables are written to <tt>.gsas_config</tt> when
369"Save Options" is used. These variables are all set from the GUI and therefore
370do not need to be edited manually.
371
372<DL><DL>
373<DT><TT>graph(printout)</TT><DD>
374This is set to 1 if PostScript files
375will be printed and 0 if they will be written to disk (for Windows all
376files should be written to disk).
377
378<DT><TT>graph(outname)</TT><DD>
379This is the default for the file name used
380when PostScript files will be written to disk.
381
382<DT><TT>graph(outcmd)</TT><DD>
383This is the default for the command used
384to print PostScript files (Unix only).
385
386<DT><TT>graph(legend)</TT><DD>
387Sets the default value for display of the legend in LIVEPLOT and widplt.
388
389<DT><TT>graph(autoraise)</TT><DD>
390This option shows up in the options menu item as "Raise on update."
391When set to non-zero, the LIVEPLOT window is raised
392(placed on top of any other overlapping) windows
393each time it is updated.
394This option does not seem to work in Windows-NT, but this may depend on
395the version of Tcl/Tk.
396
397<DT><TT>peakinfo(obssym)</TT><DD>
398Symbol for observed data points. Valid choices are square, circle, diamond,
399plus, cross, splus and scross.
400
401<DT><TT>peakinfo(obssize)</TT><DD>
402Size for the symbol for observed data points. A value of 1 corresponds to about 1/8 inch
403(about 3 mm).
404
405<DT><TT>expgui(pixelregion)</TT><DD>
406When hkl values are loaded (using tcldump) and reflections are labeled, reflections
407can be labeled using a Shift-Left-Mouse click. All labeled reflections within expgui(pixelregion)
408pixels of the mouse position are assumed to be overlapped and are labeled.
409
410<DT><TT>expgui(fadetime)</TT><DD>
411The time in seconds before reflection labels are removed. A value of zero means that reflections
412must be deleted manually (Shift-Right-Mouse).
413
414<DT><TT>expgui(lblfontsize)</TT><DD>
415A size for reflections labels in pixels.
416
417<DT><TT>expgui(hklbox)</TT><DD>
418If this variable is non-zero, reflection indices are shown in a box.
419
420<DT><TT>expgui(autotick)</TT><DD>
421If this variable is non-zero, reflection markers positions are
422set automatically.
423</DL></DL>
424<P>
425<hr><H2>Installation details/External Programs</H2>
426<B>Using TCLDUMP with LIVEPLOT.</B>
427LIVEPLOT works with the standard GSAS program HSTDMP, but it works faster and is more
428powerful when used with the TCLDUMP program.
429Note that as of the April 2000 releases, GSAS is now distributed with TCLDUMP
430included. For older versions of GSAS, note the
431instructions for downloading this file can in the installation notes for
432<A HREF="expgui_Win_readme.html">
433Windows</A> and
434<A HREF="expgui_Unix_readme.html">
435UNIX</A>.
436<P>
437
438<B>Combining CMPR and LIVEPLOT.</B>
439If you have <A HREF="http://www.ncnr.nist.gov/programs/crystallography/software/cmpr.html">CMPR</A>
440installed on your computer, you can use superimpose on the GSAS results
441the peaks for an arbitrary unit cell. If desired, space group extinctions
442can even be shown.
443This is pretty neat! To enable this feature, you must have a version
444of CMPR downloaded after 4 May 1998
445<A HREF="http://www.ncnr.nist.gov/programs/crystallography/software/cmpr.html">
446(see the CMPR installation instructions.)</A>
447<UL><LI>
448For UNIX, create a link from in the EXPGUI
449directory to file cellgen.tcl in the CMPR directory. For example:
450<PRE>
451   ln -s /usr/local/cmpr/cellgen.tcl /usr/local/gsas/expgui/cellgen.tcl
452</PRE>
453<LI>For Windows, copy all the .tcl and .exe files from the CMPR directory
454into the EXPGUI directory.
455</UL>
456<P>
457
458<B>Combining LOGIC and LIVEPLOT.</B>
459If you have <A HREF="http://www.ncnr.nist.gov/programs/crystallography/software/logic.html">LOGIC</A>
460installed on your computer, you can superimpose peaks
461for a entry from the ICDD/JCPDS database on a pattern in LIVEPLOT.
462This is also pretty neat!
463To enable this feature, you must have
464a version of LOGIC downloaded after 4 May 1998
465<A HREF="http://www.ncnr.nist.gov/programs/crystallography/software/logic.html">
466(see the LOGIC installation instructions.)</A>
467<UL><LI>
468For UNIX, create a link from in the GSAS GUI
469directory to file icddcmd.tcl in the LOGIC directory. For example:
470<PRE>
471   ln -s /usr/local/powdersuite/icddcmd.tcl /usr/local/gsas/expgui/icddcmd.tcl
472</PRE>
473<LI>For Windows, copy all the LOGIC files into the EXPGUI directory.
474</UL>
475<hr>
476<TABLE BORDER BGCOLOR="#FFFF40" ALIGN=RIGHT>
477<TR><TH><A  Href="expgui.html">EXPGUI top</A> 
478</TH></TR></TABLE>
479
480<a href="http://www.ncnr.nist.gov/staff/toby/">Brian Toby</a> (<a href="mailto:brian.toby@nist.gov">Brian.Toby@NIST.GOV</a>)
481<br>
482$Revision: 406 $ $Date: 2009-12-04 23:05:38 +0000 (Fri, 04 Dec 2009) $
483</body>
484</html>
Note: See TracBrowser for help on using the repository browser.