Skip to content

Leonardo-Razzai/XPSAnlayzer

Repository files navigation

XPS Data Analysis Module

Overview

This module provides tools for analyzing and visualizing X-ray Photoelectron Spectroscopy (XPS) data. It enables users to:

  • Load spectra from .TXT files (exported from measurement instruments).
  • Extract peaks within user-defined energy ranges.
  • Subtract background from peaks.
  • Integrate peak areas.
  • Smooth data.
  • Find peak positions via polynomial fitting.
  • Plot raw and corrected spectra.

The module is organized into two main classes:

  • Component → Represents a spectrum (entire dataset for one element or orbital).
  • Peak → Represents a specific spectral peak within a Component.

Installation

Requirements

The following Python packages are required:

  • pandas
  • numpy
  • matplotlib
  • scipy

Install them with:

pip install pandas numpy matplotlib scipy

File Structure

The module expects input data files in the following format:

data/
 ├── AM25_<component_name>.TXT

Where <component_name> is the name passed to the Component class. Each .TXT file must be tab-delimited with a header of 4 lines, followed by columns:

KE    BE    CPS    Background

Usage

Importing the Module

from xps_module import Component

Loading a Spectrum

# Load an XPS spectrum (e.g., Oxygen 1s)
comp = Component("O1s")

Plotting the Spectrum

comp.plot_BE(title="O1s Spectrum")

Selecting Peaks

# Define peaks by specifying energy intervals (in eV)
comp.select_peaks([(528, 534)])

# Access the first peak
peak = comp.peaks[0]

Background Subtraction

# Subtract background using intervals outside the peak
peak.subtract_background([(528, 529), (533, 534)], deg=1, plot=True)

Integration

peak.integrate()
print("Integrated area:", peak.Integral)

Smoothing

peak.smooth(deg=5)

Peak Position

peak.find_peak_position((529, 532))
print("Peak position:", peak.peak_pos)
print("Peak height:", peak.height)

Plotting

peak.plot_raw_spectrum()
peak.plot_corrected_spectrum(title="Corrected O1s Spectrum")

API Reference

class Component

Represents a full XPS spectrum.

  • __init__(componenet_name: str) Loads spectrum from data/AM25_<component_name>.TXT.

  • select_peaks(intervals, energy_scale='BE') Extracts peaks from the spectrum.

    • intervals: list of (min_energy, max_energy)
    • energy_scale: "BE" (default) or "KE"
  • plot_BE(title='BE spectrum') Plots the binding energy spectrum.


class Peak

Represents an individual peak extracted from a Component.

  • subtract_background(intervals, deg=1, plot=False) Fits polynomial background using side intervals and subtracts it.

  • integrate() Computes integrated peak area.

  • smooth(deg=3) Smooths spectrum via moving average.

  • find_peak_position(interval) Estimates peak position and height with quadratic fit.

  • plot_raw_spectrum() Plots the original (uncorrected) spectrum.

  • plot_corrected_spectrum(title) Plots spectrum after background subtraction.


Example Workflow

# Load spectrum
comp = Component("O1s")

# Select region of interest
comp.select_peaks([(528, 534)])
peak = comp.peaks[0]

# Background subtraction
peak.subtract_background([(528, 529), (533, 534)], plot=True)

# Integration
peak.integrate()
print("Area under peak:", peak.Integral)

# Peak position
peak.find_peak_position((529, 532))
print("Peak at", peak.peak_pos, "eV with height", peak.height)

# Plot final result
peak.plot_corrected_spectrum("Corrected O1s Spectrum")

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors