File tree Expand file tree Collapse file tree 1 file changed +25
-2
lines changed
Expand file tree Collapse file tree 1 file changed +25
-2
lines changed Original file line number Diff line number Diff line change 1616 "The supplied q-array and wavelength will result in an impossible two-theta. "
1717 "Please check these values and re-instantiate the DiffractionObject with correct values."
1818)
19+ inf_output_wmsg = "WARNING: The largest output is infinite and cannot be plotted."
1920
2021
2122def _validate_inputs (q , wavelength ):
@@ -125,8 +126,30 @@ def q_to_d(qarray):
125126 return 2.0 * np .pi / copy (qarray )
126127
127128
128- def tth_to_d (ttharray , wavelength ):
129- qarray = tth_to_q (ttharray , wavelength )
129+ def tth_to_d (tth , wavelength ):
130+ r"""
131+ Helper function to convert two-theta to d on independent variable axis.
132+
133+ Uses the formula .. math:: d = \frac{\lambda}{2 \sin\left(\frac{2\theta}{2}\right)}.
134+
135+ Parameters
136+ ----------
137+ tth : 1D array
138+ The array of :math:`2\theta` values np.array([tths]).
139+ The units of tth are expected in degrees.
140+
141+ wavelength : float
142+ Wavelength of the incoming x-rays/neutrons/electrons
143+
144+ Returns
145+ -------
146+ d : 1D array
147+ The array of :math:`d` values np.array([ds]).
148+ """
149+ tth = np .deg2rad (tth )
150+ if 0 in tth :
151+ warnings .warn (inf_output_wmsg )
152+ qarray = tth_to_q (tth , wavelength )
130153 return 2.0 * np .pi / copy (qarray )
131154
132155
You can’t perform that action at this time.
0 commit comments