Back to skills
SkillHub ClubAnalyze Data & AIFull StackData / AITesting

raman-fitting

This skill provides guidance for Raman spectrum peak fitting tasks. It should be used when analyzing spectroscopic data, fitting Lorentzian or Gaussian peaks to Raman spectra, or working with graphene/carbon material characterization. The skill emphasizes critical data parsing verification, physical constraints from domain knowledge, and systematic debugging of curve fitting problems.

Packaged view

This page reorganizes the original catalog entry around fit, installability, and workflow context first. The original raw source lives below.

Stars
782
Hot score
99
Updated
March 20, 2026
Overall rating
C4.3
Composite score
4.3
Best-practice grade
B77.6

Install command

npx @skill-hub/cli install benchflow-ai-skillsbench-raman-fitting

Repository

benchflow-ai/SkillsBench

Skill path: registry/terminal_bench_2.0/letta_skills_batch/terminal_bench_2_0_raman-fitting/environment/skills/raman-fitting

This skill provides guidance for Raman spectrum peak fitting tasks. It should be used when analyzing spectroscopic data, fitting Lorentzian or Gaussian peaks to Raman spectra, or working with graphene/carbon material characterization. The skill emphasizes critical data parsing verification, physical constraints from domain knowledge, and systematic debugging of curve fitting problems.

Open repository

Best for

Primary workflow: Analyze Data & AI.

Technical facets: Full Stack, Data / AI, Testing.

Target audience: everyone.

License: Unknown.

Original source

Catalog source: SkillHub Club.

Repository owner: benchflow-ai.

This is still a mirrored public skill entry. Review the repository before installing into production workflows.

What it helps with

  • Install raman-fitting into Claude Code, Codex CLI, Gemini CLI, or OpenCode workflows
  • Review https://github.com/benchflow-ai/SkillsBench before adding raman-fitting to shared team environments
  • Use raman-fitting for development workflows

Works across

Claude CodeCodex CLIGemini CLIOpenCode

Favorites: 0.

Sub-skills: 0.

Aggregator: No.

Original source / Raw SKILL.md

---
name: raman-fitting
description: This skill provides guidance for Raman spectrum peak fitting tasks. It should be used when analyzing spectroscopic data, fitting Lorentzian or Gaussian peaks to Raman spectra, or working with graphene/carbon material characterization. The skill emphasizes critical data parsing verification, physical constraints from domain knowledge, and systematic debugging of curve fitting problems.
---

# Raman Fitting

## Overview

This skill guides the analysis and curve fitting of Raman spectroscopy data, particularly for materials like graphene where characteristic peaks (G, D, 2D bands) must be accurately extracted. The primary challenge in these tasks is ensuring correct data ingestion before any analysis begins.

## Critical First Step: Data Parsing Verification

**Before any fitting or analysis, verify data is parsed correctly.** This is the most common source of failure in spectroscopic data analysis.

### Data File Inspection Protocol

1. **Read raw file content first** - Examine the first 5-10 lines of the raw data file to understand the actual format
2. **Identify potential format issues:**
   - Line number prefixes (e.g., "1→", "2→" before actual data)
   - Decimal separators (comma vs period - European vs US format)
   - Column delimiters (tab, comma, semicolon, whitespace)
   - Header lines that need to be skipped
   - Encoding issues (UTF-8, ISO-8859-1, etc.)

3. **Parse and print first few values** - After parsing, print the first 3-5 data points to verify they match expectations:
   ```python
   # Always verify parsing immediately
   print(f"First 5 wavenumbers: {wavenumbers[:5]}")
   print(f"First 5 intensities: {intensities[:5]}")
   print(f"Wavenumber range: {min(wavenumbers)} to {max(wavenumbers)} cm⁻¹")
   ```

4. **Sanity check against physical expectations:**
   - Raman wavenumbers typically range from 100-4000 cm⁻¹
   - If values fall outside this range, parsing is likely incorrect
   - Graphene G peak should appear near 1580 cm⁻¹
   - Graphene 2D peak should appear near 2700 cm⁻¹

### Common Parsing Pitfalls

