Skip to content

Commit 67e3db5

Browse files
committed
Merge branch 'main' into v3.7.0
# Conflicts: # src/diffpy/utils/_deprecator.py
2 parents d6992e6 + bfaea66 commit 67e3db5

File tree

8 files changed

+6006
-24
lines changed

8 files changed

+6006
-24
lines changed

docs/source/examples/example_data/CeO2_635um_accum_0.xy

Lines changed: 5631 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
'Id: "" Comment: "" Operator: "Lab Manager" Anode: "Mo" Scantype: "Z" TimePerStep: "0.1"
2+
-0.5000 438699.993
3+
-0.4900 437939.993
4+
-0.4800 436679.993
5+
-0.4700 434109.994
6+
-0.4600 439659.993
7+
-0.4500 436119.994
8+
-0.4400 435829.994
9+
-0.4300 438749.993
10+
-0.4200 432339.994
11+
-0.4100 431319.994
12+
-0.4000 435779.994
13+
-0.3900 437599.993
14+
-0.3800 434739.994
15+
-0.3700 433929.994
16+
-0.3600 436689.993
17+
-0.3500 433569.994
18+
-0.3400 435229.994
19+
-0.3300 437549.993
20+
-0.3200 434419.994
21+
-0.3100 435259.994
22+
-0.3000 437439.993
23+
-0.2900 437869.993
24+
-0.2800 434529.994
25+
-0.2700 436509.993
26+
-0.2600 434709.994
27+
-0.2500 432969.994
28+
-0.2400 434899.994
29+
-0.2300 432389.994
30+
-0.2200 436019.994
31+
-0.2100 437949.993
32+
-0.2000 437949.993
33+
-0.1900 435849.994
34+
-0.1800 437349.993
35+
-0.1700 435199.994
36+
-0.1600 439539.993
37+
-0.1500 434519.994
38+
-0.1400 436629.993
39+
-0.1300 435779.994
40+
-0.1200 437839.993
41+
-0.1100 433019.994
42+
-0.1000 440589.993
43+
-0.0900 440729.993
44+
-0.0800 432909.994
45+
-0.0700 435749.994
46+
-0.0600 439069.993
47+
-0.0500 437979.993
48+
-0.0400 437069.993
49+
-0.0300 436549.993
50+
-0.0200 430119.994
51+
-0.0100 426019.994
52+
0.0000 418459.994
53+
0.0100 403369.994
54+
0.0200 383859.994
55+
0.0300 365809.995
56+
0.0400 344199.995
57+
0.0500 320469.995
58+
0.0600 294339.996
59+
0.0700 266309.996
60+
0.0800 239429.996
61+
0.0900 209889.997
62+
0.1000 176649.997
63+
0.1100 144879.998
64+
0.1200 115089.998
65+
0.1300 92299.999
66+
0.1400 72569.999
67+
0.1500 58649.999
68+
0.1600 46629.999
69+
0.1700 38329.999
70+
0.1800 33500.000
71+
0.1900 29950.000
72+
0.2000 26210.000
73+
0.2100 24490.000
74+
0.2200 22100.000
75+
0.2300 21030.000
76+
0.2400 20140.000
77+
0.2500 18260.000
78+
0.2600 17220.000
79+
0.2700 17280.000
80+
0.2800 16080.000
81+
0.2900 16040.000
82+
0.3000 15250.000
83+
0.3100 15030.000
84+
0.3200 14610.000
85+
0.3300 13840.000
86+
0.3400 14300.000
87+
0.3500 14400.000
88+
0.3600 14140.000
89+
0.3700 13810.000
90+
0.3800 13060.000
91+
0.3900 13520.000
92+
0.4000 13930.000
93+
0.4100 13230.000
94+
0.4200 14140.000
95+
0.4300 14110.000
96+
0.4400 14730.000
97+
0.4500 13240.000
98+
0.4600 14850.000
99+
0.4700 14670.000
100+
0.4800 16110.000
101+
0.4900 16920.000
102+
0.5000 18110.000
103+
0.5100 18900.000
104+
0.5200 19600.000
105+
0.5300 21530.000
106+
0.5400 22640.000
107+
0.5500 25950.000
108+
0.5600 27170.000
109+
0.5700 31850.000
110+
0.5800 35309.999
111+
0.5900 40459.999
112+
0.6000 48749.999
113+
0.6100 60139.999
114+
0.6200 77359.999
115+
0.6300 98939.999
116+
0.6400 119429.998
117+
0.6500 144089.998
118+
0.6600 173249.997
119+
0.6700 196839.997
120+
0.6800 222189.997
121+
0.6900 251099.996
122+
0.7000 276849.996
123+
0.7100 306689.995
124+
0.7200 324769.995
125+
0.7300 349759.995
126+
0.7400 370219.994
127+
0.7500 389929.994
128+
0.7600 403689.994
129+
0.7700 415189.994
130+
0.7800 419159.994
131+
0.7900 426049.994
132+
0.8000 430569.994
133+
0.8100 433369.994
134+
0.8200 433519.994
135+
0.8300 431809.994
136+
0.8400 432409.994
137+
0.8500 431049.994
138+
0.8600 432439.994
139+
0.8700 429879.994
140+
0.8800 432939.994
141+
0.8900 430969.994
142+
0.9000 429989.994
143+
0.9100 432439.994
144+
0.9200 433599.994
145+
0.9300 431779.994
146+
0.9400 436329.993
147+
0.9500 432509.994
148+
0.9600 429609.994
149+
0.9700 432349.994
150+
0.9800 429109.994
151+
0.9900 430159.994
152+
1.0000 432219.994

