Skip to content

Commit d016b99

Browse files
authored
Merge pull request #215 from cadenmyers13/doc0.3.0
doc: Add documentation reflecting new CLI
2 parents 6a632b7 + be60e61 commit d016b99

File tree

11 files changed

+347
-185
lines changed

11 files changed

+347
-185
lines changed

.github/workflows/matrix-and-codecov-on-merge-to-main.yml

Lines changed: 0 additions & 62 deletions
This file was deleted.
Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
:tocdepth: -1
22

3-
|title|
4-
=======
5-
6-
.. |title| replace:: diffpy.labpdfproc package
3+
diffpy.labpdfproc package
4+
=========================
75

86
.. automodule:: diffpy.labpdfproc
97
:members:
@@ -14,17 +12,33 @@ Subpackages
1412
-----------
1513

1614
.. toctree::
17-
diffpy.labpdfproc.example_package
15+
:titlesonly:
16+
17+
diffpy.labpdfproc.data
1818

1919
Submodules
2020
----------
2121

22-
|module|
23-
--------
22+
diffpy.labpdfproc.functions module
23+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
24+
25+
.. automodule:: diffpy.labpdfproc.functions
26+
:members:
27+
:undoc-members:
28+
:show-inheritance:
29+
30+
diffpy.labpdfproc.tools module
31+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32+
33+
.. automodule:: diffpy.labpdfproc.tools
34+
:members:
35+
:undoc-members:
36+
:show-inheritance:
2437

25-
.. |module| replace:: diffpy.labpdfproc.example_submodule module
38+
diffpy.labpdfproc.labpdfprocapp module
39+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2640

27-
.. automodule:: diffpy.labpdfproc.example_submodule
41+
.. automodule:: diffpy.labpdfproc.labpdfprocapp
2842
:members:
2943
:undoc-members:
3044
:show-inheritance:

docs/source/examples/example-data/CeO2_635um_zscan_200umSlit_chanClose_exported.xy renamed to docs/source/examples/example-data/CeO2_635um_zscan.xy

File renamed without changes.

docs/source/examples/labpdfprocapp-example.rst

Lines changed: 160 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -10,121 +10,206 @@ to apply absorption correction to your 1D diffraction data using the command-lin
1010
Check ``labpdfproc --help`` for more information.
1111
A graphical user interface (GUI) is also available and is designed to be intuitive and easy to use.
1212

13+
There are three ways to correct dirraction data within ``diffpy.labpdfproc``, these are,
1314

14-
1. To use this application, you will need:
15-
(1) your input diffraction data file(s), and (2) information required to compute the muD value.
16-
To launch the GUI, use ``labpdfproc`` or ``labpdfproc --gui``.
17-
Note that the GUI is currently not supported on Python 3.13.
15+
1. ``labpdfproc mud``: Provide the diffraction data file(s) and muD value directly.
16+
2. ``labpdfproc zscan``: Provide the diffraction data file(s) and a z-scan file, which will be used to calculate the muD value.
17+
3. ``labpdfproc sample``: Provide the diffraction data file(s) and information about the sample to calculate the theoretical muD value.
1818

19+
We will go through all three methods in this tutorial.
1920

20-
2. Here we first provide a basic CLI example.
21-
Assume you have an uncorrected diffraction data file named ``zro2_mo.xy`` in the current directory
22-
with a muD of 2.5 on the two-theta x-axis. Then the minimum command would be:
21+
.. admonition:: Example Data
2322

24-
.. code-block:: python
23+
Example data for these examples can be found at: https://github.com/diffpy/diffpy.labpdfproc/tree/main/docs/source/examples/example-data
2524

26-
labpdfproc zro2_mo.xy --mud 2.5
2725

26+
Launching the Graphical User Interface (GUI)
27+
--------------------------------------------
2828

29-
3. You must provide at least one file path, and filepath(s) should immediately follow ``labpdfproc``.
29+
To launch the GUI, run one of the following commands in your terminal,
3030

