---
jupytext:
  formats: md:myst
  text_representation:
    extension: .md
    format_name: myst
    format_version: 0.13
    jupytext_version: 1.11.5
kernelspec:
  display_name: Python 3
  language: python
  name: python3
---

# The tutorial 8th 

Describes how PyXplore processes X-ray photoelectron spectroscopy (XPS) data.

## coding

> **1. Save your XPS data to the root directory and rename the file to `int.csv`.**




```{code-cell}
# import PyXplore package
from PyXplore import WPEM
import pandas as pd
```

> **2. Parse your diffraction data (`bing energy`, intensity) and perform background processing.**

```{code-cell}
intensity_csv = pd.read_csv(r'int.csv',header=None )
var = WPEM.BackgroundFit(intensity_csv,segement=[[910,931],[948,952],[958,959],[966,970]],bac_num=120,Model='XPS',noise = 0.05,bac_var_type='multivariate gaussian')
```

> **3. After running the code, a new folder named `ConvertedDocuments` will be created in the root directory. This folder contains the background information.**

> **Copy the two important files — `bac.csv` and `no_bac_intensity.csv` — from `ConvertedDocuments` into the root directory, as they are required for the next steps.**

```{seealso}
A key difference with XPS is that the initial binding energy needs to be queried and input using two parameters: `AtomIdentifier` and `satellitePeaks`.**
```



```{code-cell}

AtomIdentifier = [['CuII','2p3/2',933.7,],['CuII','2p1/2',954,],]
satellitePeaks = [['CuII', '2p3/2',941.6,],['CuII','2p3/2',943.4],['CuII','2p1/2',962.5,],]
# The file name of non-background data 
no_bac_intensity_file = "no_bac_intensity.csv" 
# The file name of raw/original data 
original_file = "int.csv"  
# The file name of background data 
bacground_file = "bac.csv"  

# Execute the model
WPEM.XPSfit(
        var, AtomIdentifier, satellitePeaks,no_bac_intensity_file, original_file, bacground_file, 
    bta = 0.80,iter_max = 50,
)

```



> **The results are saved in the `XPSFittingProfile` folder.**