docs/source/examples/examples.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ Landing page for diffpy.utils examples.
1212
resample_example
1313
parsers_example
1414
tools_example
15+
mu_calc_examples
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
.. _mu calc Example:
2+
3+
:tocdepth: -1
4+
5+
Linear Absorption Coefficient (μ) Examples
6+
#########################################
7+
8+
These examples will demonstrate how to calculate the Linear absorption
9+
coefficient, μ, using different methods provided in ``diffpy.utils``.
10+
11+
12+
.. admonition:: Methods for obtaining linear absorption coefficient
13+
14+
Obtaining μ can be done in **two
15+
different ways** using ``diffpy.utils``.
16+
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 linear 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 linear 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 linear absorption,
37+
the linear absorption coefficient, μ, must be known.
38+
39+
.. admonition:: Correcting for linear absorption with ``diffpy.labpdfproc``
40+
41+
If your objective is to correct for linear 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//>`_.
46+
47+
48+
Calculating μ from a "z-scan" Measurement
49+
-----------------------------------------
50+
51+
.. note::
52+
53+
The data we will be using for this example can be found,
54+
`here <https://github.com/diffpy/diffpy.utils/tree/main/docs/source/examples/example_data>`_.
55+
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+
perpendicular to 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:: ../img/zscan-plot.png
62+
:alt: Example of a z-scan measurement.
63+
:align: center
64+
:width: 300px
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 = "CeO2_635um_zscan_200umSlit_chanClose_exported.xy"
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: 3.489
92+
Calculated mu: 6.977 mm^-1
93+
94+
Calculating μ from Tabulated Values
95+
-----------------------------------
96+
97+
The function to calculate μ from tabulated values is located
98+
in the ``diffpy.utils.tools`` module. So first, import the function,
99+
100+
.. code-block:: python
101+
102+
from diffpy.utils.tools import compute_mu_using_xraydb
103+
104+
To calculate μ, you need to know the sample composition, and X-ray energy, and sample mass density (g/cm\ :sup:`3`).
105+
106+
.. code-block:: python
107+
108+
composition = "Fe2O3"
109+
energy_keV = 17.45 # Mo K-alpha energy
110+
sample_mass_density = 5.24 # g/cm^3
111+
112+
Now calculate μ using the ``compute_mu_using_xraydb`` function.
113+
114+
.. code-block:: python
115+
116+
mu = compute_mu_using_xraydb(composition, energy_keV, sample_mass_density)
117+
print(f"Calculated mu: {round(mu, 3)} mm^-1")
118+
119+
This will output the calculated linear absorption coefficient, μ, in mm\ :sup:`-1`.
120+
121+
.. code-block:: console
122+
123+
Calculated mu: 13.967 mm^-1

docs/source/img/zscan-plot.png

79.6 KB
Loading

news/deprecator.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
**Added:**
22

3+
* added a function in _deprecator to generate a deprecation message for copy pasting
34
* Add ``@deprecated`` decorator.
45

56
**Changed:**

news/mu-docs.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* Add documentation for calculation mu.
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

0 commit comments

Comments
 (0)