Automated analysis toolkit for semiconductor device characterization data (IV/ITS measurements)
This repository provides end-to-end processing of raw measurement CSV files from lab experiments, extracting metadata, organizing data, and generating publication-ready plots with consistent styling.
- Features
- Quick Start
- Installation
- Usage
- Project Structure
- Data Format
- Plotting Capabilities
- Configuration
- Troubleshooting
β Automated metadata extraction from CSV headers β Session-based grouping (IVg β ITS... β IVg blocks) β Multi-chip processing with organized output structure β Publication-ready plots with 10+ custom matplotlib styles β Timeline generation for experiment chronology β Animated GIFs for IVg sequences β Wavelength-dependent photoresponse analysis β Flexible baseline correction (raw data, t=0, fixed time, or auto from LED period) β Baseline-corrected delta plots (ΞI vs time)
# Install dependencies
pip install -r requirements.txt
# Launch the interactive plotting assistant
python tui_app.py
# Follow the wizard: Select chip β plot type β experiments β generate!π¨ Beautiful guided interface with keyboard navigation, real-time progress, and interactive experiment selection.
# Clone and setup
git clone <repo-url>
cd python-lab
pip install -r requirements.txt
# Process all experiments
python src/process_all.py --raw raw_data --meta metadata
# Figures saved to: figs/<day>/<chip>/IVg|ITS/...- Python 3.10+
- Dependencies listed in
requirements.txt
# Create virtual environment (recommended)
python3 -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txtKey Dependencies:
polars- Fast dataframe operationsnumpy- Numerical computingmatplotlib+scienceplots- Plotting and stylingimageio+Pillow- GIF generationtextual- Terminal user interface (TUI)
python tui_app.py8-Step Wizard:
- Main Menu - Choose action (New Plot / Recent Configs / Process Data)
- Chip Selection - Auto-discover chips from metadata
- Plot Type - ITS / IVg / Transconductance
- Config Mode - Quick (defaults) or Custom (full control)
- Configuration - Select experiments or customize parameters
- Preview - Review all settings before generating
- Generation - Real-time progress tracking
- Success - View results, plot another, or exit
New Features:
- πΎ Configuration Persistence - Auto-save successful plots, load from Recent Configs
- β‘ Quick Mode - Smart defaults for fast plotting
- ποΈ Custom Mode - Full parameter control (filters, baseline, legend, savgol params)
- π€ Export/Import - Share configurations as JSON files
π Full guide: See TUI_GUIDE.md for keyboard shortcuts, config persistence, and troubleshooting.
Complete Pipeline (Recommended):
# Parse all raw data + generate chip histories in one command
python process_and_analyze.py full-pipelineIndividual Commands:
# Parse metadata from raw CSVs
python process_and_analyze.py parse-all --raw raw_data --meta metadata
# Generate chip timeline histories
python process_and_analyze.py chip-histories --meta metadata --group Alisson
# View specific chip history
python process_and_analyze.py show-history 67 --meta metadata --group Alisson
# Generate plots
python process_and_analyze.py plot-its 67 --seq 52,57,58
python process_and_analyze.py plot-ivg 67 --seq 2,8,14
python process_and_analyze.py plot-transconductance 67 --seq 2,8,14 --method savgol
# Quick statistics
python process_and_analyze.py quick-stats --meta metadataπ Full CLI reference: See CLI_GUIDE.md for all commands and options.
Data Pipeline:
Raw CSVs β Metadata Extraction β Session Grouping β Figure Generation
β β β β
raw_data/ metadata.csv load_and_prepare figs/
Extract experimental parameters from raw CSV headers:
# Edit folder_name in src/parser.py first
python src/parser.pyOutput: <folder>_metadata.csv containing chip number, voltages, laser settings, timestamps, etc.
Alternative: Use mirrored directory structure
python src/parser.py --raw raw_data --out metadata
# Creates: metadata/<day>/metadata.csvGenerate all plots for one day's experiments:
# Edit configuration in src/process_day.py:
# - METADATA_CSV = "Alisson_15_sept_metadata.csv"
# - BASE_DIR = Path("raw_data")
# - CHIPS_TO_PROCESS = None # or [68, 72, 75]
python src/process_day.pyOutput structure:
figs/
βββ Chip72_2024_09_15/
βββ IVg/
β βββ sequence/ # Chronological IVg plots
β βββ pairs/ # Consecutive pairs
β βββ triplets/ # 3-measurement groups
β βββ gif/ # Animated sequences
β βββ transconductance/ # dI/dVg (gm) plots
βββ ITS/
βββ regular/ # I(t) at specific VG
βββ delta/ # ΞI(t) baseline-corrected
βββ overlays/ # Wavelength comparisons
Automatically discover and process all metadata files:
# Process everything
python src/process_all.py --raw raw_data --meta metadata
# Filter specific chips
python src/process_all.py --chips 68 75
# Skip GIFs or overlays
python src/process_all.py --no-gif --no-overlaysOpen Jupyter notebooks for custom exploration:
jupyter notebook encap72.ipynbExample notebook workflow:
from pathlib import Path
from src.plots import load_and_prepare_metadata, plot_ivg_sequence
from src.styles import set_plot_style
# Set plotting style
set_plot_style('prism_rain')
# Load data
meta = load_and_prepare_metadata('Alisson_15_sept_metadata.csv', chip=72)
# Generate plot
plot_ivg_sequence(meta, Path('raw_data'), tag='custom_analysis')python-lab/
βββ src/ # Core modules
β βββ parser.py # Metadata extraction
β βββ utils.py # Data reading & standardization
β βββ plots.py # Plotting functions
β βββ styles.py # Matplotlib themes
β βββ timeline.py # Chronological summaries
β βββ process_day.py # Single-day orchestrator
β βββ process_all.py # Batch processor
βββ raw_data/ # Raw CSV files
β βββ Alisson_04_sept/
β βββ Alisson_15_sept/
β βββ ...
βββ metadata/ # Extracted metadata (optional)
β βββ Alisson_15_sept/
β βββ metadata.csv
βββ figs/ # Generated figures (gitignored)
βββ *.ipynb # Interactive notebooks
βββ requirements.txt # Python dependencies
βββ CLAUDE.md # AI assistant guide
βββ README.md # This file
#Procedure: <laser_setup.procedures.It.It>
#Parameters:
# Chip number: 72
# VG: -3.0 V
# VDS: 0.1 V
# Laser voltage: 3.5 V
# Laser wavelength: 455.0 nm
# Laser ON+OFF period: 120 s
#Metadata:
# Start time: 1726394856.2
#Data:
t (s),I (A),VL (V),Plate T (degC),Ambient T (degC),Clock (ms)
0.0,7.23624e-06,0.0,nan,nan,nan
0.08,7.230252e-06,0.0,nan,nan,nan
...
| Column | Description |
|---|---|
Chip number |
Device identifier |
VG |
Gate voltage (V) |
VDS / VSD |
Source-drain voltage (V) |
Laser voltage |
Laser power setting (V) |
Laser wavelength |
Wavelength (nm) |
start_time |
Unix timestamp |
time_hms |
HH:MM:SS format |
source_file |
Path to raw CSV (relative to BASE_DIR) |
| Type | Description | Plot Type |
|---|---|---|
| IVg | Gate voltage sweep | Id vs Vg curves |
| ITS | Time series (photoresponse) | Id vs time with light ON/OFF |
| IV | Source-drain sweep | Id vs Vds |
- Sequence plots - Chronological overlay of all IVg measurements
- Pair/triplet comparisons - Consecutive measurements for drift tracking
- Animated GIFs - Cumulative overlay with frame-by-frame progression
- VG-filtered overlays - Time series at specific gate voltages
- Flexible baseline modes:
- Raw data - No correction,
_rawsuffix on filename - t=0 baseline - Subtract first visible point (avoids artifacts)
- Fixed time - Traditional interpolation at specific time
- Auto - Smart calculation from LED period metadata
- Raw data - No correction,
- Delta plots - Baseline-corrected ΞI(t) = I(t) - I(tβ)
- Wavelength comparison - Multi-wavelength photoresponse
- UV/blue vs longer wavelengths - Grouped spectral analysis
10+ custom matplotlib themes via set_plot_style():
prism_rain(default) - Vibrant colors, clean designsolar_flare- High-contrast warm tonesdark_nova- Dark background for presentationscryolab- Cool blues for cryogenic dataink_sketch- Black-and-white publication style
Edit src/process_day.py or src/process_all.py for:
# Metadata file
METADATA_CSV = "Alisson_15_sept_metadata.csv"
# Raw data location
BASE_DIR = Path("raw_data")
# Chip filter (None = all chips)
CHIPS_TO_PROCESS = [68, 72, 75]
# Optional outputs
GENERATE_GIFS = True
GENERATE_WAVELENGTH_OVERLAYS = Truefrom src.styles import set_plot_style
# Available styles:
# prism_rain, solar_flare, dark_nova, nova,
# super_nova, cryolab, deep_forest, ink_sketch
set_plot_style('solar_flare')The code automatically groups measurements into sessions:
Session 1: IVg (pre) β ITS β ITS β IVg (post)
Session 2: IVg (pre) β ITS β IVg (post)
- pre_ivg: Initial characterization
- its: Stress/photoresponse measurements
- post_ivg: Final characterization
Problem: Files not found, paths like raw_data/raw_data/...
Solution: process_all.py includes fix_source_paths() to normalize paths. Ensure source_file in metadata is relative to BASE_DIR.
Problem: KeyError: 'VG' or similar
Solution: Raw CSVs have variable column names. src/utils.py standardizes:
Gate V,gate voltageβVGVSD,VDS,drain-sourceβVSDI,ID,currentβI
Problem: Figures generated but no data plotted
Solution: Check:
- Chip number in metadata matches
CHIPS_TO_PROCESS source_filepaths are correct- CSV files exist in
BASE_DIR
Problem: imageio errors or blank frames
Solution: Ensure imageio>=2.28.0 and Pillow>=10.0.0 installed:
pip install --upgrade imageio PillowComplete example for processing new data:
# 1. Add raw CSVs to raw_data/Alisson_20_sept/
# 2. Generate metadata
# Edit src/parser.py: folder_name = "Alisson_20_sept"
python src/parser.py
# 3. Process all chips
# Edit src/process_day.py: METADATA_CSV = "Alisson_20_sept_metadata.csv"
python src/process_day.py
# 4. Review outputs
open figs/Chip72_2024_09_20/IVg/sequence/*.png
open figs/Chip72_2024_09_20/ITS/overlays/*.pngOr use the automated batch processor:
python src/process_all.py --raw raw_data --meta metadata --chips 72This is a research lab utility. For questions or improvements, contact the repository owner.
Internal use only. Contact owner for usage permissions.