Last active
August 14, 2020 09:28
-
-
Save Drvanon/5f490526a73d8f29dbde20b286674f79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from scipy.optimize import curve_fit | |
from scipy import signal | |
def gauss(x, mu, sigma, A): | |
return A / (sigma * np.sqrt(2 * np.pi)) * np.exp(- .5 * np.power((x-mu)/sigma , 2)) | |
peakind = signal.find_peaks_cwt(inten_na2, np.arange(2,5), noise_perc=90, min_length=2, min_snr=2) | |
# plt.plot(lamb_na2, inten_na2) | |
lamb_peaks = lamb_na2[peakind] | |
inten_peaks = inten_na2[peakind] | |
ra = (lamb_peaks > 400) & (lamb_peaks < 600) | |
l_peaks = lamb_peaks[ra] | |
for l in l_peaks: | |
domain = (lamb_na2 > l - 1) & (lamb_na2 < l + 1) | |
popt_peak, pcov_peak = curve_fit(gauss, lamb_na2[domain], inten_na2[domain], p0=[l, .5, 3e3]) | |
print(f"{l:.4} {popt_peak[1]:.2} ") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment