# Results Files Documentation

This page provides an overview of the output files generated by the **WPEM** software for diffraction refinement, background fitting, amorphous component analysis, solid solution modeling, and simulation tasks.

---

## General Information

All results are saved in the **working directory** (`work_dir`), which can be specified by the user during execution. If not specified, outputs default to the current directory.

### File Naming Conventions

* **Prefix**: Indicates the task type (e.g., `XRD`, `Background`, `Amorphous`, etc.).
* **Suffix**: Usually includes a timestamp to prevent file overwriting.

---

## Output Files by Function

### 1. **Background Fitting**

**Folder**: `ConvertedDocuments`

* `bac.csv`: Fitted background intensities.
* `no_bac_intensity.csv`: Diffraction signals after background removal.
* `bac_points.csv`: Selected background points.
* `intensity_fft.csv`: Diffraction signals processed by Fast Fourier Transform.
* `de_backgroundfittingcurve.png`: Plot of the original data, fitted background, and background-subtracted signals.
* `backgroundfittingcurve.png`: Visualization showing the raw data, selected background points, and the fitted background curve.

---

### 2. **XRD Refinement**

**Folder**: `WPEMFittingResults`

* `CrystalSystem0_WPEMout_<time>.csv`: Refined crystal information, including:

  * `code`: Indicates Kα1 or Kα2 origin.
  * `H`, `K`, `L`: Miller indices.
  * `wi`, `Ai`, `L_gamma_i`, `G_sigma2_i`: Peak shape parameters (refer to the WPEM paper for details).
  * `mu_i`: Peak positions.
  * `intensity`: Peak intensities.
  * `system0`, `system1`, etc.: Refers to different phases.
* `hkl0_<time>.csv`: Diffraction indices for each peak in phase 0.
* `WPEMfittingProfile_<time>.csv`: WPEM-generated fitting profile.
* `WPEMPeakParas_<time>.csv`: Peak location and shape parameters, with profile fitting quality metrics.
* `ResidualWPEM_fittingresult_<time>.png`: Plot comparing fitted results with experimental data.

---

### 3. **Amorphous Fitting**

**Folder**: `DecomposedComponents`

* `Amorphous.csv`: Extracted amorphous signals.
* `M_Amorphous_componentsX.csv`: Identified amorphous peak components (X = index).
* `upbackground.csv`: Updated background after amorphous subtraction.
* `Decomposed_peaks.png`: Visualization of decomposed crystalline and amorphous components.

---

### 4. **CIF Parsing**

**Folder**: `output_xrd`

* `NAMEHKL.csv`: Calculated diffraction indices, angles, and theoretical intensities.
* `NAME_Extinction_peak.csv`: List of extinction peaks caused by geometrical and systematic extinction.

---

### 5. **Solid Solution Modeling**

**Folder**: `WPEMSitOpt`

* `substitutional.png`: Fitting result of the optimized solid solution structure.
* `DecompositionPlot.png`: Overlay of decomposed peaks and experimental data.

---

### 6. **XRD Simulation**

**Function**: `XRDSimulation`

* `Simulated_XRDPattern.csv`: Simulated XRD pattern based on the provided CIF file.
* `SimulatedPeaks.csv`: Simulated peak positions and intensities.
* `SimulationPlot.png`: Visualization of the simulated XRD pattern.

---

### 7. **CIF Preprocessing**

**Function**: `CIFpreprocess`

* `Processed_CIF_LatticeConstants.csv`: Extracted lattice constants from CIF.
* `Processed_CIF_Structure.csv`: Atomic positions and unit cell parameters.
* `ProcessedCIFPlot.png`: Visualization of the crystal structure.

---

### 8. **Substitutional Search**

**Function**: `SubstitutionalSearch`

* `SubstitutionalSearchResults.csv`: Possible substitutional configurations and their likelihoods.

---

### 9. **XPS Analysis**

**Folder**: `XPSFittingProfile`

* `XPSfittingProfile_<time>.csv`: Fitted XPS spectrum data.
* `XPSPeakParas_<time>.csv`: Peak parameters including binding energies, areas, shapes, and fitting quality.
* `WPEM_fittingresult.png`: Decomposed results of individual photoelectron peaks.

---

### 10. **EXAFS Analysis**

**Folder**: `XAFS` / `WXAFS`

* `FFT_EXAFS_unknown.png`: Radial distribution function representing local atomic structure.
* `interactive_plot.html`: Interactive 2D wavelet transform visualization.

---

## Notes

* All files are saved with descriptive names based on their function and timestamp.
* Figures are generated in `.png` format for easy interpretation.
* CSV files are widely compatible with data analysis tools such as Excel, Python, and MATLAB.

For further reference and source code, please visit the [WPEM GitHub Repository](https://github.com/Bin-Cao/PyWPEM).