|
5 | 5 | labpdfprocapp Example
|
6 | 6 | #####################
|
7 | 7 |
|
8 |
| -This example provides a quick-start tutorial for using ``diffpy.labpdfproc``. |
9 |
| -It will demonstrate how to apply absorption correction to your 1D diffraction data |
10 |
| -using either the command-line (CLI) or graphical user interface (GUI). |
11 |
| -For more details, run ``labpdfproc --help``. |
| 8 | +This example provides a quick-start tutorial for using ``diffpy.labpdfproc`` |
| 9 | +to apply absorption correction to your 1D diffraction data using the command-line (CLI). |
| 10 | +Check ``labpdfproc --help`` for more information. |
| 11 | +A graphical user interface (GUI) is also available and is designed to be intuitive and easy to use. |
12 | 12 |
|
13 |
| -1. In order to use this app, |
14 |
| -you will need: (1) your input diffraction data file(s), and (2) information required to compute the mu*D value. |
15 |
| -To launch the GUI, use either ``labpdfproc`` or ``labpdfproc --gui``. |
16 |
| -Note that the GUI currently does not support Python 3.13. |
17 | 13 |
|
18 |
| -2. Here we provide a basic example first. |
19 |
| -Assume you have an uncorrected data called zro2_mo.xy in the current directory with a muD of 2.5 in two-theta. |
20 |
| -Then the minimum command would be: |
| 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. |
| 18 | + |
| 19 | + |
| 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: |
| 23 | + |
| 24 | +.. code-block:: python |
| 25 | +
|
| 26 | + labpdfproc zro2_mo.xy --mud 2.5 |
| 27 | +
|
| 28 | +
|
| 29 | +3. You must provide at least one file path, and filepath(s) should immediately follow ``labpdfproc``. |
| 30 | + |
| 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: |
| 34 | + |
| 35 | +.. code-block:: python |
| 36 | +
|
| 37 | + labpdfproc "SiO2 uncorrected.xy" input_dir file_list.txt ./*.chi data* --mud 2.5 |
| 38 | +
|
| 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. |
| 44 | + |
| 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. |
| 50 | + |
| 51 | +We will now continue using ``zro2_mo.xy`` as the example input throughout the rest of this tutorial. |
| 52 | + |
| 53 | + |
| 54 | +4. The muD value is required for absorption correction, and you can specify it in one of the four ways: |
21 | 55 |
|
22 | 56 | .. code-block:: python
|
23 | 57 |
|
| 58 | + # Option 1: Manual value |
24 | 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 |
| 66 | +
|
| 67 | +Note that you can only use one method at a time. The following examples are not allowed: |
| 68 | + |
| 69 | +.. code-block:: python |
25 | 70 |
|
26 |
| -3. You must provide at least one file path. |
27 |
| -In the GUI, the file browser supports selecting multiple files, but not entire folders. |
28 |
| -To include directories in GUI mode, you can: |
29 |
| -(1) create a text file named ``file_list.txt`` listing the desired paths and load it, |
30 |
| -(2) select all files in a folder manually, |
31 |
| -(3) manually enter file paths separated by semicolons. |
| 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 |
32 | 73 |
|
33 |
| -4. You can specify the wavelength in different ways: |
| 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. |
| 76 | + |
| 77 | + |
| 78 | +5. You can specify the wavelength in two ways: |
34 | 79 |
|
35 | 80 | .. code-block:: python
|
36 | 81 |
|
37 |
| - # manually enter wavelength |
38 |
| - labpdfproc zro2_mo.xy --mud 2 -w 0.71303 |
39 |
| - # use a known anode_type |
40 |
| - labpdfproc zro2_mo.xy --mud 2 -a Mo |
| 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 |
41 | 86 |
|
42 |
| -5. To specify the output directory where the corrected data should be saved: |
| 87 | +Do not use both ``-w`` and ``-a`` at the same time. For example: |
43 | 88 |
|
44 | 89 | .. code-block:: python
|
45 | 90 |
|
46 |
| - labpdfproc zro2_mo.xy --mud 2 -w 0.71303 -o "output_dir" |
| 91 | + labpdfproc zro2_mo.xy --mud 2.5 -w 0.71303 -a Mo |
47 | 92 |
|
48 |
| -This will save the processed data into the folder ``output_dir``. |
| 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. |
49 | 96 |
|
50 |
| -6. Additional options: |
51 |
| -- ``xtype``: choose the x-axis variable for your diffraction data. |
52 |
| -- You can also choose to output the cve file as well (via ``-o`` in CLI or checkbox in GUI). |
53 |
| -- Use the overwrite option carefully - it will replace existing files. |
54 |
| -- You are encouraged to input user information to help save progress and support reproducibility. |
| 97 | + |
| 98 | +6. You are also encouraged to provide your information (name, email, and orcid) for reproducibility: |
55 | 99 |
|
56 | 100 | .. code-block:: python
|
57 | 101 |
|
58 |
| - labpdfproc zro2_mo.xy --mud 2 -n Joe -e Joe@email.com --orcid 0000-0000-0000-0000 |
| 102 | + labpdfproc zro2_mo.xy --mud 2.5 -n Joe -e Joe@email.com --orcid 0000-0000-0000-0000 |
| 103 | +
|
| 104 | +
|
| 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. |
| 108 | + |
| 109 | + |
| 110 | +7. You can further customize the diffraction correction process using the following options: |
| 111 | + |
| 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. |
| 118 | + |
| 119 | + |
| 120 | +8. To summarize, a full command might look like this: |
| 121 | + |
| 122 | +.. code-block:: python |
59 | 123 |
|
| 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 |
60 | 125 |
|
61 |
| -You can also enter this information during input prompts or store it in a diffpy configuration file. |
62 |
| -For a full tutorial, refer to the documentation on ``diffpy.utils``. |
| 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. |
0 commit comments