# diffpy/diffpy.labpdfproc architecture

> Architecture diagram of the GitHub repository diffpy/diffpy.labpdfproc, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/diffpy/diffpy.labpdfproc
- Repository: https://github.com/diffpy/diffpy.labpdfproc

## Overview

diffpy.labpdfproc preprocesses laboratory powder X-ray diffraction data by estimating or accepting μ·D, computing a cylindrical-volume absorption correction, and saving corrected patterns. The principal workflow enters through the CLI or Gooey GUI, normalizes arguments and metadata, loads each diffraction pattern, computes and applies its correction, then writes output files. Separate correction modes support a supplied μ·D, a z-scan, or sample composition and density. The graph reflects relationships visible in the excerpts and README; data-loading details and some implementation paths were not sampled.

Main entry points: [`src/diffpy/labpdfproc/labpdfprocapp.py`](https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/labpdfprocapp.py) (CLI / GUI app), [`src/diffpy/labpdfproc/tools.py`](https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/tools.py) (μ·D estimation), [`src/diffpy/labpdfproc/functions.py`](https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/functions.py) (CVE calculation), [`src/diffpy/labpdfproc/__init__.py`](https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/__init__.py) (Package API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User entry"]
  node_app["CLI / GUI app<br/>[labpdfprocapp.py]"]
end

subgraph group_prep["Inputs and estimates"]
  node_preprocess["Argument preprocessing<br/>[tools.py]"]
  node_inputdata["Diffraction files"]
  node_mud["μ·D estimation<br/>[tools.py]"]
  node_zscan["Z-scan input"]
  node_sample["Sample properties"]
  node_utils["diffpy.utils"]
  node_parser["Diffraction parser"]
end

subgraph group_correction["Absorption correction"]
  node_cve["CVE calculation<br/>[functions.py]"]
  node_datasets[("Interpolation datasets")]
  node_apply["Correction application<br/>[functions.py]"]
  node_outputs["Corrected data files"]
  node_correctionfile["Optional correction file"]
end

subgraph group_package["Package API"]
  node_version["Package version<br/>[version.py]"]
  node_packageapi["Package API<br/>[__init__.py]"]
end

node_user(("Researcher"))

node_user -->|"runs"| node_app
node_app -->|"preprocesses"| node_preprocess
node_app -->|"loads patterns"| node_parser
node_preprocess -->|"sets μ·D"| node_mud
node_mud -->|"reads scan"| node_zscan
node_mud -->|"uses properties"| node_sample
node_mud -->|"estimates μ·D"| node_utils
node_parser -->|"reads"| node_inputdata
node_app -->|"computes CVE"| node_cve
node_cve -->|"uses data"| node_datasets
node_app -->|"applies correction"| node_apply
node_app -->|"saves corrected"| node_outputs
node_app -->|"may save"| node_correctionfile
node_packageapi -->|"exports version"| node_version

click node_app "https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/labpdfprocapp.py"
click node_preprocess "https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/tools.py"
click node_mud "https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/tools.py"
click node_cve "https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/functions.py"
click node_datasets "https://github.com/diffpy/diffpy.labpdfproc/tree/main/src/diffpy/labpdfproc/data"
click node_apply "https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/functions.py"
click node_version "https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/version.py"
click node_packageapi "https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/__init__.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app toneBlue
class node_preprocess,node_inputdata,node_mud,node_zscan,node_sample,node_utils,node_parser toneAmber
class node_cve,node_datasets,node_apply,node_outputs,node_correctionfile toneMint
class node_version,node_packageapi toneRose
class node_user toneIndigo
```

## Components

### User entry

- [CLI / GUI app](https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/labpdfprocapp.py): `src/diffpy/labpdfproc/labpdfprocapp.py`

### Inputs and estimates

- [Argument preprocessing](https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/tools.py): `src/diffpy/labpdfproc/tools.py`
- **Diffraction files**
- [μ·D estimation](https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/tools.py): `src/diffpy/labpdfproc/tools.py`
- **Z-scan input**
- **Sample properties**
- **diffpy.utils**
- **Diffraction parser**

### Absorption correction

- [CVE calculation](https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/functions.py): `src/diffpy/labpdfproc/functions.py`
- [Interpolation datasets](https://github.com/diffpy/diffpy.labpdfproc/tree/main/src/diffpy/labpdfproc/data): `src/diffpy/labpdfproc/data`
- [Correction application](https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/functions.py): `src/diffpy/labpdfproc/functions.py`
- **Corrected data files**
- **Optional correction file**

### Package API

- [Package version](https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/version.py): `src/diffpy/labpdfproc/version.py`
- [Package API](https://github.com/diffpy/diffpy.labpdfproc/blob/main/src/diffpy/labpdfproc/__init__.py): `src/diffpy/labpdfproc/__init__.py`

### Other components

- **Researcher**

## Connections

- Researcher → CLI / GUI app: runs (evidence: `README.rst`)
- CLI / GUI app → Argument preprocessing: preprocesses (evidence: `src/diffpy/labpdfproc/labpdfprocapp.py`)
- CLI / GUI app → Diffraction parser: loads patterns (evidence: `src/diffpy/labpdfproc/labpdfprocapp.py`)
- Argument preprocessing → μ·D estimation: sets μ·D (evidence: `src/diffpy/labpdfproc/tools.py`)
- μ·D estimation → Z-scan input: reads scan (evidence: `src/diffpy/labpdfproc/tools.py`)
- μ·D estimation → Sample properties: uses properties (evidence: `src/diffpy/labpdfproc/tools.py`)
- μ·D estimation → diffpy.utils: estimates μ·D (evidence: `src/diffpy/labpdfproc/tools.py`)
- Diffraction parser → Diffraction files: reads
- CLI / GUI app → CVE calculation: computes CVE (evidence: `src/diffpy/labpdfproc/labpdfprocapp.py`)
- CVE calculation → Interpolation datasets: uses data (evidence: `src/diffpy/labpdfproc/functions.py`)
- CLI / GUI app → Correction application: applies correction (evidence: `src/diffpy/labpdfproc/labpdfprocapp.py`)
- CLI / GUI app → Corrected data files: saves corrected (evidence: `src/diffpy/labpdfproc/labpdfprocapp.py`)
- CLI / GUI app → Optional correction file: may save (evidence: `src/diffpy/labpdfproc/labpdfprocapp.py`)
- Package API → Package version: exports version (evidence: `src/diffpy/labpdfproc/__init__.py`)
