Skip to content

Conversation

@cadenmyers13
Copy link
Contributor

I wanted to get this PR in before the weekend, so apologies for the sloppy commits. This PR improves the UX of labpdfproc. It breaks it into 3 subcommands mud, zscan, and sample. These commands do the following

$ labpdfproc -h
usage: labpdfproc [-h] {mud,zscan,sample} ...

Apply absorption corrections to laboratory X-ray diffraction data prior to PDF analysis. Supports manual mu*d, z-scan, or sample-based corrections.

options:
  -h, --help          show this help message and exit

Correction method:
  {mud,zscan,sample}
    mud               Correct diffraction data using known mu*d value
    zscan             Correct diffraction data using a z-scan measurement
    sample            Correct diffraction data using sample composition/density

mud command

$ labpdfproc mud -h
usage: labpdfproc mud [-h] [-w WAVELENGTH] [-x XTYPE] [-m {brute_force,polynomial_interpolation}] [-o OUTPUT_DIRECTORY] [-f] [-c] [-u KEY=VALUE [KEY=VALUE ...]]
                      [--username USERNAME] [--email EMAIL] [--orcid ORCID]
                      input [input ...] mud

positional arguments:
  input                 Input X-ray diffraction data file(s) or directory. Can specify multiple files, directories, or use wildcards.
  mud                   mu*d value

zscan command

$ labpdfproc zscan -h
usage: labpdfproc zscan [-h] [-w WAVELENGTH] [-x XTYPE] [-m {brute_force,polynomial_interpolation}] [-o OUTPUT_DIRECTORY] [-f] [-c] [-u KEY=VALUE [KEY=VALUE ...]]
                        [--username USERNAME] [--email EMAIL] [--orcid ORCID]
                        input [input ...] z_scan_file

positional arguments:
  input                 Input X-ray diffraction data file(s) or directory. Can specify multiple files, directories, or use wildcards.
  z_scan_file           Z-scan measurement file. See diffpy.labpdfproc documentation for more information.

sample command

$ labpdfproc sample -h
usage: labpdfproc sample [-h] [-w WAVELENGTH] [-x XTYPE] [-m {brute_force,polynomial_interpolation}] [-o OUTPUT_DIRECTORY] [-f] [-c] [-u KEY=VALUE [KEY=VALUE ...]]
                       [--username USERNAME] [--email EMAIL] [--orcid ORCID]
                       input [input ...] sample_composition sample_mass_density diameter

positional arguments:
input                 Input X-ray diffraction data file(s) or directory. Can specify multiple files, directories, or use wildcards.
sample_composition    Chemical formula, e.g. Fe2O3
sample_mass_density   Sample mass density in capillary (g/cm^3). If unsure, a good estimate is ~1/3 of the theoretical packing fraction density.
diameter              Outer diameter of the capillary in mm

All commands have the same following options

options:
  -h, --help            show this help message and exit
  -w, --wavelength WAVELENGTH
                        X-ray wavelength in angstroms (numeric) or X-ray source name (allowed: Ag, AgKa1, AgKa1Ka2, Cu, CuKa1, CuKa1Ka2, Mo, MoKa1, MoKa1Ka2). Will be loaded
                        from config files if not specified.
  -x, --xtype XTYPE     X-axis type (default: tth). Allowed values: angle, tth, twotheta, 2theta, d, dspace, q
  -m, --method {brute_force,polynomial_interpolation}
                        Method for cylindrical volume element (CVE) calculation (default: polynomial_interpolation). Allowed methods: brute_force, polynomial_interpolation
  -o, --output-directory OUTPUT_DIRECTORY
                        Directory to save corrected files (created if needed). Defaults to current directory.
  -f, --force           Overwrite existing files
  -c, --output-correction
                        Also output the absorption correction to a separate file
  -u, --user-metadata KEY=VALUE [KEY=VALUE ...]
                        Specify key-value pairs to be loaded into metadata using the format key=value. Separate pairs with whitespace, and ensure no whitespaces before or
                        after the = sign. Avoid using = in keys. If multiple = signs are present, only the first separates the key and value. If a key or value contains
                        whitespace, enclose it in quotes. For example, facility='NSLS II', 'facility=NSLS II', beamline=28ID-2, 'beamline'='28ID-2', 'favorite color'=blue, are
                        all valid key=value items.
  --username USERNAME   Your name (optional, for dataset credit). Will be loaded from config files if not specified.
  --email EMAIL         Your email (optional, for dataset credit). Will be loaded from config files if not specified.
  --orcid ORCID         Your ORCID ID (optional, for dataset credit). Will be loaded from config files if not specified.

Additional changes

  • I removed the --anode-type and merged it with --wavelength. If the user wants to specify an anode type, they still can. They just use the --wavelength option (ie --wavelength Mo) and the code recognizes this. I felt as if this made the code smoother.
  • I removed the ability to calculate mu*d from packing fraction and just added the help message that density can be approximated with 0.3 x theoretical packing. We can add this back though if we like. I left the function there.

Gooey interface

With this change, the gui now is separated nicely into its three subcommands.
Screenshot 2026-01-23 at 6 04 56 PM

@cadenmyers13
Copy link
Contributor Author

@sbillinge This is ready for review/discussion if you find some time this weekend. Im marking this as a draft for now so i can come back monday with a clearer head. Also the merge conflict looks to be because of some re-skpkging work. Just wanted to get this to you if you have any comments.

@cadenmyers13 cadenmyers13 marked this pull request as draft January 23, 2026 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant