|
| 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 | +There are three ways to correct dirraction data within ``diffpy.labpdfproc``, these are, |
| 14 | + |
| 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. |
| 18 | + |
| 19 | +We will go through all three methods in this tutorial. |
| 20 | + |
| 21 | +.. admonition:: Example Data |
| 22 | + |
| 23 | + Example data for these examples can be found at: https://github.com/diffpy/diffpy.labpdfproc/tree/main/docs/source/examples/example-data |
| 24 | + |
| 25 | + |
| 26 | +Launching the Graphical User Interface (GUI) |
| 27 | +-------------------------------------------- |
| 28 | + |
| 29 | +To launch the GUI, run one of the following commands in your terminal, |
| 30 | + |
| 31 | +.. code-block:: bash |
| 32 | +
|
| 33 | + labpdfproc |
| 34 | + labpdfproc --gui |
| 35 | +
|
| 36 | +.. note:: Note that the GUI is currently not supported on Python>=3.12. |
| 37 | + |
| 38 | +This will open the GUI, which should look something like, |
| 39 | + |
| 40 | +.. image:: ../img/labpdfproc-gui.jpeg |
| 41 | + :align: center |
| 42 | + |
| 43 | +Below we will go through all the commands using the CLI, but the same principles apply to the GUI. |
| 44 | + |
| 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. |
| 48 | + |
| 49 | + |
| 50 | +``labpdfproc mud`` Command |
| 51 | +--------------------------- |
| 52 | + |
| 53 | +If you know the muD value for your sample, you can use the ``labpdfproc mud`` |
| 54 | +command to apply absorption correction directly. |
| 55 | + |
| 56 | +To see all the options for this command, type, |
| 57 | + |
| 58 | +.. code-block:: bash |
| 59 | +
|
| 60 | + labpdfproc mud -h |
| 61 | +
|
| 62 | +To run the correction, specify the path to your diffraction data file(s) and the muD value, |
| 63 | + |
| 64 | +.. code-block:: bash |
| 65 | +
|
| 66 | + labpdfproc mud <diffraction-data-file.xy> <mud> |
| 67 | + labpdfproc mud zro2_mo.xy 2.5 |
| 68 | +
|
| 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. |
| 73 | + |
| 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, |
| 76 | + |
| 77 | +.. code-block:: bash |
| 78 | +
|
| 79 | + labpdfproc mud zro2_mo.xy 2.5 -w 0.71303 |
| 80 | + labpdfproc mud zro2_mo.xy 2.5 -w Mo |
| 81 | +
|
| 82 | +This will then save the corrected file in the same directory as the input file with the name ``zro2_mo_corrected.chi``. |
| 83 | + |
| 84 | +To save the correction file, specify the ``-c`` or ``--output-correction`` flag, |
| 85 | + |
| 86 | +.. code-block:: bash |
| 87 | +
|
| 88 | + labpdfproc mud zro2_mo.xy 2.5 -w 0.71303 -c |
| 89 | +
|
| 90 | +This will then save the correction file in the same directory as the input file with the name ``zro2_mo_cve.chi``. |
| 91 | + |
| 92 | +``labpdfproc zscan`` Command |
| 93 | +---------------------------- |
| 94 | + |
| 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. |
| 98 | + |
| 99 | +To see the options for this command, type, |
| 100 | + |
| 101 | +.. code-block:: bash |
| 102 | +
|
| 103 | + labpdfproc zscan -h |
| 104 | +
|
| 105 | +To run this command, provide the path to your diffraction data file(s) and the z-scan file, |
| 106 | + |
| 107 | +.. code-block:: bash |
| 108 | +
|
| 109 | + labpdfproc zscan <diffraction-data-file.xy> <zscan-file.xy> |
| 110 | + labpdfproc zscan CeO2_635um_accum_0.xy CeO2_635um_zscan.xy |
| 111 | +
|
| 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, |
| 114 | + |
| 115 | +.. code-block:: bash |
| 116 | +
|
| 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