Skip to content

Commit d49e8da

Browse files
committed
deploy: 65f2cf2
1 parent e51e67b commit d49e8da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+4248
-2171
lines changed

.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: 341508aba3029fe06e4cabd6064f43b8
3+
config: 26dcc74c4dac56996964f1c2ca160797
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

_images/labpdfproc-gui.jpeg

161 KB
Loading

_modules/diffpy/labpdfproc/functions.html

Lines changed: 0 additions & 424 deletions
This file was deleted.

_modules/diffpy/labpdfproc/labpdfprocapp.html

Lines changed: 0 additions & 287 deletions
This file was deleted.

_modules/diffpy/labpdfproc/mud_calculator.html

Lines changed: 0 additions & 205 deletions
This file was deleted.

_modules/diffpy/labpdfproc/tools.html

Lines changed: 0 additions & 413 deletions
This file was deleted.

_sources/api/diffpy.labpdfproc.rst.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ diffpy.labpdfproc.tools module
3535
:undoc-members:
3636
:show-inheritance:
3737

38-
diffpy.labpdfproc.mud_calculator module
39-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40-
41-
.. automodule:: diffpy.labpdfproc.mud_calculator
42-
:members:
43-
:undoc-members:
44-
:show-inheritance:
45-
4638
diffpy.labpdfproc.labpdfprocapp module
4739
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4840

