source: Tutorials/PythonScript/Scripting.htm @ 3207

Last change on this file since 3207 was 3207, checked in by toby, 4 years ago

New command-line tutorial

  • Property svn:mime-type set to text/html
File size: 23.7 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2<html> <head>
3<title>Scripting GSAS-II</title>
4</head>
5
6<body>
7<h1>Running a GSAS-II Refinement From a Python Script</h1>
8To demonstrate the use of the
9<A href="http://gsas-ii.readthedocs.io/en/latest/GSASIIscripts.html" target="_blank">
10GSASIIscriptable module</A>, we create a Python script to duplicate the
11refinement in the
12<A
13href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/CWCombined/Combined%20refinement.htm"
14target="_blank">GSAS-II CW Combined Refinement</A>
15tutorial. This uses a Python script
16to perform the same refinements steps as in that tutorial, but without use of the GSAS-II
17graphical user interface. Note that the
18<A href="http://gsas-ii.readthedocs.io/en/latest/GSASIIscripts.html" target="_blank">
19GSASIIscriptable module</A> does not offer access to all of the
20features within GSAS-II, but over time it is expected to grow in
21capabilities. Much of the initial development for this module was done
22by Jackson O'Donnell, as a summer undergraduate visitor under
23supervisor Dr. Maria Chan. Other programming contributions are welcome.
24
25<h2>Prerequisites</h2>
26This exercise assumes that the reader has reasonable familiarity with
27the Python language.
28Also, the documentation on the
29<A href="http://gsas-ii.readthedocs.io/en/latest/GSASIIscripts.html"
30target="_blank">
31Scripting Tools in the GSAS-II GSASIIscriptable module</A> should be
32read from here: <A href="http://gsas-ii.readthedocs.io/en/latest/GSASIIscripts.html"
33target="_blank">http://gsas-ii.readthedocs.io/en/latest/GSASIIscripts.html</A>. It
34is also wise to read the <A href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/CWCombined/Combined%20refinement.htm"
35target="_blank">GSAS-II CW Combined Refinement</A> tutorial that this
36exercise is modeled upon, which explains why each refinement step is
37being used.
38The exercise will require downloading of the same files needed for the
39Combined Refinement tutorial: "PBSO4.XRA", "INST_XRY.PRM", "PBSO4.CWN",
40"inst_d1a.prm" and "PbSO4-Wyckoff.cif",
41which can be downloaded from
42<A href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/PythonScript/data/">
43https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/PythonScript/data/</A>)
44or will be downloaded with this tutorial if that is requested.
45<P>
46The exercise can be performed by placing all of the Python commands
47into a script, (which is supplied for
48<A href="https://subversion.xray.aps.anl.gov/trac/pyGSAS/browser/Tutorials/PythonScript/data/example.py?format=txt">
49download here</A>),
50but a more pedagogical approach will be to enter the
51commands into a Python interpreter. Use of IPython or Jupyter to run
52Python will make this a more pleasant experience.
53
54<h2>Multi-step Script Approach</h2>
55
56<h4>0: Load the GSASIIscriptable module</H4>
57<blockquote>
58The first step in writing any Python module is to load the modules
59that will be needed. Here we will need the <tt>os</tt> and
60<tt>sys</tt> modules from the Python standard library and the
61GSASIIscriptable from the GSAS-II code. The location where the
62GSAS-II source code is installed must usually be hard-coded into the
63script as is done in the example below. Note that a common location
64for this will be
65<TT>os.path.expanduser("~/g2conda/GSASII/")</TT> or
66<tt>'/Users/toby/software/GSASII'</tt>, etc.
67Thus the script will begin with something like this:
68
69<blockquote><textarea rows="3" cols="60" readonly>
70import os,sys
71sys.path.insert(0,os.path.expanduser("~/g2conda/GSASII/"))
72import GSASIIscriptable as G2sc</textarea></blockquote>
73
74If a <tt>ImportError: No module named GSASIIscriptable</tt> error
75occurs, then the wrong directory location has been supplied for the
76GSAS-II files.
77</blockquote>
78
79<h4>1: Define some other prerequisite code</H4>
80<blockquote>
81To simplify this example, we will define the location where files will
82be written as <tt>workdir</tt> (this directory must exist, but it may
83be empty) and the location where the input files for this exercise
84("PBSO4.XRA", "INST_XRY.PRM", "PBSO4.CWN",
85"inst_d1a.prm" and "PbSO4-Wyckoff.cif") will
86be found as <tt>datadir</tt>. (As discussed previously,
87these files can be
88<A href="https://subversion.xray.aps.anl.gov/pyGSAS/Tutorials/PythonScript/data/">
89downloaded from here. </A>)
90<P>
91We also define here a short function to display the weighted profile R
92factor for every histogram in a project, <tt>HistStats</tt>. This will
93be <A href="#HistStats">discussed later</A>.
94
95<blockquote><textarea rows="10" cols="70" readonly>
96workdir = "/Users/toby/Scratch/PythonScript"
97datadir = "/Users/toby/software/G2/Tutorials/PythonScript/data"
98
99def HistStats(gpx):
100    '''prints profile rfactors for all histograms'''
101    print(u"*** profile Rwp, "+os.path.split(gpx.filename)[1])
102    for hist in gpx.histograms():
103        print("\t{:20s}: {:.2f}".format(hist.name,hist.get_wR()))
104    print("")
105    gpx.save()</textarea></blockquote>
106
107</blockquote>
108
109<h4>2: Create a GSAS-II project</H4>
110<blockquote>
111The first step in creating a GSASIIscriptable script to to create or
112access a GSAS-II project, which is done with a call to
113<TT>GSASIIscriptable.G2Project()</tt>. This can be done in one of two
114ways: a call with <tt>G2sc.G2Project(filename=</tt><I>file</I><tt>)</tt> creates a new
115(empty) project, while a call with
116<tt>G2sc.G2Project(gpxfile=</tt><I>file</I><tt>)</tt> opens and
117reads an existing project (.gpx) file. Both return a <tt>G2Project</tt> wrapper
118object that is used to access a number of methods and variables.
119Note that <TT>GSASIIscriptable.G2Project()</tt> can read .gpx files
120written by both previous <TT>GSASIIscriptable.G2Project()</tt> runs or
121the GSAS-II GUI.
122<P>
123In this example, we create a new project by using the
124<tt>filename=</tt><I>file</I> argument with this code:
125   
126<blockquote><textarea rows="3" cols="70" readonly>
127# create a project with a default project name
128gpx = G2sc.G2Project(filename='PbSO4.gpx')</textarea></blockquote>
129
130Note that the file will not actually be created until an operation
131that saves the project is called.
132</blockquote>
133
134<h4>3: Add Histograms and Phase to the GSAS-II project</H4>
135<blockquote>
136To add two powder diffraction datasets (histograms) and a phase to the
137project using this code:
138
139<blockquote><textarea rows="10" cols="70" readonly>
140# setup step 1: add two histograms to the project
141hist1 = gpx.add_powder_histogram(os.path.join(datadir,"PBSO4.XRA"),
142                          os.path.join(datadir,"INST_XRY.PRM"))
143hist2 = gpx.add_powder_histogram(os.path.join(datadir,"PBSO4.CWN"),
144                          os.path.join(datadir,"inst_d1a.prm"))
145# setup step 2: add a phase and link it to the previous histograms
146phase0 = gpx.add_phase(os.path.join(datadir,"PbSO4-Wyckoff.cif"),
147                      phasename="PbSO4",
148                      histograms=[hist1,hist2])</textarea></blockquote>
149
150 
151We use the <I>project</I><tt>.add_powder_histogram()</tt> method in
152the <TT>GSASIIscriptable</tt> class to read in the powder data.
153The two arguments to
154<tt>.add_powder_histogram()</tt> are the powder dataset and the
155  instrument parameter file. Note that these files are both "GSAS
156  powder data" files and the importer for this format (and many
157  others) allows files with arbitrary extensions to be read.
158All importers that allow for extensions .XRA and .CWN will be
159used to attempt to read the file, producing a number of warning
160messages. To specify that only the GSAS powder data importer be
161used, include a third argument, <tt>fmthint="GSAS powder"</tt> or
162something similar (<tt>fmthint="GSAS"</tt> is also fine, but will
163cause both the "GSAS powder data" and the "GSAS-II .gpx" importer to be considered.)
164<UL><LI>
165  Note that <I>project</I><tt>.add_powder_histogram()</tt> returns a
166  powder histogram objects, which here are saved for later reference. It is
167  also possible to obtain these using <tt>gpx.histograms()</tt>, which
168  returns a list of defined histograms.
169</UL>
170<P>
171Then we add a phase to the project using
172  <I>project</I><tt>.add_phase()</tt>. This specifies a CIF containing the
173  structural information, a name for the phase and specifies that the
174  two histograms are "added" (linked) to the phase. The
175<tt>fmthint="CIF"</tt> parameter can also optionally be specified to limit the
176importers that will be tried.
177
178  <UL><LI>
179  Note that <I>project</I><tt>.add_phase()</tt>
180  returns a phase object</li>
181  <LI>Also, the previously saved histogram objects are used in the
182  <I>project</I><tt>.add_phase()</tt> call. Note that it is
183  also possible to reference the two histgrams by their numbers in the
184  project (here <tt>histograms=[0,1]</tt>) or by the histogram names
185  (here <BR><TT>histograms=['PWDR PBSO4.XRA Bank 1', 'PWDR PBSO4.CWN
186  Bank 1']</TT>).
187  These three ways to use the <tt>histograms</tt> parameter produce
188  the same result.
189</blockquote>
190   
191<A name="ChangeCycles">
192<h4>4: Change the number of refinement cycles</H4>
193</A><blockquote>
194While this is not noted in the original tutorial, this exercise will
195  not complete properly if more variables are added to the refinement
196  without converging the refinement (or at least coming close to
197  convergence) at each refinement step. This is best accomplished by
198  increasing the number of least-squares cycles. No supplied method (at
199  present) allows this parameter to be set straightforwardly, but this
200  code will do this:
201 
202 <blockquote><textarea rows="3" cols="70" readonly>
203# not in tutorial: increase # of cycles to improve convergence
204gpx.data['Controls']['data']['max cyc'] = 8 # not in API </textarea></blockquote>
205
206<P>
207  To find this parameter in the GSAS-II data structure, I followed
208  these steps: In the GUI, Controls is the tree item
209  corresponding to the section where Least Squares cycles are
210  set. Executing the command <tt>gpx.data.keys()</tt> shows the names of the
211  entries in the dictionary corresponding to the GSAS-II tree and
212  indeed one entry is 'Controls'.
213  Command <tt>gpx.data['Controls'].keys()</tt> shows that all
214  values are located in an entry labeled 'data' and
215  <tt>gpx.data['Controls']['data'].keys()</tt> shows the entries in
216this section. Examination of
217<tt>gpx.data['Controls']['data']['max cyc']</tt> shows the value 3,
218which is default number of cycles. Thus,
219the number of cycles is changed with the Python command above.
220
221</blockquote>
222
223<h4>5: Set initial variables and refine</H4>
224<blockquote>
225
226In Step 4 of the original tutorial, the refinement is performed with
227the variables that are on by default. These variables are the two
228histogram scale factors and three background parameters for each
229histogram (8 in total). With GSASIIscriptable, the background
230refinement flags are not turned on by default, so a dictionary must be
231created to set these histogram variables. This code:
232<blockquote><textarea rows="5" cols="75" readonly>
233# tutorial step 4: turn on background refinement (Hist)
234refdict0 = {"set": {"Background": { "no. coeffs": 3, "refine": True }}}
235gpx.save('step4.gpx')
236gpx.do_refinements([refdict0])
237HistStats(gpx)</textarea></blockquote>
238<UL>
239<LI>defines a dictionary (refdict0) that will be used to set the number of background coefficients (not really
240needed, since the default is 3) and sets the background refinement
241flag "on".</li>
242<LI>The project is saved under a new name, so that we can later look at
243the results from each step separately.</li>
244<LI>The parameters in refdict0 are set using
245<I>project</i><tt>.do_refinements()</tt> for both histograms in the
246project and the a refinement is run.
247<LI>The weighted profile R-factor values for all histograms in the project
248are printed using the previously defined <tt>HistStats()</tt> function.
249</UL>
250
251<A name="HistStats">
252Function <tt>HistStats()</tt> works by using <tt>gpx.histograms()</tt>
253to iterate over all histograms in the project, setting <tt>hist</tt> to each histogram
254object. Class member <tt>hist.name</tt> provides the histogram name
255and method <tt>hist.get_wR()</tt> looks up the profile R-factor and
256prints them. The function also writes the final refinement results
257into the current project file. </A>
258
259The output from this will be:<blockquote><pre>
260 Hessian Levenburg-Marquardt SVD refinement on 8 variables:
261initial chi^2 9.6912e+06
262 Cycle: 0, Time: 1.88s, Chi**2: 6.7609e+05, Lambda: 0.001,  Delta: 0.93
263initial chi^2 6.7609e+05
264 Cycle: 1, Time: 1.84s, Chi**2: 6.7602e+05, Lambda: 0.001,  Delta: 0.000104
265converged
266Found 0 SVD zeros
267Read from file: /Users/toby/software/G2/Tutorials/PythonScript/step4.bak0.gpx
268Save to file  : /Users/toby/software/G2/Tutorials/PythonScript/step4.gpx
269GPX file save successful
270 Refinement results are in file: /Users/toby/software/G2/Tutorials/PythonScript/step4.lst
271 ***** Refinement successful *****
272*** profile Rwp, step4.gpx
273        PWDR PBSO4.XRA Bank 1: 40.88
274        PWDR PBSO4.CWN Bank 1: 18.65
275</pre></blockquote>Note that the Rwp values agree with what is
276 expected from the original tutorial.
277<P>
278<B>Note:</B> that there are several equivalent ways to set the histogram
279parameters using
280<tt>G2PwdrData.set_refinements()</tt>,
281<tt>G2Project.set_refinement()</tt> or
282<tt>my_project.do_refinements()</tt>, as
283<A href="http://gsas-ii.readthedocs.io/en/latest/GSASIIscripts.html#refinement-parameters">
284described here</A>. Thus, the <tt>gpx.do_refinements([refdict0])</tt>
285statement above could be replaced with:
286<blockquote><pre>
287gpx.set_refinement({"Background": { "no. coeffs": 3, "refine": True }})
288gpx.do_refinements([{}])
289</pre></blockquote>
290or
291<blockquote><pre> 
292for hist in gpx.histograms():
293    hist.set_refinements({"Background": { "no. coeffs": 3, "refine": True }})
294gpx.do_refinements([{}])
295</pre></blockquote>
296
297</blockquote>
298<h4>6: Add unit cell parameters to refinement</h4>
299<blockquote>
300
301In Step 5 of the original tutorial, the refinement is performed again,
302but the unit cell is refined in the phase.
303
304<blockquote><textarea rows="6" cols="75" readonly>
305# tutorial step 5: add unit cell refinement (Phase)
306gpx.save('step5.gpx')
307refdict1 = {"set": {"Cell": True}} # set the cell flag (for all phases)
308gpx.set_refinement(refdict1)
309gpx.do_refinements([{}])
310HistStats(gpx)</textarea></blockquote>
311
312In this case the <tt>gpx.set_refinement(refdict1)</tt> statement can
313be replaced with:<blockquote><pre>
314phase0.set_refinements({"Cell": True})
315</pre></blockquote>
316
317Note that it is also possible to combine the refinement in the current
318and previous section using
319<blockquote><pre>
320gpx.do_refinements([refdict0,refdict1])
321</pre></blockquote>
322but then the results are not saved in separate project files and it is
323not possible to see the Rwp values after each refinement.
324
325</blockquote>
326<h4>7: Add hydrostatic strain for just one histogram</h4>
327<blockquote>
328
329In Step 6 of the original tutorial, the refinement is performed again
330after adding Histogram/Phase (HAP) parameters so that the lattice
331constants for the first histogram (only) can vary. This is done with
332this code:
333
334<blockquote><textarea rows="6" cols="75" readonly>
335# tutorial step 6: add Dij terms (HAP) for histogram 1 only
336gpx.save('step6.gpx')
337refdict2 = {"set": {"HStrain": True}} # set HAP parameters
338gpx.set_refinement(refdict2,phase=phase0,histogram=[hist1])
339gpx.do_refinements([{}]) # refine after setting
340HistStats(gpx)</textarea></blockquote>
341
342Here we cannot use <tt>gpx.do_refinements([refdict2])</tt> with
343<tt>refdict2</tt> defined as above because
344that would turn on refinement of the Hstrain terms for all histograms
345and all phases. There are several ways to restrict the parameter
346changes to specified histogram(s) and phase(s). One is to call a
347method in the phase object(s) directly, such as
348replacing the <tt>gpx.set_refinement(...)</tt>
349statement with this:
350<blockquote><pre>
351phase0.set_HAP_refinements({"HStrain": True},histograms=[hist1])
352</pre></blockquote>
353
354It is also possible to add "histograms" and/or "phases" values into
355the <tt>refdict2</tt> dict, as will be <a href="#SingeStep">described below.</a>
356</blockquote>
357
358<h4>8: Add X-ray Sample broadening terms</h4>
359<blockquote>
360The next step in the original tutorial is to treat sample broadening
361by turning on refinement of the "Mustrain" (microstrain) and
362"Size" (Scherrer broadening) terms using an isotropic (single-term)
363model. As described in the
364<A
365href="http://gsas-ii.readthedocs.io/en/latest/GSASIIscripts.html#histogram-and-phase-parameters">
366documentation for Histogram/Phase parameters</A>, type must always be
367specfied even as in this case where it is not being changed from the
368existing default. Again, since these parameters are being set only for
369one histogram, either <tt>phase0.set_HAP_refinements()</tt> or
370<tt>gpx.set_refinement()</tt> must be called or to use
371<tt>gpx.do_refinements([refdict3])</tt> the "histograms" element must be
372included inside <tt>refdict3</tt>.
373
374<blockquote><textarea rows="8" cols="75" readonly>
375# tutorial step 7: add size & strain broadening (HAP) for histogram 1 only
376gpx.save('step7.gpx')
377refdict3 = {"set": {"Mustrain": {"type":"isotropic","refine":True},
378                    "Size":{"type":"isotropic","refine":True},
379                    }}
380gpx.set_refinement(refdict3,phase=phase0,histogram=[hist1])
381gpx.do_refinements([{}]) # refine after setting
382HistStats(gpx)</textarea></blockquote>
383
384</blockquote>
385<h4>9: Add Structural and Sample Displacement Parameters</h4>
386<blockquote>
387The step 8 in the original tutorial is to treat sample displacement
388for each histogram/phase. These parameters are different because of
389the differing diffractometer geometries. We also add refinement of
390sample parameters using <tt>phase0.set_refinements()</tt> to set the
391"X" (coordinate) and "U" (displacement) refinement flags for all
392atoms. This is done with this code:
393
394<blockquote><textarea rows="9" cols="75" readonly>
395# tutorial step 8: add sample parameters & set radius (Hist); refine atom parameters (phase)
396gpx.save('step8.gpx')
397hist1.set_refinements({'Sample Parameters': ['Shift']})
398hist2.set_refinements({'Sample Parameters': ['DisplaceX', 'DisplaceY']})
399hist2.data['Sample Parameters']['Gonio. radius'] = 650. # not in API
400phase0.set_refinements({"Atoms":{"all":"XU"}})
401gpx.do_refinements([{}]) # refine after setting
402HistStats(gpx)</textarea></blockquote>
403
404Note that the original tutorial
405calls for the diffractometer radius to be changed to the correct value
406so that the displacement value is in the correct units. This parameter
407cannot be set from any GSASIIscriptable routines, but following a
408similar process,
409<A href="#ChangeCycles">as before</A>, the location for this
410setting can be located in the histogram's 'Sample Parameters' section
411(as <tt>hist2.data['Sample Parameters']['Gonio. radius']</tt>).
412
413Also note that the settings provided in the
414<tt>phase0.set_refinements()</tt> and statements
415<tt>gpx.do_refinements()</tt> could have
416been combined into this single statement:
417<blockquote><pre>
418gpx.do_refinements({"set":{"Atoms":{"all":"XU"}})
419</pre></blockquote>
420
421</blockquote>
422<h4>10: Change Data Limits; Vary Gaussian Profile Terms</h4>
423<blockquote>
424The final step in the original tutorial is to trim the range of data
425used in the refinement to exclude data where no reflections occur and
426where the peaks are cut off at high angle. Also, additional parameters
427are refined here because the supplied instrumental profile parameters
428are not very accurate descriptions for the datasets that are used
429here. It is not possible to refine the Lorentzian x-ray instrumental
430broadening terms, since this broadening is treated as sample
431broadening. The Lorentzian neutron broadening is negligible.
432
433<blockquote><textarea rows="6" cols="75" readonly>
434# tutorial step 9: change data limits & inst. parm refinements (Hist)
435gpx.save('step9.gpx')
436hist1.set_refinements({'Limits': [16.,158.4]})
437hist2.set_refinements({'Limits': [19.,153.]})
438gpx.do_refinements([{"set": {'Instrument Parameters': ['U', 'V', 'W']}}])
439HistStats(gpx)</textarea></blockquote>
440
441Note that the final <tt>gpx.do_refinements()</tt> statement can be
442replaced with calls to
443<tt>hist</tt><I>X</I><tt>.set_refinements()</tt> or
444<tt>gpx.set_refinement()</tt>, such as
445<blockquote><pre>
446hist1.set_refinements({'Instrument Parameters': ['U', 'V', 'W']})
447hist2.set_refinements({'Instrument Parameters': ['U', 'V', 'W']})
448gpx.do_refinements([{}])
449</pre></blockquote>
450
451</blockquote>
452<a name="SingleStep"><h2>Single Step Approach</h2></a>
453<blockquote>
454
455As is noted in the
456<A href="http://gsas-ii.readthedocs.io/en/latest/GSASIIscripts.html" target="_blank">
457GSASIIscriptable module documentation</A>,
458the <I>project</i><tt>.do_refinements()</tt> method can be used to
459perform multiple refinement steps. To duplicate the above steps into a
460single call, a more complex set of dicts must be created, as shown
461below:
462
463<blockquote><textarea rows="39" cols="75" readonly>
464# tutorial step 4: turn on background refinement (Hist)
465refdict0 = {"set": {"Background": { "no. coeffs": 3, "refine": True }},
466            "output":'step4.gpx',
467            "call":HistStats,"callargs":[gpx]} # callargs actually unneeded
468                                               # as [gpx] is the default
469# tutorial step 5: add unit cell refinement (Phase)
470refdict1 = {"set": {"Cell": True},    # set the cell flag (for all phases)
471            "output":'step5.gpx', "call":HistStats}
472# tutorial step 6: add Dij terms (HAP) for phase 1 only
473refdict2 = {"set": {"HStrain": True},  # set HAP parameters
474            "histograms":[hist1],      # histogram 1 only
475            "phases":[phase0],         # unneeded (default is all
476                                       # phases) included as a example
477            "output":'step6.gpx', "call":HistStats}
478# tutorial step 7: add size & strain broadening (HAP) for histogram 1 only
479refdict3 = {"set": {"Mustrain": {"type":"isotropic","refine":True},
480                    "Size":{"type":"isotropic","refine":True},},
481            "histograms":[hist1],      # histogram 1 only
482            "output":'step7.gpx', "call":HistStats}
483# tutorial step 8: add sample parameters & set radius (Hist); refine
484#                  atom parameters (phase)
485refdict4a = {"set": {'Sample Parameters': ['Shift']},
486            "histograms":[hist1],      # histogram 1 only
487             "skip": True}
488refdict4b = {"set": {"Atoms":{"all":"XU"}, # not affected by histograms
489             'Sample Parameters': ['DisplaceX', 'DisplaceY']},
490            "histograms":[hist2],      # histogram 2 only
491            "output":'step8.gpx', "call":HistStats}
492# tutorial step 9: change data limits & inst. parm refinements (Hist)
493refdict5a = {"set": {'Limits': [16.,158.4]},
494            "histograms":[hist1],      # histogram 1 only
495             "skip": True,}
496refdict5b = {"set": {'Limits': [19.,153.]},
497            "histograms":[hist2],      # histogram 2 only
498             "skip": True}
499refdict5c = {"set": {'Instrument Parameters': ['U', 'V', 'W']},
500            "output":'step9.gpx', "call":HistStats}
501</textarea></blockquote>
502
503Note that above the "call" and "callargs" dict entries are
504defined to run <tt>HistStats</tt> and "output" is used to designate
505the .gpx file that will be needed. When parameters should be changed
506in specific histograms, the entries <tt>"histograms":[hist1]</tt> and
507<tt>"histograms":[hist2]</tt> are used
508(equivalent would be <tt>"histograms":[0]</tt> and
509<tt>"histograms":[1]</tt>).
510Since there is only one phase present, use of <tt>"phase":[0]</tt> is
511superfluous, but in a more complex refinement, this could be needed.
512<p>
513A list of dicts is then prepared here:
514<blockquote><textarea rows="3" cols="75" readonly>
515dictList = [refdict0,refdict1,refdict2,refdict3,
516            refdict4a,refdict4b,
517            refdict5a,refdict5b,refdict5c]
518</textarea></blockquote>
519Steps 4 through 10, above then can be performed with these few commands:
520<blockquote><textarea rows="4" cols="75" readonly>
521# Change number of cycles and radius
522gpx.data['Controls']['data']['max cyc'] = 8 # not in API
523hist2.data['Sample Parameters']['Gonio. radius'] = 650. # not in API
524gpx.do_refinements(dictList)
525</textarea></blockquote>
526Note that this version of the exercise can be
527<A href="https://subversion.xray.aps.anl.gov/trac/pyGSAS/browser/Tutorials/PythonScript/data/SingleStep.py?format=txt">
528downloaded here</A>).
529
530</blockquote>
531
532<hr>
533<address></address>
534<!-- hhmts start -->Last modified: Tue Dec 26 17:03:22 CST 2017 <!-- hhmts end -->
535</body> </html>
Note: See TracBrowser for help on using the repository browser.