Skip to content

Commit

Permalink
MAINT: API: mu = MPV
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidLP committed Jun 30, 2016
1 parent 5f423f1 commit eed153d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
6 changes: 3 additions & 3 deletions examples/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import pylandau

x = np.arange(0, 100, 0.5)
mu, eta, sigma, A = 10, 1, 3, 1
y = pylandau.langau(x, mu, eta, sigma, A) + np.random.normal(0, 0.05, 200)
mpv, eta, sigma, A = 10, 1, 3, 1
y = pylandau.langau(x, mpv, eta, sigma, A) + np.random.normal(0, 0.05, 200)

coeff, pcov = curve_fit(pylandau.langau, x, y, p0=(mu, eta, sigma, A))
coeff, pcov = curve_fit(pylandau.langau, x, y, p0=(mpv, eta, sigma, A))
plt.plot(x, y, "o")
plt.plot(x, pylandau.langau(x, *coeff), "-")
plt.show()
8 changes: 4 additions & 4 deletions examples/landau_gauss.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import matplotlib.pyplot as plt
from scipy.ndimage.filters import gaussian_filter1d

mu, eta, sigma, A = 10, 1, 3, 1
mpv, eta, sigma, A = 10, 1, 3, 1
x = np.arange(0, 50, 0.01)
y = pylandau.landau(x, mu=mu, eta=eta, A=A)
y = pylandau.landau(x, mpv=mpv, eta=eta, A=A)
y_gconv = gaussian_filter1d(y, sigma=sigma / 0.01)
y_gconv_2 = pylandau.langau(x, mu, eta, sigma, A)
y_gconv_2 = pylandau.langau(x, mpv, eta, sigma, A)
plt.plot(x, y, label='Landau')
plt.plot(x, y_gconv_2, label='Langau')
plt.plot(x, y_gconv / np.amax(y_gconv), '--', label='Langau Scipy')
plt.plot(x, y_gconv, '--', label='Langau Scipy')
plt.legend(loc=0)
plt.show()
9 changes: 4 additions & 5 deletions examples/mpv_fwhm.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ class NoPeaksFound(Exception):
return roots[0], roots[1]

x = np.arange(0, 100, 0.01)
for A, eta, mu in ((1, 1, 10), (1, 2, 30), (0.5, 5, 50)):
y = pylandau.landau(x, mu, eta, A)
plt.plot(x, y, label='A=%d, eta=%d, mu=%d' % (A, eta, mu))
for A, eta, mpv in ((1, 1, 10), (1, 2, 30), (0.5, 5, 50)):
y = pylandau.landau(x, mpv, eta, A)
plt.plot(x, y, label='A=%d, mpv=%d, eta=%d' % (A, mpv, eta))
x_fwhm_1, x_fwhm_2 = fwhm(x, y)
plt.plot([x_fwhm_1, x_fwhm_2], [np.max(y) / 2., np.max(y) / 2.], label='FWHM: %1.1f' % np.abs(x_fwhm_1 - x_fwhm_2))
x_mpv = x[np.argmax(y)]
plt.plot([x_mpv, x_mpv], [0., np.max(y)], label='MPV: %1.1f' % x_mpv)
plt.plot([mpv, mpv], [0., np.max(y)], label='MPV: %1.1f' % mpv)
plt.legend(loc=0)
plt.show()
3 changes: 1 addition & 2 deletions examples/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
plt.plot(x, pylandau.landau(x, mu, eta, A), '-', label='A=%1.1f, eta=%1.1f, mu=%1.1f' % (A, eta, mu))

# Use the function that calculates the y value given a x value, (e.g. needed for minimizers)
y = np.array([pylandau.get_landau_pdf(x_value, mu, eta) for x_value in x])
y = y / np.max(y) * A # Scale maximum to amplitude A
y = np.array([pylandau.get_landau(x_value, mu, eta, A) for x_value in x])
plt.plot(x, y, '--', label='A=%1.1f, eta=%1.1f, mu=%1.1f' % (A, eta, mu))
plt.legend(loc=0)
plt.show()

0 comments on commit eed153d

Please sign in to comment.