+
predefined configuration file
+
Change to the Ni directory. The file named
+ni300mesh_300k_nor_1-5.chi contains powder X-ray data
+measured from nickel at the Advanced Photon Source beamline
+6ID-D. The file contains two columns for the 2Θ scattering
+angles and X-ray intensities. The second file
+kapton_bgrd_300k_nor_2-3.chi contains the background
+measurement, i.e., the intensities from an empty capillary.
+Finally, the pdfgetx3.cfg contains a complete configuration
+parameters for converting the powder pattern to a PDF. Since all
+processing parameters are already defined in the configuration file,
+the first PDF calculation is very simple and involves running the
+pdfgetx3 program
+with the powder data file as an argument:
+
$ pdfgetx3 ni300mesh_300k_nor_1-5.chi
+
+
+
For the first run there should be no output on the screen,
+however a new file, ni300mesh_300k_nor_1-5.gr should appear
+in the work directory.
+We can use the plotdata program,
+included with this software, to plot the output data:
+
$ plotdata ni300mesh_300k_nor_1-5.gr
+
+
+
This will open a graph window and start an IPython interactive session.
+To exit and close the figure, type exit() on the IPython prompt.
+Let’s run the program again, but now with a
+--verbose=info
+option, to show more details about the program actions.
+
$ pdfgetx3 --verbose=info ni300mesh_300k_nor_1-5.chi
+
+INFO:applying pdfgetx3 defaults
+INFO:set config.mode = xray
+INFO:searching for default config file /home/user/.pdfgetx3.cfg
+INFO:searching for default config file .pdfgetx3.cfg
+INFO:searching for default config file pdfgetx3.cfg
+INFO:loaded default config file pdfgetx3.cfg
+INFO:reset config.twothetazero = 0.0
+INFO:parsing config file section [DEFAULT]
+INFO:set config.dataformat = twotheta
+INFO:set config.backgroundfile = kapton_bgrd_300k_nor_2-3.chi
+INFO:set config.outputtypes = gr
+INFO:set config.wavelength = 0.142774
+INFO:set config.composition = Ni
+INFO:set config.qmaxinst = 26.5
+INFO:set config.qmax = 26.0
+INFO:set config.rmin = 0.0
+INFO:set config.rmax = 30.0
+INFO:set config.rstep = 0.01
+INFO:finished parsing config file
+INFO:processing command line options
+INFO:set config.verbose = info
+INFO:finished with command line options
+INFO:using 1 input files from the command line.
+INFO:configuring PDFGetter mode 'xray'
+INFO:calling config_xray
+INFO:started PDF processing.
+INFO:processing 'ni300mesh_300k_nor_1-5.chi'
+INFO:resolved output file '' as 'ni300mesh_300k_nor_1-5.gr'
+WARNING:ni300mesh_300k_nor_1-5.gr already exists.
+WARNING:Use "--force=yes" or "--force=once" to overwrite.
+INFO:elapsed time: 0.095
+
+
+
Here we can see what configuration files are searched, which of them
+get loaded and what are the effective values of the processing
+parameters. Unless the --verbose option is in effect, the
+program will show only messages that have either WARNING or ERROR
+importance. The warning line above indicates no output has been
+written, because that file already exists. This safety check can be
+overruled with the --force=yes option, upon
+which pdfgetx3 would overwrite any existing files.
+
PDFgetX3 output files start with a header that lists all the processing
+parameters and can be used as a valid configuration file with the
+-c option. Another option, --plot=[iq,sq,fq,gr] turns on plotting of the final PDF or of some other result. A
+side effect of the --plot option is that pdfgetx3 starts in
+an interactive mode, so the user can manipulate or save the plots. To
+put it all together, we are now going to redo the original PDF and plot
+its reduced total scattering function F(Q) and the PDF curve G(r). This
+time the chi file is not necessary, because the input file is already
+listed in the gr file that is now used as a custom configuration:
+
$ pdfgetx3 -c ni300mesh_300k_nor_1-5.gr --plot=fq,gr
+
+WARNING:ni300mesh_300k_nor_1-5.gr already exists.
+WARNING:Use "--force=yes" or "--force=once" to overwrite.
+
+Variables related to PDF processing:
+
+pdfgetter -- PDFGetter used for calculation.
+config -- configuration data used by PDFGetter.
+ See config.inputfiles for a list of inputs.
+iraw -- matrix of input raw intensities with 2 rows per file.
+iq sq fq gr -- intermediate results per each input file stored
+ as matrix rows.
+
+Functions:
+
+tuneconfig -- dynamically tune configuration variables.
+processfiles -- process specified data files.
+clearsession -- clear all elements from the inputfiles, iraw,
+ iq, sq, fq and gr variables.
+plotdata -- plot all or selected columns from a text data file.
+loaddata -- load all or selected columns from a text data file.
+findfiles -- search for files matching the specified patterns.
+
+Use "%pdfgetx3" for a fresh run without exiting IPython.
+In [1]:
+
+
+
This will open a plot figure similar to
+

