-
Notifications
You must be signed in to change notification settings - Fork 21
q_to_tth & tth_to_q #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
q_to_tth & tth_to_q #178
Changes from 3 commits
7841ff2
1b0fa19
4e85b0a
a33482b
3efde28
a53461f
2a5a819
64d8693
728ff36
490486c
d481253
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -763,25 +763,27 @@ def q_to_tth(self): | |
|
|
||
| 2\theta_n = 2 \arcsin\left(\frac{\lambda q}{4 \pi}\right) | ||
|
|
||
| Function adapted from scikit-beam. Thanks to those developers | ||
|
|
||
| Parameters | ||
| ---------- | ||
| q : array | ||
| An array of :math:`q` values | ||
| The array of :math:`q` values | ||
|
|
||
| wavelength : float | ||
| Wavelength of the incoming x-rays | ||
|
|
||
| Function adapted from scikit-beam. Thanks to those developers | ||
|
|
||
| Returns | ||
| ------- | ||
| two_theta : array | ||
| An array of :math:`2\theta` values in radians | ||
| The array of :math:`2\theta` values in radians | ||
| """ | ||
| q = self.on_q[0] | ||
| q = np.asarray(q) | ||
| wavelength = float(self.wavelength) | ||
| pre_factor = wavelength / (4 * np.pi) | ||
| if np.any(np.abs(q * pre_factor) > 1): | ||
| raise ValueError("Please check if you entered an incorrect wavelength or q value.") | ||
|
||
| return np.rad2deg(2.0 * np.arcsin(q * pre_factor)) | ||
|
|
||
| def tth_to_q(self): | ||
|
|
@@ -800,25 +802,28 @@ def tth_to_q(self): | |
|
|
||
| q = \frac{4 \pi \sin\left(\frac{2\theta}{2}\right)}{\lambda} | ||
|
|
||
|
|
||
| Function adapted from scikit-beam. Thanks to those developers. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| two_theta : array | ||
| An array of :math:`2\theta` values in units of degrees | ||
| The array of :math:`2\theta` values in units of degrees | ||
|
|
||
| wavelength : float | ||
| Wavelength of the incoming x-rays | ||
|
|
||
| Function adapted from scikit-beam. Thanks to those developers. | ||
|
|
||
| Returns | ||
| ------- | ||
| q : array | ||
| An array of :math:`q` values in the inverse of the units | ||
| The array of :math:`q` values in the inverse of the units | ||
| of ``wavelength`` | ||
| """ | ||
| two_theta = np.asarray(np.deg2rad(self.on_tth[0])) | ||
| if np.any(two_theta > np.pi): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as above, I think this isn't doing quite what we want. |
||
| raise ValueError( | ||
| "Two theta exceeds 180 degrees. Please check if invalid values were entered " | ||
| "or if degrees were incorrectly specified as radians." | ||
| ) | ||
| wavelength = float(self.wavelength) | ||
| pre_factor = (4 * np.pi) / wavelength | ||
| return pre_factor * np.sin(two_theta / 2) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.