@@ -8,34 +8,27 @@ Diffraction Objects Example
8
8
This example will demonstrate how to use the ``DiffractionObject `` class in the
9
9
``diffpy.utils.scattering_objects.diffraction_objects `` module to process and analyze diffraction data.
10
10
11
- 1) We have the function ``q_to_tth `` to convert q to two theta values in degrees, and ``tth_to_q `` to do the reverse.
12
- You can use these functions with a pre-defined ``DiffractionObject ``. ::
11
+ 1) Assuming we have created a ``DiffractionObject `` called my_diffraction_pattern from a measured diffraction pattern,
12
+ and we have specified the wavelength (see Section ??, to be added),
13
+ we can use the ``q_to_tth `` and ``tth_to_q `` functions to convert between q and two-theta. ::
13
14
14
- # convert q to tth
15
- from diffpy.utils.scattering_objects.diffraction_objects import DiffractionObject
16
- test = DiffractionObject(wavelength=1.54)
17
- test.on_q = [[0, 0.2, 0.4, 0.6, 0.8, 1], [1, 2, 3, 4, 5, 6]]
18
- test.q_to_tth()
15
+ # Example: convert q to tth
16
+ my_diffraction_pattern.on_q = [[0, 0.2, 0.4, 0.6, 0.8, 1], [1, 2, 3, 4, 5, 6]]
17
+ my_diffraction_pattern.q_to_tth()
19
18
20
19
This function will convert your provided q array and return a two theta array in degrees.
21
- To load the converted array, you can either call ``test.q_to_tth() `` or ``test.on_q[0] ``.
22
-
23
- Similarly, use the function ``tth_to_q `` to convert two theta values in degrees to q values. ::
20
+ To load the converted array, you can either call ``test.q_to_tth() `` or ``test.on_q[0] ``. ::
24
21
25
- # convert tth to q
22
+ # Example: convert tth to q
26
23
from diffpy.utils.scattering_objects.diffraction_objects import DiffractionObject
27
- test = DiffractionObject(wavelength=1.54)
28
- test.on_tth = [[0, 30, 60, 90, 120, 180], [1, 2, 3, 4, 5, 6]]
29
- test.tth_to_q()
24
+ my_diffraction_pattern.on_tth = [[0, 30, 60, 90, 120, 180], [1, 2, 3, 4, 5, 6]]
25
+ my_diffraction_pattern.tth_to_q()
30
26
31
- To load the converted array, you can either call ``test.tth_to_q() `` or ``test.on_tth[0] ``.
27
+ Similarly, to load the converted array, you can either call ``test.tth_to_q() `` or ``test.on_tth[0] ``.
32
28
33
- 2) You can use these functions without specifying a wavelength. However, if so, the function will return an empty array,
34
- so we strongly encourage you to specify a wavelength when using these functions. ::
35
-
36
- from diffpy.utils.scattering_objects.diffraction_objects import DiffractionObject
37
- test = DiffractionObject()
38
- test.on_q = [[0, 0.2, 0.4, 0.6, 0.8, 1], [1, 2, 3, 4, 5, 6]]
39
- test.q_to_tth()
29
+ 2) Both functions require a wavelength to perform conversions. Without a wavelength, they will return empty arrays.
30
+ Therefore, we strongly encourage you to specify a wavelength when using these functions. ::
40
31
41
- In this case, the function will return an empty array on two theta.
32
+ # Example: without wavelength specified
33
+ my_diffraction_pattern.on_q = [[0, 0.2, 0.4, 0.6, 0.8, 1], [1, 2, 3, 4, 5, 6]]
34
+ my_diffraction_pattern.q_to_tth() # returns an empty array
0 commit comments