+
Because of the interactive mode implied by plotting,
+the program enters an IPython session.
+The IPython environment is preloaded with several extra functions
+and variables related to the PDF processing. For example, the
+config variable stores all the configuration parameters,
+and its content can be displayed with the print()
+function as
+
In [1]: print(config)
+
+configfile = ni300mesh_300k_nor_1-5.gr
+configsection = DEFAULT
+dataformat = twotheta
+...
+qmax = 26.0
+...
+
+
+
The processfiles() function allows to redo the
+whole calculation and plotting process for additional input files or
+for new parameter values. To plot the F(Q) and G(r)
+curves calculated at Qmax = 22 Å-1, we can call
+processfiles() and pass it a keyword argument for
+the new qmax as follows:
+
In [2]: processfiles(qmax=22)
+
+# the qmax parameter was updated to a new value, thus
+In [3]: config.qmax
+Out[3]: 22
+
+
+
There should be now two lines in each plot axis corresponding to
+the results at Qmax equal 26 and 22 Å-1. To exit the program,
+type exit().
+
+
processing from scratch
+
We have already encountered the command-line option -c
+for specifying a custom configuration file. A special argument “NONE”,
+will make pdfgetx3 ignore any configuration files and start up in a
+default state. We can use this feature to process the nickel PDF as if
+we did not have any configuration file:
+
$ pdfgetx3 -c NONE ni300mesh_300k_nor_1-5.chi
+
+WARNING:Nothing to do, use "-t" or "--plot" options.
+ERROR:Configuration error: wavelength not specified.
+ERROR:See "--help" for more hints.
+
+
+
There is an error, for the wavelength is necessary to convert
+the scattering angle 2Θ to momentum transfer Q. The
+X-ray wavelength was 0.142774 Å, which can be passed with the
+-w, --wavelength option:
+
$ pdfgetx3 -c NONE ni300mesh_300k_nor_1-5.chi -w 0.142774
+
+...
+ERROR:Configuration error: Chemical composition not known.
+ERROR:See "--help" for more hints.
+
+
+
There is still an error. The PDF calculation needs an average
+X-ray scattering factor of the material, which is obtained from
+sample chemical composition. The composition can be specified
+with the --composition option. The example
+below uses a “\” character to indicate the command continues
+on the next line. Such syntax works in Unix terminals, but
+on Windows the command has to be typed all on a single line:
+
$ pdfgetx3 -c NONE ni300mesh_300k_nor_1-5.chi -w 0.142774 \
+ --composition=Ni
+
+WARNING:Nothing to do, use "-t" or "--plot" options.
+...
+
+
+
There was no error message this time, but the program complains
+about a lack of action. The pdfgetx3 program does not write any results
+unless instructed by the -t, --outputtypes option.
+The outputtypes option recognizes the following result types:
+“iq”, “sq”, “fq”, “gr”. One or more of these type strings,
+separated by a comma, can be included with the
+-t option, which will produce the corresponding
+output files. An empty string, such as -t "", or -t NONE
+may be used to clear any outputtypes defined in the configuration file,
+and avoid the unseemly file-exists warnings.
+
At this point, we will not write any output files, but will use the
+--plot option to display the calculated curves. The
+--plot accepts the same arguments as outputtypes, so to
+display the F(Q) and G(r) curves we shall run
+
$ pdfgetx3 -c NONE ni300mesh_300k_nor_1-5.chi -w 0.142774 \
+ --composition=Ni --plot=fq,gr
+
+WARNING:qmaxinst reset to last nonzero point qmaxinst=28.0865680161
+WARNING:qmax reset to the data boundary qmaxinst=28.0865680161
+
+
+
which should open the following plot window:
+

+
The graphs look terrible. The PDF is very noisy and the F(Q) curve
+shows a sudden break at about 27 Å-1. What happened? The powder
+intensities are inaccurate at a very top of the detector angular range.
+The interactive session is setup with
+iraw, iq, sq,
+fq, gr
+variables for the original raw data and intermediate results. We
+are going to plot the “iq” variable that has the input intensities
+resampled on the Q grid. The matplotlib function
+clf() clears the figure,
+the iq variable is a two-row matrix with Q and I rows, and the
+axis()
+function lets us zoom to a given range:
+
In [1]: clf()
+In [2]: plot(iq[0], iq[1])
+Out[2]: [<matplotlib.lines.Line2D at 0x3e20f50>]
+In [3]: axis([20, 29, 0, 3000])
+Out[3]: [20, 29, 0, 3000]
+
+
+
The graph shows a sudden drop in the raw intensities at 27 Å-1.
+The qmaxinst variable defines a Q cutoff for a meaningful
+instrument intensities and, to be on a safe side, we are going to set
+it to 26.5 Å-1
+
In [4]: processfiles(qmaxinst=26.5)
+WARNING:qmax reset to the data boundary qmaxinst=26.5
+
+
+
The updated curves looks reasonable without any oscillations and
+breakpoints. The tuneconfig() function provides a
+GUI-driven way for visualizing the processing parameters and their
+effect on the results. Type tuneconfig() to execute the function,
+which should open a new window with several sliders. Try to move
+different sliders and see how do the F(Q) and G(r) curves change.
+The rpoly parameter controls the degree of data-correction
+polynomial and is an approximate low-r bound of reliable G
+values. Once the parameters are tuned, they may be set to
+exact values. We will also turn on the writing of the G(r)
+curve and save it to an output file nicmd.gr:
+
In [14]: config.qmax = 26
+In [15]: config.outputtypes = 'gr'
+In [16]: config.output = 'nicmd'
+In [17]: processfiles()
+
+
+