-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated docstrings #80
base: dev
Are you sure you want to change the base?
Conversation
src/peakstats.jl
Outdated
@@ -28,7 +38,29 @@ function estimate_single_peak_stats(args...; calib_type::Symbol=:th228) | |||
end | |||
export estimate_single_peak_stats | |||
|
|||
function _get_hist_peakpos_fwhm(E::AbstractVector, W::Vector{<:Real}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolving the merge conflicts, something went wrong here.
_get_hist_peakpos_fwhm
disappeared..
63db43f
to
6070456
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR seems to (re)introduce two functions (not sure if we want them out):
f_optimize_ctc
and get_n_after_aoe_cut
. Do we need/want them?
""" | ||
ctc_energy(e::Array{T}, qdrift::Array{T}, peak::T, window::T) where T<:Real | ||
f_optimize_ctc(fct, e, qdrift, bin_width) | ||
|
||
Calculate the ratio of the FWHM and the peak height of the peak around `peak` in | ||
`e` with a cut window of `window`. The drift time dependence is given by | ||
`e_ctc` = `e` + `fct` * `qdrift`. | ||
|
||
# Arguments | ||
* 'fct': Correction factor | ||
* 'e': Calibrated energies | ||
* 'qdrift': Charge drift | ||
* 'bin_width': Width of histogram bins | ||
|
||
# Returns | ||
* `fwhm / p_height`: FWHM of the peak divided by peak height | ||
""" | ||
function f_optimize_ctc(fct, e, qdrift, bin_width) | ||
# calculate drift time corrected energy | ||
e_ctc = e .+ fct .* qdrift | ||
# fit peak | ||
h = fit(Histogram, e_ctc, minimum(e_ctc):bin_width:maximum(e_ctc)) | ||
ps = estimate_single_peak_stats(h) | ||
result_peak, report_peak = fit_single_peak_th228(h, ps; uncertainty=false) | ||
# get fwhm and peak height | ||
fwhm = mvalue(result_peak.fwhm) | ||
p_height = maximum(report_peak.f_fit.(mvalue(result_peak.μ-0.2*result_peak.σ):0.01:mvalue(result_peak.μ+0.2*result_peak.σ))) | ||
# use ratio of fwhm and peak height as optimization functional | ||
return log(fwhm/p_height) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is (re)introduced: f_optimize_ctc
""" | ||
get_n_after_aoe_cut(aoe_cut::Unitful.RealOrRealQuantity, aoe::Vector{<:Unitful.RealOrRealQuantity}, e::Vector{<:T}, peak::T, window::Vector{T}, bin_width::T, result_before::NamedTuple, peakstats::NamedTuple; uncertainty::Bool=true, fixed_position::Bool=true) where T<:Unitful.Energy{<:Real} | ||
|
||
Get the number of counts after a AoE cut value `aoe_cut` for a given `peak` and `window` size while performing a peak fit with fixed position. The number of counts is determined by fitting the peak with a pseudo prior for the peak position. | ||
|
||
# Arguments | ||
* 'aoe_cut': A/E cut value | ||
* 'aoe': A/E | ||
* 'e': Calibrated energies | ||
* 'peak': Data peak | ||
* 'window': histogram window size of counts used | ||
* 'bin_width': Histogram bin widths | ||
* 'result_before': | ||
* 'peakstats': Peak statistics | ||
|
||
# Keywords | ||
* 'uncertainty': Data uncertainty | ||
* 'fixed_position': Position of peak | ||
|
||
# Returns | ||
* `n`: Number of counts after the cut | ||
|
||
""" | ||
function get_n_after_aoe_cut(aoe_cut::Unitful.RealOrRealQuantity, aoe::Vector{<:Unitful.RealOrRealQuantity}, e::Vector{<:T}, peak::T, window::Vector{T}, bin_width::T, result_before::NamedTuple, peakstats::NamedTuple; uncertainty::Bool=true, fixed_position::Bool=true) where T<:Unitful.Energy{<:Real} | ||
# get energy after cut and create histogram | ||
peakhist = fit(Histogram, ustrip.(e[aoe .> aoe_cut]), ustrip(peak-first(window):bin_width:peak+last(window))) | ||
# create pseudo_prior with known peak sigma in signal for more stable fit | ||
pseudo_prior = if fixed_position | ||
NamedTupleDist(σ = Normal(result_before.σ, 0.1), μ = ConstValueDist(result_before.μ)) | ||
else | ||
NamedTupleDist(σ = Normal(result_before.σ, 0.1), ) | ||
end | ||
# fit peak and return number of signal counts | ||
result, _ = fit_single_peak_th228(peakhist, peakstats,; uncertainty=uncertainty, low_e_tail=false, pseudo_prior=pseudo_prior) | ||
return result.n | ||
end | ||
export get_n_after_aoe_cut | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is (re)introduced: get_n_after_aoe_cut
The failing tests seem to be unrelated (can we fix that??) |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #80 +/- ##
======================================
Coverage ? 21.52%
======================================
Files ? 33
Lines ? 2983
Branches ? 0
======================================
Hits ? 642
Misses ? 2341
Partials ? 0 ☔ View full report in Codecov by Sentry. |
Updated docstrings in the following format:
There are still functions that need arguments, keywords, returns or a description added. All of the missing descriptions are found in this Google Doc.
https://docs.google.com/document/d/1-clJFUV2ZZ8kklChEZ_7bfOK89VDA-6_WGYy7SodkRs/edit?usp=sharing