FindPeaks

[1]:
import nexus as nx
import numpy as np
import matplotlib.pyplot as plt
[2]:
data = np.loadtxt("Fe_alpha_spectrum.txt")

# create an arbitrary x axis for this example
x_axis = np.arange(len(data))*0.087

x, y, indices, n = nx.data.FindPeaks(x_axis,
                                     data,
                                     n=6,
                                     neg=True)

print(x)
print(y)

plt.plot(x_axis, data, color = 'black', marker="o")

for i, j in zip(x,y):
    plt.axvline(i, color = 'red', alpha=0.5)
    plt.text(i+1, j, f"{j:.1f}")

plt.savefig("fig_findpeaks.png")

plt.show()
[ 7.395 13.572 19.923 24.534 30.711 36.975]
[ 656.10337734  968.54481784 1472.52126398 1429.91065595 1031.57776675
  642.49844298]
../../_images/tutorial_data_nb_find_peaks_2_1.png