| Issue | Example Raw Data | Correct Handling |
|-------|------------------|------------------|
| Line number prefix | `1→1580.5,12345` | Strip prefix before delimiter split |
| Comma decimal | `1580,5\t12345,7` | Replace comma with period |
| Mixed delimiters | `1580.5, 12345` | Handle both tab and comma |
| BOM character | `\ufeff1580.5` | Strip BOM from file start |

## Physical Constraints for Raman Spectroscopy

### Graphene/Carbon Materials

Apply these domain-specific constraints when fitting:

| Peak | Expected Position (cm⁻¹) | Typical Width (FWHM) | Physical Meaning |
|------|--------------------------|---------------------|------------------|
| D band | ~1350 | 20-50 | Defects/disorder |
| G band | ~1580 | 10-20 | sp² carbon vibration |
| 2D band | ~2700 | 25-60 | Second-order D band |
| D+G | ~2940 | 30-60 | Combination mode |

### Fitting Parameter Bounds

Set physically reasonable bounds to avoid nonsensical fits:

```python
# Example bounds for graphene G peak
bounds_lower = [1560, 5, 0]      # [x0, gamma, amplitude]
bounds_upper = [1600, 50, 1e6]

# Example bounds for graphene 2D peak
bounds_lower = [2650, 10, 0]
bounds_upper = [2750, 100, 1e6]
```

## Fitting Approach

### Step 1: Visual Identification of Peaks

Before fitting, identify peaks visually:
- Plot the full spectrum to see all features
- Note approximate peak positions and relative intensities
- Identify baseline behavior (flat, sloped, curved)

### Step 2: Baseline Correction

Consider baseline subtraction before peak fitting:
- Linear baseline for simple cases
- Polynomial baseline for curved backgrounds
- Iterative methods for complex baselines

### Step 3: Peak Function Selection

Common peak shapes for Raman:
- **Lorentzian**: Natural line shape, use when peaks are sharp
- **Gaussian**: Use when instrumental broadening dominates
- **Voigt**: Convolution of both, most physically accurate
- **Pseudo-Voigt**: Computationally efficient approximation

Lorentzian function:
```
I(x) = amplitude * (gamma²) / ((x - x0)² + gamma²)
```

### Step 4: Initial Parameter Estimation

Use visual inspection or automatic peak finding to set initial guesses:
```python
from scipy.signal import find_peaks

# Find peaks in the data
peaks, properties = find_peaks(intensity, height=threshold, distance=min_distance)

# Use found peak positions as initial guesses
for peak_idx in peaks:
    x0_guess = wavenumber[peak_idx]
    amplitude_guess = intensity[peak_idx]
```

### Step 5: Fitting and Validation

After fitting, validate results:
1. **Check R² value** - Should be > 0.95 for good fits
2. **Check parameter boundaries** - Parameters hitting bounds indicate problems
3. **Visual inspection** - Plot data with fitted curve overlay
4. **Physical plausibility** - Do fitted parameters make physical sense?

## Verification Strategies

### Red Flags That Indicate Problems

- **R² < 0.9**: Poor fit quality, investigate cause
- **Parameters at bounds**: Fit is constrained, not converged
- **Peak positions far from expected**: Data parsing or assignment error
- **Negative amplitudes**: Physically impossible, check data/model
- **Very large/small widths**: Outside physical expectations

### Systematic Debugging Checklist

1. [ ] Raw data file examined line by line
2. [ ] Parsing verified by printing first few values
3. [ ] Wavenumber range is physically reasonable (100-4000 cm⁻¹)
4. [ ] Peaks visible in plotted data at expected positions
5. [ ] Initial guesses based on actual data, not assumptions
6. [ ] Fit quality metrics (R², residuals) calculated and checked
7. [ ] Fitted parameters compared to literature values

### When Fits Fail

If fitting produces poor results:
1. **Go back to data parsing** - Most common source of error
2. **Narrow the fitting window** - Fit one peak at a time
3. **Improve initial guesses** - Use values closer to peak maximum
4. **Check for overlapping peaks** - May need multi-peak model
5. **Examine residuals** - Systematic patterns indicate model issues

## Output Format

When reporting fitted parameters, include:
- Peak position (x0) with uncertainty
- Width parameter (gamma or FWHM)
- Amplitude or integrated intensity
- Goodness of fit metric (R², chi-squared)
- Comparison to expected/literature values if available
raman-fitting | SkillHub