Skip to content

Example 9: MCR-ALS (Multivariate Curve Resolution)

Resolving pure components from a mixture.

1. Setting up MCR-ALS

(Note: Requires pymcr or internal implementation)

import numpy as np
import spectrochempy as scp

# Assume 'dataset' contains the mixture data from Example 8

# Initialize MCR
# You typically need initial estimates (e.g., from EFA or purity)
# Here we just initialize blindly for demonstration or use PCA results

try:
    mcr = scp.MCRALS(n_components=2)
    mcr.fit(dataset)

    resolved_spectra = mcr.components
    resolved_concentrations = mcr.transform(dataset)

    # resolved_spectra.plot(title="Resolved MCR Spectra")
    print("MCR-ALS converged.")
except AttributeError:
    print("MCR-ALS might need an extension or specific import.")