@@ -8,34 +8,27 @@ Diffraction Objects Example
88This example will demonstrate how to use the ``DiffractionObject `` class in the
99``diffpy.utils.scattering_objects.diffraction_objects `` module to process and analyze diffraction data.
1010
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. ::
1314
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()
1918
2019 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] ``. ::
2421
25- # convert tth to q
22+ # Example: convert tth to q
2623 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()
3026
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] ``.
3228
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. ::
4031
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