Skip to content

Commit 40f7a73

Browse files
committed
add z-scan example placeholder
1 parent ff5a6aa commit 40f7a73

File tree

1 file changed

+87
-32
lines changed

1 file changed

+87
-32
lines changed

docs/source/examples/mu_calc_examples.rst

Lines changed: 87 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,97 @@
22

33
:tocdepth: -1
44

5-
Lab-collected PDF Correction Examples
6-
######################################
5+
X-ray Absorption Coefficient (μ) Examples
6+
#########################################
77

8-
These examples will demonstrate how to correct X-ray diffraction data
9-
to compute pair distribution functions (PDFs) from lab-collected X-ray
10-
diffraction experiments.
8+
These examples will demonstrate how to calculate the X-ray absorption
9+
coefficient, μ, using different methods provided in ``diffpy.utils``.
1110

12-
When calculating PDFs using ``diffpy.pdfgetx``,
13-
a key assumption is that the X-ray absorption is negligible.
14-
This is frequently the case for high-energy X-rays.
15-
However, this must be corrected for when using low energy
16-
X-rays, such as those from a laboratory source.
17-
To correct for X-ray absorption, the X-ray absorption coefficient, μ,
18-
must be known.
1911

20-
.. admonition:: Correction methods for X-ray absorption
12+
.. admonition:: Methods for obtaining X-ray absorption coefficient
2113

22-
Correcting your diffraction data can be done in **three
14+
Obtaining μ can be done in **two
2315
different ways** using ``diffpy.utils``.
2416

25-
1. **Using a known μ value**: If the X-ray absorption coefficient μ
26-
is already known for your sample, supply this value along with the capillary diameter
27-
to directly correct the diffraction data.
28-
2. **Using a "z-scan" measurement**: Perform a z-scan measurement
29-
on the sample to measure X-ray absorption and extract
30-
the corresponding μ value, which is then used to correct the data.
31-
3. **Using tabulated values**: Find μ using tabulated absorption coefficients based on the sample
32-
composition, density, and X-ray energy, and use this value to apply the
33-
absorption correction.
17+
1. **Using a "z-scan" measurement**: Perform a z-scan measurement
18+
on the sample and use ``diffpy.utils.tools.compute_mud`` to calculate
19+
μ.
20+
2. **Using tabulated values**: Given composition, density, and X-ray energy,
21+
use ``diffpy.utils.tools.compute_mu_using_xraydb`` to calculate μ from
22+
tabulated values.
23+
24+
Why is μ Important?
25+
-----------------------
26+
27+
The X-ray absorption coefficient, μ, quantifies how much X-ray
28+
radiation is absorbed by a material per unit length. It is a critical
29+
parameter in many scientific techniques.
30+
31+
For example, when calculating pair distribution functions (PDFs)
32+
using ``diffpy.pdfgetx``,
33+
a key assumption is that the X-ray absorption is negligible.
34+
This is frequently the case for high-energy X-rays. However,
35+
this must be corrected for when using low energy X-rays, such
36+
as those from a laboratory source. To correct for X-ray absorption,
37+
the X-ray absorption coefficient, μ, must be known.
38+
39+
.. admonition:: Correcting for X-ray Absorption with ``diffpy.labpdfproc``
40+
41+
If your objective is to correct for X-ray absorption in PDF calculations,
42+
please refer to our package ``diffpy.labpdfproc``. This package is specifically
43+
designed to correct your laboratory X-ray PDF data for absorption effects.
44+
More information can be found in the
45+
`diffpy.labpdfproc documentation <https://www.diffpy.org/diffpy.labpdfproc//>`_.
3446

35-
Using a known μ value
36-
---------------------
3747

38-
example here
48+
Calculating μ from a "z-scan" Measurement
49+
-----------------------------------------
3950

40-
Using a "z-scan" measurement
41-
----------------------------
51+
.. note::
4252

43-
Example here
53+
The data we will be using for this example can be found here,
54+
`FIXME <https://www.diffpy.org/diffpy.utils/examples/zscan_example_data.txt>`_.
4455

45-
Using tabulated values
46-
----------------------------
56+
A "z-scan" measurement is the measured transmission of your X-ray incident beam
57+
as a function of sample position. This is obtained by moving the sample
58+
along the X-ray beam (z-direction) and recording the transmitted
59+
intensity at each position. This measured data looks something like this,
60+
61+
.. image:: ../images/FIXME
62+
:alt: Example of a z-scan measurement.
63+
:align: center
64+
:width: 200px
65+
66+
Using this z-scan data, you can calculate **μ·d**, where d is the inner diameter of
67+
your sample capillary. To do this, simply pass your z-scan measurement to the ``compute_mud``
68+
function from the ``diffpy.utils.tools`` module.
69+
70+
71+
First, import the ``compute_mud`` function,
72+
73+
.. code-block:: python
74+
75+
from diffpy.utils.tools import compute_mud
76+
77+
Next, pass the filepath to the function,
78+
79+
.. code-block:: python
80+
81+
filepath = "zscan_example_data.txt"
82+
capillary_diameter = 0.5 # mm
83+
mud = compute_mud(filepath)
84+
print(f"Calculated mu*d: {round(mud, 3)}")
85+
print(f"Calculated mu: {round(mud / capillary_diameter, 3)} mm^-1")
86+
87+
This will output the calculated value of μ·d, which is unitless, and μ in mm\ :sup:`-1`.
88+
89+
.. code-block:: console
90+
91+
Calculated mu*d: FIXME
92+
Calculated mu: FIXME mm^-1
93+
94+
Calculating μ from Tabulated Values
95+
-----------------------------------
4796

4897
The function to calculate μ from tabulated values is located
4998
in the ``diffpy.utils.tools`` module. So first, import the function,
@@ -65,4 +114,10 @@ Now calculate μ using the ``compute_mu_using_xraydb`` function.
65114
.. code-block:: python
66115
67116
mu_density = compute_mu_using_xraydb(composition, energy_keV, sample_mass_density=sample_mass_density)
68-
print(f"Calculated mu from sample_mass_density: {mu_density} cm^-1")
117+
print(f"Calculated mu from sample_mass_density: {round(mu_density, 3)} mm^-1")
118+
119+
This will output the calculated X-ray absorption coefficient, μ, in mm\ :sup:`-1`.
120+
121+
.. code-block:: console
122+
123+
Calculated mu from sample_mass_density: 13.967 mm^-1

0 commit comments

Comments
 (0)