Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

50 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

YCP Grease Analyzer - FTIR Deviation Analysis System

🎯 Overview

Production-ready FTIR spectroscopy analysis tool for grease condition monitoring. Uses a deviation-focused approach that reports factual spectral differences (Ξ”X, Ξ”Y) rather than quality scores.

Key Features

βœ… Pure Deviation Analysis - Reports WHERE spectra differ (Ξ”X, Ξ”Y metrics)
βœ… Multi-Metric Categorization - Combines correlation + Ξ”X + Ξ”Y + ratio
βœ… Fast Performance - <1 second per sample
βœ… Baseline Compatibility - Detects formulation mismatches
βœ… AI Translation - Optional LLM for user-friendly language (NOT quality judgments)
βœ… PyQt6 GUI - Interactive desktop application
βœ… Batch Analysis - Process multiple samples efficiently


πŸ—οΈ System Architecture

CSV Files β†’ Deviation Analyzer β†’ Multi-Metric Categorization β†’ Optional LLM Translation
            (Ξ”X, Ξ”Y, correlation)   (GOOD/CRITICAL/MISMATCH)    (User-friendly summary)

Two Analysis Engines:

  1. FTIRDeviationAnalyzer (PRIMARY)

    • Pure deviation metrics (Ξ”X, Ξ”Y)
    • Multi-metric categorization
    • No quality judgments
    • Always reliable (<1s)
  2. FTIRPeakAnalyzer (LEGACY)

    • Peak detection
    • Quality recommendations
    • Kept for backward compatibility

πŸš€ Quick Start

Installation

# Clone repository
git clone https://github.com/JinLeeGG/YCP_Grease_Analyzer.git
cd YCP_Grease_Analyzer

# Install dependencies
pip install -r requirements.txt

Run Application

python app.py

Basic Usage

  1. Load Baseline - Click "Select Baseline CSV"
  2. Load Samples - Click "Select Sample CSV(s)" (multiple files OK)
  3. View Results - Analysis runs automatically
  4. Export - Save graphs and reports

πŸ“Š Understanding Results

Multi-Metric Categories

Category Meaning Action
βœ… GOOD Minimal deviations Continue operation
⚠️ REQUIRES_ATTENTION Minor deviations Monitor trends
❌ CRITICAL Significant deviations Investigate cause
🚨 OUTLIER Major differences Check for contamination
⚑ BASELINE_MISMATCH Different formulation Verify baseline selection

Key Metrics

Ξ”Y (Vertical Deviation)

  • Intensity difference at same wavenumber
  • Thresholds: <0.03A (OK), 0.05-0.10A (major), >0.10A (critical)

Ξ”X (Horizontal Shift)

  • Peak position change
  • Thresholds: <5cm⁻¹ (OK), 5-10cm⁻¹ (minor), >10cm⁻¹ (major)

Ξ”X:Ξ”Y Ratio

  • 100: Shift-dominant (chemical change)

  • <20: Intensity-dominant (degradation/concentration)
  • 20-100: Both types of deviation

Correlation (r)

  • β‰₯0.97: Excellent similarity
  • 0.85-0.97: Good to moderate
  • <0.85: Poor (possible mismatch)

πŸ“‚ Project Structure

YCP_Grease_Analyzer/
β”œβ”€β”€ app.py                          # Main PyQt6 GUI application
β”œβ”€β”€ requirements.txt                # Python dependencies
β”œβ”€β”€ modules/
β”‚   β”œβ”€β”€ ftir_deviation_analyzer.py  # PRIMARY: Deviation analysis
β”‚   β”œβ”€β”€ ftir_peak_analyzer.py       # LEGACY: Peak detection
β”‚   β”œβ”€β”€ llm_analyzer.py             # LLM integration (optional)
β”‚   β”œβ”€β”€ csv_processor.py            # CSV data handling
β”‚   β”œβ”€β”€ graph_generator.py          # Matplotlib plotting
β”‚   └── peak_detector.py            # Legacy peak detection
β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ config.py                   # Configuration settings
β”‚   └── validators.py               # Data validation
β”œβ”€β”€ GUI/
β”‚   β”œβ”€β”€ Analyzer_main.ui            # Main window UI
β”‚   └── path.ui                     # Path selection dialog
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ FINAL_SYSTEM_SUMMARY.md     # Complete system documentation
β”‚   └── (other documentation)
└── tests/
    β”œβ”€β”€ test_csv_loader.py
    └── test_llm.py

