Skip to content

docs for transformers module #237

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

Merged
merged 1 commit into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 0 additions & 34 deletions doc/source/examples/diffractionobjectsexample.rst

This file was deleted.

53 changes: 53 additions & 0 deletions doc/source/examples/transformsexample.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
.. _Transforms Example:

:tocdepth: -1

Transforms Example
##################

This example will demonstrate how to use the functions in the
``diffpy.utils.transforms`` module to process and analyze diffraction data.

1) Converting from ``q`` to ``2theta`` or ``d``:
If you have a 1D ``q``-array, you can use the ``q_to_tth`` and ``q_to_d`` functions
to convert it to ``2theta`` or ``d``. ::

# Example: convert q to 2theta
from diffpy.utils.transformers import q_to_tth
wavelength = 0.71
q = np.array([0, 0.2, 0.4, 0.6, 0.8, 1])
tth = q_to_tth(q, wavelength)

# Example: convert q to d
from diffpy.utils.transformers import q_to_d
q = np.array([0, 0.2, 0.4, 0.6, 0.8, 1])
d = q_to_d(q)

(2) Converting from ``2theta`` to ``q`` or ``d``:
For a 1D ``2theta`` array, you can convert it to ``q`` or ``d`` in a similar way. ::

# Example: convert 2theta to q
from diffpy.utils.transformers import tth_to_q
wavelength = 0.71
tth = np.array([0, 30, 60, 90, 120, 180])
q = tth_to_q(tth, wavelength)

# Example: convert 2theta to d
from diffpy.utils.transformers import tth_to_d
wavelength = 0.71
tth = np.array([0, 30, 60, 90, 120, 180])
d = tth_to_d(tth, wavelength)

(3) Converting from ``d`` to ``q`` or ``2theta``:
For a 1D ``d`` array, you can convert it to ``q`` or ``2theta``. ::

# Example: convert d to q
from diffpy.utils.transformers import tth_to_q
d = np.array([1.0, 0.8, 0.6, 0.4, 0.2])
q = d_to_q(d)

# Example: convert d to 2theta
from diffpy.utils.transformers import d_to_tth
wavelength = 0.71
d = np.array([1.0, 0.8, 0.6, 0.4, 0.2])
tth = d_to_tth(d, wavelength)
13 changes: 0 additions & 13 deletions doc/source/utilities/diffractionobjectsutility.rst

This file was deleted.

14 changes: 14 additions & 0 deletions doc/source/utilities/transformsutility.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. _Transforms Utility:

Transforms Utility
==================

The ``diffpy.utils.transforms`` module provides a set of functions for managing and analyzing diffraction data,
including angle-space transformations between ``q``, ``2theta``, and ``d``-spacing.

These functions allow developers to standardize diffraction data and convert it between different spacings,
simplifying analysis, visualization, and processing.
They are also internally used by the ``DiffractionObject`` class for efficient data manipulation.
For more information about this, click :ref:`here <DiffractionObject Utility>`.

For a more in-depth tutorial for how to use these functions, click :ref:`here <Transforms Example>`.
Loading