_sources/examples/examples.rst.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.. _Examples:
2+
3+
:tocdepth: -1
4+
5+
Examples
6+
########
7+
Landing page for diffpy.labpdfproc examples.
8+
9+
.. toctree::
10+
labpdfprocapp-example
11+
functions-example
12+
tools-example
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
.. _Functions Example:
2+
3+
:tocdepth: -1
4+
5+
Functions Example
6+
#################
7+
8+
This example will demonstrate how to use ``diffpy.labpdfproc.functions`` module independently
9+
to apply absorption correction to your 1D diffraction data.
10+
11+
1. First, you will need to prepare and load your input diffraction data.
12+
For example, if you want to load data from ``zro2_mo.xy`` in the ``example-data`` directory, you can write:
13+
14+
.. code-block:: python
15+
16+
from diffpy.utils.parsers import load_data
17+
from diffpy.utils.diffraction_objects import DiffractionObject
18+
19+
filepath = "../example-data/zro2_mo.xy"
20+
xarray, yarray = load_data(filepath, unpack=True)
21+
input_pattern = DiffractionObject(
22+
xarray=xarray,
23+
yarray=yarray,
24+
xtype="tth",
25+
wavelength=0.7,
26+
scat_quantity="x-ray",
27+
name="input diffraction data",
28+
metadata={"beamline": "28ID-2"},
29+
)
30+
31+
For the full tutorial on working with diffraction objects,
32+
please refer to https://www.diffpy.org/diffpy.utils/examples/diffraction_objects_example.html.
33+
34+
2. Assume you have created your ``input_pattern`` and specified mu*D value as ``muD`` (e.g., ``muD=2``).
35+
You can now compute the absorption correction (cve) for the given mu*D using the ``compute_cve`` function,
36+
apply it to your input pattern, and save the corrected file.
37+
38+
.. code-block:: python
39+
40+
from diffpy.labpdfproc.functions import apply_corr, compute_cve
41+
absorption_correction = compute_cve(input_pattern, muD) # compute cve, default method is "polynomial_interpolation"
42+
corrected_pattern = apply_corr(input_pattern, absorption_correction) # apply cve correction
43+
corrected_data.dump("corrected pattern.chi", xtype="tth") # save the corrected pattern
44+
45+
If you want to use brute-force computation instead, you can replace the first line with:
46+
47+
.. code-block:: python
48+
49+
absorption_correction = compute_cve(input_pattern, muD, method="brute_force")
50+
51+
3. Now, you can visualize the effect of the absorption correction
52+
by plotting the original and corrected diffraction patterns.
53+
54+
.. code-block:: python
55+
56+
import matplotlib.pyplot as plt
57+
plt.plot(input_pattern.xarray, input_pattern.yarray, label="Original Intensity")
58+
plt.plot(corrected_pattern.xarray, corrected_pattern.yarray, label="Corrected Intensity")
59+
plt.xlabel("tth (degree)")
60+
plt.ylabel("Intensity")
61+
plt.legend()
62+
plt.title("Original vs. Corrected Intensity")
63+
plt.show()
64+
65+
4. You can modify the global parameters
66+
``N_POINTS_ON_DIAMETER`` (the number of points on each diameter to sample the circle)
67+
and ``TTH_GRID`` (the range of angles) when using the brute-force method.
68+
69+
To speed up computation, you can reduce the range of ``TTH_GRID``. You can also increase ``N_POINTS_ON_DIAMETER``
70+
for better accuracy, but keep in mind that this will increase computation time.
71+
For optimal results, we recommend setting it to an even number.
72+
73+
Currently, the interpolation coefficients were computed using ``N_POINTS_ON_DIAMETER=2000``,
74+
which ensures good accuracy within the muD range of 0.5 to 7.
75+
This resolution also provides flexibility for extending the interpolation range in the future.
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
.. _labpdfprocapp Example:
2+
3+
:tocdepth: -1
4+
5+
labpdfprocapp Example
6+
#####################
7+
8+
This example provides a quick-start tutorial for using ``diffpy.labpdfproc``
9+
to apply absorption correction to your 1D diffraction data using the command-line (CLI).
10+
Check ``labpdfproc --help`` for more information.
11+
A graphical user interface (GUI) is also available and is designed to be intuitive and easy to use.
12+
13+
There are three ways to correct dirraction data within ``diffpy.labpdfproc``, these are,
14+
15+
1. ``labpdfproc mud``: Provide the diffraction data file(s) and muD value directly.
16+
2. ``labpdfproc zscan``: Provide the diffraction data file(s) and a z-scan file, which will be used to calculate the muD value.
17+
3. ``labpdfproc sample``: Provide the diffraction data file(s) and information about the sample to calculate the theoretical muD value.
18+
19+
We will go through all three methods in this tutorial.
20+
21+
.. admonition:: Example Data
22+
23+
Example data for these examples can be found at: https://github.com/diffpy/diffpy.labpdfproc/tree/main/docs/source/examples/example-data
24+
25+
26+
Launching the Graphical User Interface (GUI)
27+
--------------------------------------------
28+
29+
To launch the GUI, run one of the following commands in your terminal,
30+
31+
.. code-block:: bash
32+
33+
labpdfproc
34+
labpdfproc --gui
35+
36+
.. note:: Note that the GUI is currently not supported on Python>=3.12.
37+
38+
This will open the GUI, which should look something like,
39+
40+
.. image:: ../img/labpdfproc-gui.jpeg
41+
:align: center
42+
43+
Below we will go through all the commands using the CLI, but the same principles apply to the GUI.
44+
45+
.. note:: The first time you run any of the below commands,
46+
you will be prompted to enter your name, email, and ORCID. This will be
47+
appended to metadata in the output file header for reproducibility and tracking purposes.
48+
49+
50+
``labpdfproc mud`` Command
51+
---------------------------
52+
53+
If you know the muD value for your sample, you can use the ``labpdfproc mud``
54+
command to apply absorption correction directly.
55+
56+
To see all the options for this command, type,
57+
58+
.. code-block:: bash
59+
60+
labpdfproc mud -h
61+
62+
To run the correction, specify the path to your diffraction data file(s) and the muD value,
63+
64+
.. code-block:: bash
65+
66+
labpdfproc mud <diffraction-data-file.xy> <mud>
67+
labpdfproc mud zro2_mo.xy 2.5
68+
69+
If the flag ``--wavelength`` is not specified, the program will attempt to fetch
70+
the wavelength from a configuration file.
71+
If the wavelength is not found in the configuration file, a ``ValueError``
72+
will be raised, prompting you to provide the wavelength either through the CLI or the configuration file.
73+
74+
To provide the wavelength through the CLI, you can use the ``-w`` or ``--wavelength`` flag followed by the wavelength value in angstroms or the X-ray source.
75+
For example,
76+
77+
.. code-block:: bash
78+
79+
labpdfproc mud zro2_mo.xy 2.5 -w 0.71303
80+
labpdfproc mud zro2_mo.xy 2.5 -w Mo
81+
82+
This will then save the corrected file in the same directory as the input file with the name ``zro2_mo_corrected.chi``.
83+
84+
To save the correction file, specify the ``-c`` or ``--output-correction`` flag,
85+
86+
.. code-block:: bash
87+
88+
labpdfproc mud zro2_mo.xy 2.5 -w 0.71303 -c
89+
90+
This will then save the correction file in the same directory as the input file with the name ``zro2_mo_cve.chi``.
91+
92+
``labpdfproc zscan`` Command
93+
----------------------------
94+
95+
The ``labpdfproc zscan`` command allows you to calculate the muD value from a z-scan file and apply absorption correction to your diffraction data.
96+
For more information on what a z-scan is, please see the "Examples --> Linear Absorption Coefficient Examples"
97+
section in the ``diffpy.utils`` documentation: https://www.diffpy.org/diffpy.utils/examples/mu_calc_examples.html.
98+
99+
To see the options for this command, type,
100+
101+
.. code-block:: bash
102+
103+
labpdfproc zscan -h
104+
105+
To run this command, provide the path to your diffraction data file(s) and the z-scan file,
106+
107+
.. code-block:: bash
108+
109+
labpdfproc zscan <diffraction-data-file.xy> <zscan-file.xy>
110+
labpdfproc zscan CeO2_635um_accum_0.xy CeO2_635um_zscan.xy
111+
112+
Like the ``labpdfproc mud`` command, you can also specify the
113+
wavelength or source type using the ``-w`` flag if it's not found in the configuration file,
114+
115+
.. code-block:: bash
116+
117+
labpdfproc zscan CeO2_635um_accum_0.xy CeO2_635um_zscan.xy -w 0.71303
118+
labpdfproc zscan CeO2_635um_accum_0.xy CeO2_635um_zscan.xy -w Mo
119+
120+
This will save the corrected file in the same directory as the input file with the name ``CeO2_635um_accum_0.chi``.
121+
122+
To save the correction file, specify the ``-c`` or ``--output-correction`` flag,
123+
124+
.. code-block:: bash
125+
126+
labpdfproc zscan CeO2_635um_accum_0.xy CeO2_635um_zscan.xy -w 0.71303 -c
127+
128+
This will then save the correction file in the same directory as the input file with the name ``CeO2_635um_accum_0_cve.chi``.
129+
130+
``labpdfproc sample`` Command
131+
-----------------------------
132+
133+
The ``labpdfproc sample`` command allows you to calculate the muD value from information
134+
about your sample and apply absorption correction to your diffraction data.
135+
136+
To see the options for this command, type,
137+
138+
.. code-block:: bash
139+
140+
labpdfproc sample -h
141+
142+
To run this command, provide the path to your diffraction data file(s) along with:
143+
144+
1) ``sample_composition``: The chemical formula of your sample.
145+
2) ``sample_mass_density``: The mass density of your sample in g/cm^3. If you don't know the mass density, a good approximation is typically ~1/3 of the theoretical packing fraction.
146+
3) ``diameter``: The outer diameter of your capillary.
147+
148+
.. code-block:: bash
149+
150+
labpdfproc sample <diffraction-data-file.xy> <sample_composition> <sample_mass_density> <diameter>
151+
labpdfproc sample zro2_mo.xy ZrO2 17.45 1.2
152+
153+
Once again, you can specify the wavelength or source type using the ``-w`` flag if it's not found in the configuration file,
154+
155+
.. code-block:: bash
156+
157+
labpdfproc sample zro2_mo.xy ZrO2 17.45 1.2 -w 0.71303
158+
labpdfproc sample zro2_mo.xy ZrO2 17.45 1.2 -w Mo
159+
160+
This will save the corrected file in the same directory as the input file with the name ``zro2_mo.chi``.
161+
162+
To save the correction file, specify the ``-c`` or ``--output-correction`` flag,
163+
164+
.. code-block:: bash
165+
166+
labpdfproc sample zro2_mo.xy ZrO2 17.45 1.2 -w 0.71303 -c
167+
168+
This will then save the correction file in the same directory as the input file with the name ``zro2_mo_cve.chi``.
169+
170+
Additional CLI options
171+
----------------------
172+
173+
Below is a summary of all the additional flags that can be used with all three commands,
174+
175+
- ``-h, --help``
176+
Show this help message and exit.
177+
178+
- ``-w, --wavelength WAVELENGTH``
179+
X-ray wavelength in angstroms (numeric) or X-ray source name.
180+
Allowed: ``Ag``, ``AgKa1``, ``AgKa1Ka2``, ``Cu``, ``CuKa1``, ``CuKa1Ka2``, ``Mo``, ``MoKa1``, ``MoKa1Ka2``.
181+
Will be loaded from config files if not specified.
182+
183+
- ``-x, --xtype XTYPE``
184+
X-axis type (default: ``tth``). Allowed values: ``angle``, ``tth``, ``twotheta``, ``2theta``, ``d``, ``dspace``, ``q``.
185+
186+
- ``-m, --method {brute_force, polynomial_interpolation}``
187+
Method for cylindrical volume element (CVE) calculation (default: ``polynomial_interpolation``).
188+
Allowed methods: ``brute_force``, ``polynomial_interpolation``.
189+
190+
- ``-o, --output-directory OUTPUT_DIRECTORY``
191+
Directory to save corrected files (created if needed). Defaults to current directory.
192+
193+
- ``-f, --force``
194+
Overwrite existing files.
195+
196+
- ``-c, --output-correction``
197+
Also output the absorption correction to a separate file.
198+
199+
- ``-u, --user-metadata KEY=VALUE [KEY=VALUE ...]``
200+
Specify key-value pairs to be loaded into metadata. Format: ``key=value``.
201+
- Separate multiple pairs with whitespace.
202+
- No spaces before or after ``=``.
203+
- Avoid using ``=`` in keys. Only the first ``=`` separates key and value.
204+
- If a key or value contains whitespace, enclose it in quotes.
205+
Examples:
206+
``facility='NSLS II', beamline=28ID-2, 'favorite color'=blue``.
207+
208+
- ``--username USERNAME``
209+
Your name (optional, for dataset credit). Will be loaded from config files if not specified.
210+
211+
- ``--email EMAIL``
212+
Your email (optional, for dataset credit). Will be loaded from config files if not specified.
213+
214+
- ``--orcid ORCID``
215+
Your ORCID ID (optional, for dataset credit). Will be loaded from config files if not specified.

0 commit comments

Comments
 (0)