31-
To process multiple files at once in the CLI, separate each file path with a whitespace.
32-
In general, avoid spaces in filenames, but if necessary, enclose them in quotes; otherwise, quotes are optional.
33-
For example, the following is a valid and more complex CLI command:
31+
.. code-block:: bash
3432
35-
.. code-block:: python
33+
labpdfproc
34+
labpdfproc --gui
3635
37-
labpdfproc "SiO2 uncorrected.xy" input_dir file_list.txt ./*.chi data* --mud 2.5
36+
.. note:: Note that the GUI is currently not supported on Python>=3.12.
3837

39-
This command will process ``"SiO2 uncorrected.xy"``,
40-
all files in the ``input_dir`` directory, all files listed in ``file_list.txt``,
41-
all ``.chi`` files in the current directory, and all files matching the pattern ``data``,
42-
using a muD value of 2.5.
43-
Check ``labpdfproc --help`` to see all supported file types.
38+
This will open the GUI, which should look something like,
4439

45-
In the GUI, you can select multiple individual files via the file browser, but not entire directories.
46-
To include directories, you can either:
47-
(1) create a text file named ``file_list.txt`` containing the desired paths and load it,
48-
(2) manually select all files in a folder, or
49-
(3) enter paths manually separated by a colon with no spaces.
40+
.. image:: ../img/labpdfproc-gui.jpeg
41+
:align: center
5042

51-
We will now continue using ``zro2_mo.xy`` as the example input throughout the rest of this tutorial.
43+
Below we will go through all the commands using the CLI, but the same principles apply to the GUI.
5244

45+
.. note:: The first time you run any of the below commands,
46+
you will be prompted to enter your name, email, and ORCID. This will be
47+
appended to metadata in the output file header for reproducibility and tracking purposes.
5348

54-
4. The muD value is required for absorption correction, and you can specify it in one of the four ways:
5549

56-
.. code-block:: python
50+
``labpdfproc mud`` Command
51+
---------------------------
5752

58-
# Option 1: Manual value
59-
labpdfproc zro2_mo.xy --mud 2.5
60-
# Option 2: From a z-scan file
61-
labpdfproc zro2_mo.xy -z zscan.xy
62-
# Option 3: Using sample mass density
63-
labpdfproc zro2_mo.xy -d ZrO2,17.45,1.2
64-
# Option 4: Using packing fraction
65-
labpdfproc zro2_mo.xy -p ZrO2,17.45,0.2
53+
If you know the muD value for your sample, you can use the ``labpdfproc mud``
54+
command to apply absorption correction directly.
6655

67-
Note that you can only use one method at a time. The following examples are not allowed:
56+
To see all the options for this command, type,
6857

69-
.. code-block:: python
58+
.. code-block:: bash
7059
71-
labpdfproc zro2_mo.xy --mud 2.5 -z zscan.xy
72-
labpdfproc zro2_mo.xy --mud 2.5 -d ZrO2,17.45,1.2
60+
labpdfproc mud -h
7361
74-
If the packing fraction option is not supported at the moment, you can approximate the sample mass density as:
75-
``mass density = packing fraction * material density``, where the material density can be looked up manually.
62+
To run the correction, specify the path to your diffraction data file(s) and the muD value,
7663

64+
.. code-block:: bash
7765
78-
5. You can specify the wavelength in two ways:
66+
labpdfproc mud <diffraction-data-file.xy> <mud>
67+
labpdfproc mud zro2_mo.xy 2.5
7968
80-
.. code-block:: python
69+
If the flag ``--wavelength`` is not specified, the program will attempt to fetch
70+
the wavelength from a configuration file.
71+
If the wavelength is not found in the configuration file, a ``ValueError``
72+
will be raised, prompting you to provide the wavelength either through the CLI or the configuration file.
8173

82-
# Option 1: Manually enter wavelength
83-
labpdfproc zro2_mo.xy --mud 2.5 -w 0.71303
84-
# Option 2: Use a known anode type
85-
labpdfproc zro2_mo.xy --mud 2.5 -a Mo
74+
To provide the wavelength through the CLI, you can use the ``-w`` or ``--wavelength`` flag followed by the wavelength value in angstroms or the X-ray source.
75+
For example,
8676

87-
Do not use both ``-w`` and ``-a`` at the same time. For example:
77+
.. code-block:: bash
8878
89-
.. code-block:: python
79+
labpdfproc mud zro2_mo.xy 2.5 -w 0.71303
80+
labpdfproc mud zro2_mo.xy 2.5 -w Mo
9081
91-
labpdfproc zro2_mo.xy --mud 2.5 -w 0.71303 -a Mo
82+
This will then save the corrected file in the same directory as the input file with the name ``zro2_mo_corrected.chi``.
9283

93-
is not valid. This is to avoid confusion when wavelength conflicts with anode type.
94-
To avoid retyping, you can save your wavelength or anode type in a diffpy configuration file.
95-
See full instructions at https://www.diffpy.org/diffpy.labpdfproc/examples/tools_example.html.
84+
To save the correction file, specify the ``-c`` or ``--output-correction`` flag,
9685

86+
.. code-block:: bash
9787
98-
6. You are also encouraged to provide your information (name, email, and orcid) for reproducibility:
88+
labpdfproc mud zro2_mo.xy 2.5 -w 0.71303 -c
9989
100-
.. code-block:: python
90+
This will then save the correction file in the same directory as the input file with the name ``zro2_mo_cve.chi``.
10191

102-
labpdfproc zro2_mo.xy --mud 2.5 -n Joe -e Joe@email.com --orcid 0000-0000-0000-0000
92+
``labpdfproc zscan`` Command
93+
----------------------------
10394

95+
The ``labpdfproc zscan`` command allows you to calculate the muD value from a z-scan file and apply absorption correction to your diffraction data.
96+
For more information on what a z-scan is, please see the "Examples --> Linear Absorption Coefficient Examples"
97+
section in the ``diffpy.utils`` documentation: https://www.diffpy.org/diffpy.utils/examples/mu_calc_examples.html.
10498

105-
Alternatively, you can enter this information during the interactive prompts
106-
or save it in your diffpy configuration file.
107-
For more details, refer to https://www.diffpy.org/diffpy.utils/examples/tools_example.html.
99+
To see the options for this command, type,
108100

101+
.. code-block:: bash
109102
110-
7. You can further customize the diffraction correction process using the following options:
103+
labpdfproc zscan -h
111104
112-
- Choose xtype: use ``-x`` to specify your input data's xtype, which will be used for the output.
113-
- Select correction method: use ``-m`` to choose between "brute_force" or "polynomial_interpolation" (faster and preferred for muD 0.5-7).
114-
- Specify output directory: use ``-o`` to save the corrected file(s) to a specific folder.
115-
- Add custom metadata: use ``-u`` to provide key-value pair for information tracking (e.g., experimental details).
116-
- Output the cve file: use ``-c`` to export the cve file along with the corrected data.
117-
- Overwrite existing files: use ``-f`` to replace any previous corrected files with the same names.
105+
To run this command, provide the path to your diffraction data file(s) and the z-scan file,
118106

107+
.. code-block:: bash
119108
120-
8. To summarize, a full command might look like this:
109+
labpdfproc zscan <diffraction-data-file.xy> <zscan-file.xy>
110+
labpdfproc zscan CeO2_635um_accum_0.xy CeO2_635um_zscan.xy
121111
122-
.. code-block:: python
112+
Like the ``labpdfproc mud`` command, you can also specify the
113+
wavelength or source type using the ``-w`` flag if it's not found in the configuration file,
123114

124-
labpdfproc zro2_mo.xy --mud 2.5 -w 0.71303 -n Joe -x q -m brute_force -o results -u "facility=NSLS II" beamline=28ID-2 -c -f
115+
.. code-block:: bash
125116
126-
After running the command, check your output folder (in this case, ``results``)
127-
for the corrected data file and cve file (if ``-c`` was used).
128-
In this example, the corrected and cve files are called ``zro2_mo_corrected.chi`` and ``zro2_mo_cve.chi``.
129-
The headers include all the arguments you provided
130-
—such as diffraction settings, personal information, and metadata—making it easy to track your analysis.
117+
labpdfproc zscan CeO2_635um_accum_0.xy CeO2_635um_zscan.xy -w 0.71303
118+
labpdfproc zscan CeO2_635um_accum_0.xy CeO2_635um_zscan.xy -w Mo
119+
120+
This will save the corrected file in the same directory as the input file with the name ``CeO2_635um_accum_0.chi``.
121+
122+
To save the correction file, specify the ``-c`` or ``--output-correction`` flag,
123+
124+
.. code-block:: bash
125+
126+
labpdfproc zscan CeO2_635um_accum_0.xy CeO2_635um_zscan.xy -w 0.71303 -c
127+
128+
This will then save the correction file in the same directory as the input file with the name ``CeO2_635um_accum_0_cve.chi``.
129+
130+
``labpdfproc sample`` Command
131+
-----------------------------
132+
133+
The ``labpdfproc sample`` command allows you to calculate the muD value from information
134+
about your sample and apply absorption correction to your diffraction data.
135+
136+
To see the options for this command, type,
137+
138+
.. code-block:: bash
139+
140+
labpdfproc sample -h
141+
142+
To run this command, provide the path to your diffraction data file(s) along with:
143+
144+
1) ``sample_composition``: The chemical formula of your sample.
145+
2) ``sample_mass_density``: The mass density of your sample in g/cm^3. If you don't know the mass density, a good approximation is typically ~1/3 of the theoretical packing fraction.
146+
3) ``diameter``: The outer diameter of your capillary.
147+
148+
.. code-block:: bash
149+
150+
labpdfproc sample <diffraction-data-file.xy> <sample_composition> <sample_mass_density> <diameter>
151+
labpdfproc sample zro2_mo.xy ZrO2 17.45 1.2
152+
153+
Once again, you can specify the wavelength or source type using the ``-w`` flag if it's not found in the configuration file,
154+
155+
.. code-block:: bash
156+
157+
labpdfproc sample zro2_mo.xy ZrO2 17.45 1.2 -w 0.71303
158+
labpdfproc sample zro2_mo.xy ZrO2 17.45 1.2 -w Mo
159+
160+
This will save the corrected file in the same directory as the input file with the name ``zro2_mo.chi``.
161+
162+
To save the correction file, specify the ``-c`` or ``--output-correction`` flag,
163+
164+
.. code-block:: bash
165+
166+
labpdfproc sample zro2_mo.xy ZrO2 17.45 1.2 -w 0.71303 -c
167+
168+
This will then save the correction file in the same directory as the input file with the name ``zro2_mo_cve.chi``.
169+
170+
Additional CLI options
171+
----------------------
172+
173+
Below is a summary of all the additional flags that can be used with all three commands,
174+
175+
- ``-h, --help``
176+
Show this help message and exit.
177+
178+
- ``-w, --wavelength WAVELENGTH``
179+
X-ray wavelength in angstroms (numeric) or X-ray source name.
180+
Allowed: ``Ag``, ``AgKa1``, ``AgKa1Ka2``, ``Cu``, ``CuKa1``, ``CuKa1Ka2``, ``Mo``, ``MoKa1``, ``MoKa1Ka2``.
181+
Will be loaded from config files if not specified.
182+
183+
- ``-x, --xtype XTYPE``
184+
X-axis type (default: ``tth``). Allowed values: ``angle``, ``tth``, ``twotheta``, ``2theta``, ``d``, ``dspace``, ``q``.
185+
186+
- ``-m, --method {brute_force, polynomial_interpolation}``
187+
Method for cylindrical volume element (CVE) calculation (default: ``polynomial_interpolation``).
188+
Allowed methods: ``brute_force``, ``polynomial_interpolation``.
189+
190+
- ``-o, --output-directory OUTPUT_DIRECTORY``
191+
Directory to save corrected files (created if needed). Defaults to current directory.
192+
193+
- ``-f, --force``
194+
Overwrite existing files.
195+
196+
- ``-c, --output-correction``
197+
Also output the absorption correction to a separate file.
198+
199+
- ``-u, --user-metadata KEY=VALUE [KEY=VALUE ...]``
200+
Specify key-value pairs to be loaded into metadata. Format: ``key=value``.
201+
- Separate multiple pairs with whitespace.
202+
- No spaces before or after ``=``.
203+
- Avoid using ``=`` in keys. Only the first ``=`` separates key and value.
204+
- If a key or value contains whitespace, enclose it in quotes.
205+
Examples:
206+
``facility='NSLS II', beamline=28ID-2, 'favorite color'=blue``.
207+
208+
- ``--username USERNAME``
209+
Your name (optional, for dataset credit). Will be loaded from config files if not specified.
210+
211+
- ``--email EMAIL``
212+
Your email (optional, for dataset credit). Will be loaded from config files if not specified.
213+
214+
- ``--orcid ORCID``
215+
Your ORCID ID (optional, for dataset credit). Will be loaded from config files if not specified.

0 commit comments

Comments
 (0)