Skip to content

Commit

Permalink
Change function to fit sigma of A/E peaks from exp to sqrt
Browse files Browse the repository at this point in the history
  • Loading branch information
fhagemann committed Dec 10, 2023
1 parent 7baeb3a commit ccc1f82
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/aoe_calibration.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
f_aoe_sigma(x, p) = p[1] .+ p[2]*exp.(-p[3]./x)
# f_aoe_sigma(x, p) = p[1] .+ p[2]*exp.(-p[3]./x)
f_aoe_sigma(x, p) = sqrt(abs(p[1]) + abs(p[2])/x^2)

Check warning on line 2 in src/aoe_calibration.jl

View check run for this annotation

Codecov / codecov/patch

src/aoe_calibration.jl#L2

Added line #L2 was not covered by tests
f_aoe_mu(x, p) = p[1] .+ p[2]*x


Expand All @@ -20,19 +21,18 @@ function fit_aoe_corrections(e::Array{<:Real}, μ::Array{T}, σ::Array{T}) where
@debug "μ_scs_intercept: $μ_scs_intercept"

# fit compton band sigmas with exponential function
σ_scs = curve_fit(f_aoe_sigma, e, σ, [0.0, median(σ), 5.0])
σ_scs = curve_fit(f_aoe_sigma, e, σ, [median(σ), 5.0])

Check warning on line 24 in src/aoe_calibration.jl

View check run for this annotation

Codecov / codecov/patch

src/aoe_calibration.jl#L24

Added line #L24 was not covered by tests
σ_scs_err = stderror(σ_scs)
@debug "σ_scs offset: $(σ_scs.param[1])"
@debug "σ_scs shift : $(σ_scs.param[2])"
@debug "σ_scs phase : $(σ_scs.param[3])"

(
e = e,
μ = μ,
μ_scs = μ_scs.param,
f_μ_scs = x -> μ_scs_slope * x + μ_scs_intercept,
σ = σ,
σ_scs = σ_scs.param,
σ_scs = abs.(σ_scs.param),
f_σ_scs = x -> Base.Fix2(f_aoe_sigma, σ_scs.param)(x),
err = (σ_scs = σ_scs_err,
μ_scs = μ_scs_err
Expand Down

0 comments on commit ccc1f82

Please sign in to comment.