Skip to content

Commit 6edcd83

Browse files
committed
add documentation that reflects the new cli
1 parent c73c282 commit 6edcd83

4 files changed

Lines changed: 160 additions & 76 deletions

File tree

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.
Lines changed: 160 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
.. _labpdfprocapp Example:
21

32
:tocdepth: -1
43

@@ -10,121 +9,206 @@ to apply absorption correction to your 1D diffraction data using the command-lin
109
Check ``labpdfproc --help`` for more information.
1110
A graphical user interface (GUI) is also available and is designed to be intuitive and easy to use.
1211

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

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.
14+
1. ``labpdfproc mud``: Provide the diffraction data file(s) and muD value directly.
15+
2. ``labpdfproc zscan``: Provide the diffraction data file(s) and a z-scan file, which will be used to calculate the muD value.
16+
3. ``labpdfproc sample``: Provide the diffraction data file(s) and information about the sample to calculate the theoretical muD value.
1817

18+
We will go through all three methods in this tutorial.
1919

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:
20+
.. admonition:: Example Data
2321

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

26-
labpdfproc zro2_mo.xy --mud 2.5
2724

25+
Launching the Graphical User Interface (GUI)
26+
--------------------------------------------
2827

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

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:
30+
.. code-block:: bash
3431
35-
.. code-block:: python
32+
labpdfproc
33+
labpdfproc --gui
3634
37-
labpdfproc "SiO2 uncorrected.xy" input_dir file_list.txt ./*.chi data* --mud 2.5
35+
.. note:: Note that the GUI is currently not supported on Python>=3.12.
3836

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.
37+
This will open the GUI, which should look something like,
4438

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.
39+
.. image:: ../img/labpdfproc-gui.jpeg
40+
:align: center
5041

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

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

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

56-
.. code-block:: python
49+
``labpdfproc mud`` Command
50+
---------------------------
5751

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
52+
If you know the muD value for your sample, you can use the ``labpdfproc mud``
53+
command to apply absorption correction directly.
6654

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

69-
.. code-block:: python
57+
.. code-block:: bash
7058
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
59+
labpdfproc mud -h
7360
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.
61+
To run the correction, specify the path to your diffraction data file(s) and the muD value,
7662

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

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
73+
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.
74+
For example,
8675

87-
Do not use both ``-w`` and ``-a`` at the same time. For example:
76+
.. code-block:: bash
8877
89-
.. code-block:: python
78+
labpdfproc mud zro2_mo.xy 2.5 -w 0.71303
79+
labpdfproc mud zro2_mo.xy 2.5 -w Mo
9080
91-
labpdfproc zro2_mo.xy --mud 2.5 -w 0.71303 -a Mo
81+
This will then save the corrected file in the same directory as the input file with the name ``zro2_mo_corrected.chi``.
9282

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.
83+
To save the correction file, specify the ``-c`` or ``--output-correction`` flag,
9684

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

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

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

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.
98+
To see the options for this command, type,
10899

100+
.. code-block:: bash
109101
110-
7. You can further customize the diffraction correction process using the following options:
102+
labpdfproc zscan -h
111103
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.
104+
To run this command, provide the path to your diffraction data file(s) and the z-scan file,
118105

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

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

docs/source/img/.placeholder

Whitespace-only changes.
161 KB
Loading

0 commit comments

Comments
 (0)