Skip to content

Commit 1ea2fba

Browse files
committed
Intro and Quickstart
1 parent 3cf51ec commit 1ea2fba

File tree

5 files changed

+272
-22
lines changed

5 files changed

+272
-22
lines changed
46.8 KB
Loading
118 KB
Loading
106 KB
Loading
103 KB
Loading

doc/manual/pdfmorph.texinfo

Lines changed: 272 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
@end html
2323
@end macro
2424

25-
@macro ScreenShot{f}
26-
@center @image{\f\, 5in}
25+
@macro ScreenShot{f,ext}
26+
@center @image{\f\, 5.5in,,\ext\}
2727
@end macro
2828

2929
@macro ReleaseDate{}
@@ -104,12 +104,37 @@ Copyright 2009-2024, Board of Trustees of Columbia University in the city of New
104104
@chapter Introduction
105105
@cindex introduction
106106

107-
PDFmorph is a Python package that increases the insight researchers can
108-
obtain from measured atomic pair distribution functions (PDFs) in a
107+
@code{PDFmorph} is a Python package that increases the insight researchers can
108+
obtain by comparing measured atomic pair distribution functions (PDFs) in a
109109
model-independent way. It was originally designed to help a researcher
110110
answer a question: "Has my material undergone a phase transition between
111111
these two measurements?"
112112

113+
A common approach to compare two PDFs is to plot the difference curve below
114+
the two PDFs. However, a significant signal can be seen in the difference curve
115+
due to benign effects such as thermal expansion (peak shifts), increased thermal
116+
motion (peak broadening), or a change in scale due to differences in the incident
117+
flux when computing the PDFs for example. Other commonly-used dissimilarity metrics
118+
such as the weighted Rietveld reliability factor @math{R_W} are also inflated by
119+
these effects. @code{PDFmorph} does its best to correct for these benign effects
120+
prior to computing the @math{R_W} and plotting the difference curve.
121+
122+
To use @code{PDFmorph}, supply one PDF as the "target" (suggested to the one collected
123+
under higher temperature) and a second PDF to be morphed. The user can choose from
124+
a list of morphs to apply, which includes "stretching" (scaling the @math{r}-axis,
125+
the abscissa, to simulate isotropic expansion/compression), "smearing" (peak broadening
126+
by convlution with a Gaussian), and "scaling" (scaling the ordinate axis). By default,
127+
@code{PDFmorph} will refine the intensity of the morphs to best match the morphed to
128+
the target PDF.
129+
130+
@code{PDFmorph} includes other morphs including those that factor in nanoparticle
131+
shape effects. For a full list of available morphs, see @ref{Available morphs}.
132+
For a quick tutorial on using @code{PDFmorph}, see @ref{Quick start tutorial}.
133+
For a full list of command-line options, see @ref{PDFmorph options}.
134+
135+
Finally, we note that though @code{PDFmorph} could be used on other spectra,
136+
it has not been extensively tested beyond the PDF.
137+
113138
@page
114139
@vskip 0pt plus 1filll
115140
@node Installation, Tutorials, Introduction, Top
@@ -126,64 +151,72 @@ these two measurements?"
126151
@section Availability
127152
@cindex availability
128153

