|
| 1 | +.. _labpdfprocapp Example: |
| 2 | + |
| 3 | +:tocdepth: -1 |
| 4 | + |
| 5 | +labpdfprocapp Example |
| 6 | +##################### |
| 7 | + |
| 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 | + |
| 13 | + |
| 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: |
| 55 | + |
| 56 | +.. code-block:: python |
| 57 | +
|
| 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 |
| 66 | +
|
| 67 | +Note that you can only use one method at a time. The following examples are not allowed: |
| 68 | + |
| 69 | +.. code-block:: python |
| 70 | +
|
| 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 |
| 73 | +
|
| 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: |
| 79 | + |
| 80 | +.. code-block:: python |
| 81 | +
|
| 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 |
| 86 | +
|
| 87 | +Do not use both ``-w`` and ``-a`` at the same time. For example: |
| 88 | + |
| 89 | +.. code-block:: python |
| 90 | +
|
| 91 | + labpdfproc zro2_mo.xy --mud 2.5 -w 0.71303 -a Mo |
| 92 | +
|
| 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. |
| 96 | + |
| 97 | + |
| 98 | +6. You are also encouraged to provide your information (name, email, and orcid) for reproducibility: |
| 99 | + |
| 100 | +.. code-block:: python |
| 101 | +
|
| 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 |
| 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 |
| 125 | +
|
| 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