Python实现高斯曲线拟合
1.目的
针对光谱离散数据,寻峰完成后截取near峰值的数据,利用高斯拟合重绘单峰曲线,进而实现分峰功能

2.原理
在这里插入图片描述
在这里插入图片描述
3.代码

import numpy as np
from math import log, exp
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
from scipy import asarray as ar,exp
# 将txt文件读入numpy数组
yOriginal = np.loadtxt('C:\\工作\数据.txt')
#一维数据
#yOriginal = np.array([5.81528E-05, 0.000111682, 0.000271214, 0.000391546, 0.000786933, 0.002034528, 0.002968284, 0.005004177, 0.007329225, 0.011119662, 0.017025547, 0.02488255, 0.04219861, 0.040429801, 0.035320014, 0.05154864, 0.06894745,
     #                 0.105841984, 0.083166325, 0.110311517, 0.055681743, 0.093540639, 0.066621081, 0.056688568, 0.045128754, 0.045911571, 0.028179728, 0.021262112, 0.018781554, 0.008240159, 0.008562607, 0.004372914, 0.002847578, 0.001717186, 0.001081616])
xOriginal = np.arange(len(yOriginal))
print(
Python实现高斯曲线拟合1.目的针对光谱离散数据,寻峰完成后截取near峰值的数据,利用高斯拟合重绘单峰曲线,进而实现分峰功能2.原理3.代码import numpy as npfrom math import log, expimport matplotlib.pyplot as pltfrom scipy.optimize import curve_fitfrom scipy import asarray as ar,exp # 将txt文件读入numpy数组yOrig