129-
PDFmorph is open source and distributed under the BSD license.
154+
@code{PDFmorph} is open source and distributed under the BSD license.
130155
It runs on Windows, Mac OS, Linux, and all major Unix systems.
131156
The source code is freely available at @url{https://github.com/diffpy/diffpy.pdfmorph}.
132157

158+
If you come accross any bugs in the application, please open an
159+
@url{https://github.com/diffpy/diffpy.pdfmorph/issues, issue} or email
160+
diffpy-dev@@googlegroups.com.
161+
133162
@node Requirements, Installation instructions, Availability, Installation
134163
@section Requirements
135164
@cindex requirements
136165

137-
PDFmorph is currently run from the command line, so it is recommended that users
166+
@code{PDFmorph} is currently run from the command line, so it is recommended that users
138167
first familiarize themselves with their operating system's command line interface.
139168

140-
PDFmorph currently requires Python 3.10 or higher to run. It also makes use of
169+
@code{PDFmorph} currently requires Python 3.10 or higher to run. It also makes use of
141170
the following third party libraries:
142171
@itemize @bullet
143172
@item @url{https://numpy.org/, NumPy} - Python's fast scientific computing library
144173
@item @url{https://matplotlib.org/, Matplotlib} - Python plotting library
145174
@item @url{https://scipy.org/, SciPy} - Python's technical computing library
146-
@item @url{https://www.diffpy.org/diffpy.utils/, diffpy.utils}
175+
@item @url{https://www.diffpy.org/diffpy.utils/, diffpy.utils}
147176
- @url{https://www.diffpy.org/, DiffPy} general utility functions
148177
@end itemize
149178
These dependencies will be installed automatically if you use the conda installation
150179
procedure described in the following section (@ref{Installation instructions}).
151180

152181
@node Installation instructions, , Requirements, Installation
153182
@section Installation instructions
154-
@cindex installationinstrunctions
183+
@cindex installation instrunctions
155184

156185
We recommend installing the package and its dependencies using conda.
157186
Miniconda, a minimal installer for conda, can be downloaded
158-
@url{https://docs.anaconda.com/free/miniconda/, here}.
187+
@url{https://docs.anaconda.com/free/miniconda/, here}.
159188
Once Miniconda is installed, run @code{conda} on the command line
160189
to test that it has been installed properly.
161190

162-
To create and activate a conda environment to use PDFmorph, run the following command.
191+
To create and activate a conda environment to use @code{PDFmorph}, run the following command.
163192
@example
164193
conda create -n pdfmorph_env python=3 --yes
165194
conda activate pdfmorph_env
166195
@end example
167196

168197
A conda environment must be active to use the packages within.
169198
In future sessions, make sure to run @code{conda activate pdfmorph_env} to activate the
170-
environment before interacting with the PDFmorph program.
199+
environment before interacting with the @code{PDFmorph} program.
171200

172-
Once active, you can install PDFmorph into your environment from the
201+
Once active, you can install @code{PDFmorph} into your environment from the
173202
@url{https://conda-forge.org/, conda-forge} channel of Anaconda packages by running
174203
@example
175204
conda config --add channels conda-forge
176205
conda install diffpy.pdfmorph
177206
@end example
178207
This installation only needs to be done once. The next time you activate the environment,
179-
these packages will already be installed.
208+
these packages will already be installed. To see a list of all installed packages within
209+
an environment, run
210+
@example
211+
conda list
212+
@end example
180213

181214
When you are finished with the session, exit the environment by running
182215
@example
183216
conda deactivate pdfmorph_env
184217
@end example
185218

186-
If you do not wish to use conda to install, PDFmorph is also available on the
219+
If you do not wish to use conda to install, @code{PDFmorph} is also available on the
187220
@url{https://pypi.org/, Python Package Index} or can be installed from source
188221
at @url{https://github.com/diffpy/diffpy.pdfmorph}. Note that these installation
189222
methods will require you to first install the dependencies listed in the previous section
@@ -200,33 +233,250 @@ methods will require you to first install the dependencies listed in the previou
200233
* Extra tutorials::
201234
@end menu
202235

203-
This section includes a quick tutorial to acquaint users with PDFmorph.
204-
Also included are a few extra tutorials covering some more specific PDFmorph functionalities.
236+
This section includes a quick start tutorial to acquaint users with the core
237+
features of @code{PDFmorph}. Also included are a few extra tutorials
238+
covering some more specific @code{PDFmorph} functionalities.
205239

206240
Before you start this tutorial, make sure you have installed all necessary software
207-
and dependencies (@ref{Installation instructions}).
241+
and dependencies (@ref{Installation instructions}). If you are looking for a full
242+
summary of @code{PDFmorph} command-line options, see @ref{PDFmorph options} or
243+
run @code{pdfmorph --help} in a @code{PDFmorph}-equipped @code{conda} environment.
208244

209245
@node Quick start tutorial, Extra tutorials, Tutorials, Tutorials
210246
@section Quick start tutorial
211-
@cindex quickstarttutorial
247+
@cindex quick start tutorial
248+
249+
In this tutorial, we will demonstrate how to use @code{PDFmorph} to compare two PDFs
250+
measured from the same material at different temperatures. The morphs showcased include
251+
"stretch", "scale", and "smear". Throughout this tutorial, entries surrounded by angle
252+
brackets @code{<>} represent placeholder names. The user is free to use their own names
253+
in stead of those provided.
254+
255+
@enumerate
256+
@item Open your terminal (Linux and MacOS) or Command Prompt (Windows).
257+
@item If not already active, activate your @code{conda} environment with @code{PDFmorph} installed using
258+
@example
259+
conda activate <PDFmorph_env>
260+
@end example
261+
@itemize
262+
@item See @ref{Installation} for how to set up a @code{conda} environment with @code{PDFmorph} installed.
263+
@item If you need to list your available @code{conda} environments, run
264+
@example
265+
conda env list
266+
@end example
267+
@end itemize
268+
@item Create a directory to store the tutorial PDF files using
269+
@example
270+
mkdir <PDFmorph_tutorial_directory>
271+
@end example
272+
and enter the directory with the @code{cd} command
273+
@example
274+
cd <PDFmorph_tutorial_directory>
275+
@end example
276+
@item Download the tutorial files @code{tutorialData.zip} folder (***INSERT LINK***)
277+
into your current directory and extract the files. After this is done,
278+
type @code{ls} in the command line to list your current directory contents
279+
and make sure there is a directory named @code{tutorialData}.
280+
@itemize
281+
@item The files in this dataset were collected by Soham Banerjee at Brookhaven National Laboratory in Upton,
282+
New York. Note that these files have a @code{.gr} extension, indicating that they are measured PDFs.
283+
The @code{.cgr} file extension indicates a calculated PDF such as those generated by the
284+
@url{https://www.diffpy.org/products/pdfgui.html, PDFgui} program.
285+
@item Each file is PDF data collected on Iridium Telluride with 20% Rhodium Doping @math{IrRhTe_2} at different
286+
temperatures with the first file (01) collected at @math{10K} and the last (44) at @math{300K}.
287+
The samples increase in temperature as their numbers increase. The "C" in their names indicates that they
288+
have undergone cooling.
289+
@end itemize
290+
@item Enter the @code{tutorialData} directory using the @code{cd} command and
291+
find the data labeled @code{darkSub_rh20_C_##.gr} within this directory.
292+
@float Figure,fig3.1-1
293+
@ScreenShot{images/qs_tutorial_download,png}
294+
@caption{Entering the @code{tutorialData} directory and searching
295+
for the PDF data (Linux Terminal Output).}
296+
@end float
297+
@item Let us try try using the @code{PDFmorph} program to plot two PDFs against each other.
298+
Type the following command into the command line
299+
@example
300+
pdfmorph darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr
301+
@end example
302+
Underneath the two PDFs, we can see a substantial difference curve and large @math{R_W} value of @math{0.407}
303+
@float Figure,fig3.1-2
304+
@ScreenShot{images/qs_tutorial_unmorphed,png}
305+
@caption{Using @code{PDFmorph} to compare two PDFs without morphing.}
306+
@end float
307+
@item Now, we will start the morphing process.
308+
@itemize
309+
@item Note that the morphs will apply only to the first PDF provided (which will be
310+
@code{darkSub_rh20_C_01.gr} in our case). We will henceforth refer to the first PDF as the "morphed"
311+
and the second (unmorphed) PDF as the "target". Our goal will be to apply morphs to see if we can reduce the
312+
difference between the morphed and target PDFs.
313+
@item In this tutorial, we will apply the scale factor, Gaussian smear, and stretch morphs.
314+
To learn more about why we wish to apply these three morphs in particular,
315+
see @ref{Temperature-related morphs}.
316+
@end itemize
317+
@item We will begin by applying a scaling factor of @math{2} by typing the command
318+
@example
319+
pdfmorph darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr --scale=2 -a
320+
@end example
321+
Now, the difference is much larger @math{R_W=1.457}. We should modify our initial value
322+
for the scaling factor until we see a reduction in @math{R_W}. We can try @math{0.9}
323+
@example
324+
pdfmorph darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr --scale=0.9 -a
325+
@end example
326+
and see that the difference has dropped to @math{R_W=0.351}, lower than when comparing the unmorphed PDF.
327+
For @code{PDFmorph} to optimize the scale factor, drop the @code{-a} option
328+
@example
329+
pdfmorph darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr --scale=0.9
330+
@end example
331+
Given a reasonable initial guess, @code{PDFmorph} will find the optimal value for each morph.
332+
In this example, @code{PDFmorph} should display @code{scale=0.799025} meaning it has found this
333+
to be the optimal value for the scale factor. The difference @math{R_W=0.330} has further decreased.
334+
@itemize
335+
@item The @code{-a} option prevents @code{PDFmorph} from refining the morph.
336+
It is the choice of the user whether or not to run values before removing @code{-a} when analyzing data with
337+
@code{PDFmorph}. By including it, you can attempt to manually move towards convergence before allowing the
338+
program to optimize by removing it; when including it, you may reach a highly optimized value on the first
339+
guess or diverge greatly.
340+
@end itemize
341+
@float Figure,fig3.1-3
342+
@ScreenShot{images/qs_tutorial_scaled,png}
343+
@caption{@code{PDFmorph} has found an optimal value (minimizes @math{R_W}) for the scale factor.}
344+
@end float
345+
@item Now we will add on a Gaussian smear morph with an initial smear factor of @math{0.5}. The absolute value
346+
of the smear factor is the standard deviation of the Gaussian that is convoluted with the morphed PDF.
347+
@example
348+
pdfmorph darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr --scale=0.8 \
349+
--smear=0.5 -a
350+
@end example
351+
@itemize
352+
@item The @code{\} in the above command is only used to break our long command into multiple lines for readability
353+
on this document. In your Terminal/Command Prompt, you can write the entire command in a single line.
354+
@end itemize
355+
We have tailored our initial scale factor to be close to the optimal value given by @code{PDFmorph},
356+
but we should see that the @math{R_W=0.897} has increased substantially due to the smear factor. Remove the
357+
@math{-a} from above and run it again to refine the smear factor.
358+
@itemize
359+
@item Note that the warnings that the Terminal/Command Prompt displays are largely numerical in nature and
360+
do not indicate a physically irrelevant guess. These are somewhat superficial and in most cases can be ignored.
361+
@end itemize
362+
After refining, we should see that @math{R_W} has dropped back to @math{0.330}, and the optimized smear factor is
363+
quite small (@code{smear = 0.002940}) indicating that the smear has hardly had an effect on our PDF.
364+
To see an effect, restrict the @code{rmin} and @code{rmax} values by typing
365+
@example
366+
pdfmorph darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr --scale=0.8 \
367+
--smear=0.5 --rmin=1.5 --rmax=30
368+
@end example
369+
The optimized smear factor is now a non-insignificant @code{smear=-0.084138} and @math{R_W=0.204}.
370+
@itemize
371+
@item We restricted the @code{r} (abscissa) values because some of the Gaussian smear effects are only
372+
visible in a fixed @code{r} range. We chose this @code{r} range by noting where most of our relevant
373+
data was that was not exponentially decayed by instrumental shortcomings.
374+
@item Also note that a negative smear factor is equivalent to its absolute value. You can see that
375+
@example
376+
pdfmorph darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr --scale=0.8 \
377+
--smear=-0.84138 --rmin=1.5 --rmax=30 -a
378+
@end example
379+
and
380+
@example
381+
pdfmorph darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr --scale=0.8 \
382+
--smear=+0.84138 --rmin=1.5 --rmax=30 -a
383+
@end example
384+
give the exact same results.
385+
@end itemize
386+
@item Finally, we will examine the stretch morph. The @code{r} axis will be stretched by
387+
@math{1+s} where @math{s} is the stretch factor.
388+
@example
389+
pdfmorph darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr --scale=0.8 \
390+
--smear=-0.84 --stretch=0.5 --rmin=1.5 --rmax=30 -a
391+
@end example
392+
Again, the @math{R_W} has increased. Before letting @code{PDFmorph} refine automatically,
393+
try seeing which direction (higher or lower) the initial stretch factor should go to decrease
394+
@math{R_W}. If you cannot, type
395+
@example
396+
pdfmorph darkSub_rh20_C_01.gr darkSub_rh20_C_44.gr --scale=0.8 \
397+
--smear=-0.84 --stretch=0.005 --rmin=1.5 --rmax=30 -a
398+
@end example
399+
to observe a decreased difference and remove the @code{-a} to get the optimized
400+
stretch factor of @code{stretch=0.001762} and smaller @math{R_W=0.117}.
401+
We have reached the optimal fit for our PDF!
402+
@float Figure,fig3.1-4
403+
@ScreenShot{images/qs_tutorial_morphed,png}
404+
@caption{The optimal fit after applying the scale, smear, and stretch morphs.}
405+
@end float
406+
@item Now, try it on your own!
407+
If you have personally collected or otherwise readily available PDF data,
408+
try this process to see if you can morph your PDFs to one another.
409+
Note that many of the parameters provided in this tutorial are unique to it,
410+
so be cautious about your choices and made sure that they remain physically relevant.
411+
@end enumerate
212412

213413
@node Extra tutorials, , Quick start tutorial, Tutorials
214414
@section Extra tutorials
215-
@cindex extratutorials
415+
@cindex extra tutorials
416+
PDFmorph has some more functionalities not showcased in the basic workflow above
417+
(run @code{pdfmorph –-help} for an overview of all @code{PDFmorph} functionalities).
418+
Tutorials for some of these are included below.
419+
Additional files are used for these tutorials. Please download and extract
420+
@code{additionalData.zip} (***INSERT LINK***) before proceeding.
421+
422+
@menu
423+
* Performing multiple morphs
424+
* Nanoparticle shape effect
425+
@end menu
426+
427+
It may be useful to morph a PDF against multiple targets: for example, you may want
428+
to morph a PDF against a sequence of PDFs measured at various temepratures to determine
429+
whether a phase change has occured. PDFmorph currently allows users to morph a PDF
430+
against all files in a selected directory and plot resulting @math{R_W} values from each morph.
431+
It is advised that the lowest temperature PDF be that morphed and the higher temperature PDFs
432+
act as targets as the smear morph is only able to account for increases in thermal motion.
433+
434+
@enumerate
435+
@item Within @code{additionalData}, enter (using @code{cd}) the @code{morphsequence} directory.
436+
Inside, you will find multiple PDFs of @math{SrFe_2As_2} measured at various temperatures.
437+
@itemize
438+
@item These PDFs come from @url{https://github.com/Billingegroup/pdfttp_data/,
439+
@emph{Atomic Pair Distribution Function Analysis: A Primer}} by Simon Billinge and
440+
Kirsten Jensen.
441+
@end itemize
442+
@item It is generally advisable for the
443+
@end enumerate
444+
445+
@node Performing multiple morphs, Nanoparticle shape effect, Extra tutorials, Extra tutorials
446+
@subsection Performing multiple morphs
447+
@cindex performing multiple morphs
448+
449+
450+
@node Nanoparticle shape effect, , Performing multiple morphs, Extra tutorials
451+
@subsection Nanoparticle shape effect
452+
@cindex nanoparticle shape effect
216453

217454
@page
218455
@vskip 0pt plus 1filll
219456
@node Available morphs, PDFmorph options, Quick start tutorial, Top
220457
@chapter Available morphs
221-
@cindex availablemorphs
458+
@cindex available morphs
459+
460+
@menu
461+
* Temperature-related morphs::
462+
* Shape-related morphs::
463+
@end menu
222464

223465
In this section, we detail a few use-cases for morphs.
224466

467+
@node Temperature-related morphs, Shape-related morphs, Available morphs, Available morphs
468+
@section Temperature-related morphs
469+
@cindex temperature-related morphs
470+
471+
@node Shape-related morphs, , Temperature-related morphs, Available morphs
472+
@section Shape-related morphs
473+
@cindex shape-related morphs
474+
225475
@page
226476
@vskip 0pt plus 1filll
227477
@node PDFmorph options, Index, Available morphs, Top
228478
@chapter PDFmorph options
229-
@cindex pdfmorphoptions
479+
@cindex pdfmorph options
230480

231481
Explaination of options
232482

0 commit comments

Comments
 (0)