Skip to content

Commit 01e71dc

Browse files
initial commit
1 parent 7b6ee2e commit 01e71dc

File tree

4 files changed

+67
-47
lines changed

4 files changed

+67
-47
lines changed

Diff for: doc/source/examples/diffractionobjectsexample.rst

-34
This file was deleted.

Diff for: doc/source/examples/transformsexample.rst

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
.. _Transforms Example:
2+
3+
:tocdepth: -1
4+
5+
Transforms Example
6+
##################
7+
8+
This example will demonstrate how to use the functions in the
9+
``diffpy.utils.transforms`` module to process and analyze diffraction data.
10+
11+
1) Converting from ``q`` to ``2theta`` or ``d``:
12+
If you have a 1D ``q``-array, you can use the ``q_to_tth`` and ``q_to_d`` functions
13+
to convert it to ``2theta`` or ``d``. ::
14+
15+
# Example: convert q to 2theta
16+
from diffpy.utils.transformers import q_to_tth
17+
wavelength = 0.71
18+
q = np.array([0, 0.2, 0.4, 0.6, 0.8, 1])
19+
tth = q_to_tth(q, wavelength)
20+
21+
# Example: convert q to d
22+
from diffpy.utils.transformers import q_to_d
23+
q = np.array([0, 0.2, 0.4, 0.6, 0.8, 1])
24+
d = q_to_d(q)
25+
26+
(2) Converting from ``2theta`` to ``q`` or ``d``:
27+
For a 1D ``2theta`` array, you can convert it to ``q`` or ``d`` in a similar way. ::
28+
29+
# Example: convert 2theta to q
30+
from diffpy.utils.transformers import tth_to_q
31+
wavelength = 0.71
32+
tth = np.array([0, 30, 60, 90, 120, 180])
33+
q = tth_to_q(tth, wavelength)
34+
35+
# Example: convert 2theta to d
36+
from diffpy.utils.transformers import tth_to_d
37+
wavelength = 0.71
38+
tth = np.array([0, 30, 60, 90, 120, 180])
39+
d = tth_to_d(tth, wavelength)
40+
41+
(3) Converting from ``d`` to ``q`` or ``2theta``:
42+
For a 1D ``d`` array, you can convert it to ``q`` or ``2theta``. ::
43+
44+
# Example: convert d to q
45+
from diffpy.utils.transformers import tth_to_q
46+
d = np.array([1.0, 0.8, 0.6, 0.4, 0.2])
47+
q = d_to_q(d)
48+
49+
# Example: convert d to 2theta
50+
from diffpy.utils.transformers import d_to_tth
51+
wavelength = 0.71
52+
d = np.array([1.0, 0.8, 0.6, 0.4, 0.2])
53+
tth = d_to_tth(d, wavelength)

Diff for: doc/source/utilities/diffractionobjectsutility.rst

-13
This file was deleted.

Diff for: doc/source/utilities/transformsutility.rst

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.. _Transforms Utility:
2+
3+
Transforms Utility
4+
==================
5+
6+
The ``diffpy.utils.transforms`` module provides a set of functions for managing and analyzing diffraction data,
7+
including angle-space transformations between ``q``, ``2theta``, and ``d``-spacing.
8+
9+
These functions allow developers to standardize diffraction data and convert it between different spacings,
10+
simplifying analysis, visualization, and processing.
11+
They are also internally used by the ``DiffractionObject`` class for efficient data manipulation.
12+
For more information about this, click :ref:`here <DiffractionObject Utility>`.
13+
14+
For a more in-depth tutorial for how to use these functions, click :ref:`here <Transforms Example>`.

0 commit comments

Comments
 (0)