πŸ”§ Configuration

Adjust Deviation Thresholds

# In modules/ftir_deviation_analyzer.py
config = DeviationConfig()

# Vertical deviation (Ξ”Y)
config.delta_y_critical = 0.10  # A (absorbance units)
config.delta_y_major = 0.05
config.delta_y_minor = 0.03

# Horizontal shift (Ξ”X)
config.delta_x_major = 10.0     # cm⁻¹
config.delta_x_minor = 5.0

# Correlation thresholds
config.correlation_excellent = 0.97
config.correlation_good = 0.95

LLM Configuration (Optional)

# In utils/config.py
LLM_CONFIG = {
    "enabled": True,
    "model": "llava:7b-v1.6",  # Ollama model
    "timeout": 30
}

To use LLM features:

# Install Ollama
winget install Ollama.Ollama

# Pull model
ollama pull llava:7b-v1.6

πŸŽ“ Critical Regions Monitored

Region Wavenumber (cm⁻¹) Chemical Feature Purpose
Carbonyl Oxidation 1650-1800 C=O stretch Primary oxidation marker
Water Contamination 3200-3600 O-H stretch Water ingress
Additives/Glycol 1000-1300 C-O stretch Additive changes
C-H Stretch 2850-2950 C-H bonds Base oil reference

πŸ“ˆ Performance

Metric Value Notes
Analysis time <1s Deviation analyzer
With LLM 5-15s Optional enhancement
Accuracy High Statistical thresholds
Reliability 100% No external dependencies for core analysis

πŸ› Troubleshooting

Common Issues

Problem: Too many false positives

  • Solution: Increase deviation thresholds in DeviationConfig

Problem: BASELINE_MISMATCH errors

  • Solution: Verify you're comparing the same grease type

Problem: LLM not working

  • Solution: LLM is optional - system works without it
  • Check Ollama installation: ollama --version

Problem: Slow performance

  • Solution: Disable LLM for batch processing
  • Check data file size (should be <10K points)

πŸ“š Documentation


🎯 Key Philosophy

"The deviation analyzer does the math; AI makes it human-friendly"

  • System reports FACTS (Ξ”X, Ξ”Y, correlation)
  • AI translates to plain language (optional)
  • You make decisions based on facts + your expertise

πŸ”„ Updates & Version History

v2.1 - Improved Categorization Logic (Current)

  • βœ… Smart BASELINE_MISMATCH detection - Distinguishes different formulations from contamination
  • βœ… Degradation pattern recognition - Identifies oxidation + water signature
  • βœ… Systematic vs localized deviation analysis - Better context-aware decisions
  • βœ… Actionable warnings - "Use baseline from same grease family"
  • πŸ“š See IMPROVED_CATEGORIZATION_SUMMARY.md for details

v2.0 - Deviation-Focused Implementation

  • βœ… Pure deviation metrics (Ξ”X, Ξ”Y)
  • βœ… Multi-metric categorization
  • βœ… Ξ”X now triggers alerts
  • βœ… Ξ”X:Ξ”Y ratio diagnostic
  • βœ… Baseline mismatch detection

v1.0 - Peak Detection System (Legacy)

  • Peak-based analysis
  • Quality recommendations
  • Still available for compatibility

πŸ“„ License

See LICENSE file for details.


πŸ‘₯ Contributors

  • Development: YCP Lab
  • System Design: Based on FTIR spectroscopy best practices
  • AI Integration: Claude Sonnet 4.5 consultation

πŸ”— Related Resources

  • FTIR Spectroscopy Principles
  • Grease Analysis Standards
  • PyQt6 Documentation

Last Updated: November 9, 2025
Version: 2.1 - Improved Categorization Logic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages