mirror of
https://github.com/vale981/bandfit
synced 2025-03-05 09:31:42 -05:00
also fit the other peak height
This commit is contained in:
parent
260aa1d302
commit
a58641c3a9
1 changed files with 17 additions and 7 deletions
|
@ -133,18 +133,24 @@ def detect_bands_fixed_k(
|
|||
|
||||
col /= col[guess_1]
|
||||
|
||||
(e_1, e_2, γ, _), cov = sc.optimize.curve_fit(
|
||||
(e_1, e_2, γ, *_), cov = sc.optimize.curve_fit(
|
||||
double_lorentzian,
|
||||
e_axis,
|
||||
col,
|
||||
(guess_1, guess_2, γ, 1),
|
||||
(guess_1, guess_2, γ, 1, 1),
|
||||
bounds=(
|
||||
(max(guess_1 - γ, 0), max(guess_2 - γ, 0), 0.5, 0.3),
|
||||
(min(guess_1 + γ, col.size), min(guess_2 + γ, col.size), col.size, 1 / 0.3),
|
||||
(max(guess_1 - γ, 0), max(guess_2 - γ, 0), 0.5, 0.1, 0.1),
|
||||
(
|
||||
min(guess_1 + γ, col.size),
|
||||
min(guess_2 + γ, col.size),
|
||||
col.size,
|
||||
2,
|
||||
2,
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
σ_1, σ_2, _, _ = np.sqrt(np.diag(cov))
|
||||
σ_1, σ_2, *_ = np.sqrt(np.diag(cov))
|
||||
|
||||
(e_1, σ_1), (e_2, σ_2) = np.sort(((e_1, σ_1), (e_2, σ_2)), axis=0)
|
||||
|
||||
|
@ -155,13 +161,17 @@ def detect_bands_fixed_k(
|
|||
return e_1, e_2, σ_1, σ_2
|
||||
|
||||
|
||||
def detect_bands(data, γ=20, min_height=0.5):
|
||||
def detect_bands(data, *args, **kwargs):
|
||||
""" """
|
||||
bands = []
|
||||
|
||||
if "last_separation" in kwargs:
|
||||
del kwargs["last_separation"]
|
||||
|
||||
e_1, e_2 = 0, 0
|
||||
for k in range(data.shape[1]):
|
||||
e_1, e_2, *σ = detect_bands_fixed_k(
|
||||
k, data, γ, last_separation=abs(e_2 - e_1), min_height=min_height
|
||||
k, data, *args, **kwargs, last_separation=abs(e_2 - e_1)
|
||||
)
|
||||
|
||||
bands.append((e_1, e_2, *σ))
|
||||
|
|
Loading…
Add table
Reference in a new issue