近红外光谱建模之光谱预处理python实现(一)

目录

1 原始光谱

2 中心化处理

3 标准化处理


1 原始光谱

import numpy as np
import matplotlib.pyplot as plt
import scipy.io as sio


def PlotSpectrum(spec):
    """
    :param spec: shape (n_samples, n_features)
    :return: plt
    """

    plt.figure(figsize=(5.2, 3.1), dpi=300)
    x = np.arange(400, 400 + 2 * spec.shape[1], 2)
    for i in range(spec.shape[0]):
        plt.plot(x, spec[i, :], linewidth=0.6)

    fonts = 8
    plt.xlim(350, 2550)
    # plt.ylim(0, 1)
    plt.xlabel('Wavelength (nm)', fontsize=fonts)
    plt.ylabel('absorbance (AU)', fontsize=fonts)
    plt.yticks(fontsize=fonts)
    plt.xticks(fontsize=fonts)
    plt.tight_layout(pad=0.3)
    plt.grid(True)
    return plt


mat = sio.loadmat('ndfndf.mat')
data = mat['ndfndf']
x, y = data[:, :1050], data[:, 1050]
print(x.shape,
评论 43
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值