Skip to content

Commit d97bd84

Browse files
committed
Revert solving merge conflicts modifying functions
1 parent a46cf34 commit d97bd84

File tree

3 files changed

+30
-30
lines changed

3 files changed

+30
-30
lines changed

src/peakstats.jl

+21-24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
estimate_single_peak_stats(h::Histogram,; calib_type::Symbol=:th228)
2+
estimate_single_peak_stats(h::Histogram; calib_type::Symbol=:th228)
33
44
Estimate statistics/parameters for a single peak in the given histogram `h`.
55
@@ -38,29 +38,7 @@ function estimate_single_peak_stats(args...; calib_type::Symbol=:th228)
3838
end
3939
export estimate_single_peak_stats
4040

41-
"""
42-
estimate_single_peak_stats_th228(h::Histogram{T}) where T<:Real
43-
44-
Estimate statistics/parameters for a single peak in the given histogram `h` for Th228 calibration.
45-
46-
# Arguments
47-
* 'h': Histogram data
48-
49-
# Returns
50-
`NamedTuple` with the fields
51-
* `peak_pos`: estimated position of the peak (in the middle of the peak)
52-
* `peak_fwhm`: full width at half maximum (FWHM) of the peak
53-
* `peak_sigma`: estimated standard deviation of the peak
54-
* `peak_counts`: estimated number of counts in the peak
55-
* `mean_background`: estimated mean background value
56-
* 'mean_background_step': estimated mean background step value
57-
* 'mean_background_std': estimated mean background standard deviation
58-
"""
59-
60-
function estimate_single_peak_stats_th228(h::Histogram{T}) where T<:Real
61-
W = h.weights
62-
E = first(h.edges)
63-
bin_width = step(E)
41+
function _get_hist_peakpos_fwhm(E::AbstractVector, W::Vector{<:Real})
6442
peak_amplitude, peak_idx = findmax(W)
6543
fwhm_idx_left = findfirst(w -> w >= (first(W) + peak_amplitude) / 2, W)
6644
fwhm_idx_right = findlast(w -> w >= (last(W) + peak_amplitude) / 2, W)
@@ -96,6 +74,25 @@ function estimate_single_peak_stats_th228(e::Vector{<:Real}, bin_width::Real)
9674
estimate_single_peak_stats_th228(h)
9775
end
9876

77+
78+
"""
79+
estimate_single_peak_stats_th228(h::Histogram{T}) where T<:Real
80+
81+
Estimate statistics/parameters for a single peak in the given histogram `h` for Th228 calibration.
82+
83+
# Arguments
84+
* 'h': Histogram data
85+
86+
# Returns
87+
`NamedTuple` with the fields
88+
* `peak_pos`: estimated position of the peak (in the middle of the peak)
89+
* `peak_fwhm`: full width at half maximum (FWHM) of the peak
90+
* `peak_sigma`: estimated standard deviation of the peak
91+
* `peak_counts`: estimated number of counts in the peak
92+
* `mean_background`: estimated mean background value
93+
* 'mean_background_step': estimated mean background step value
94+
* 'mean_background_std': estimated mean background standard deviation
95+
"""
9996
function estimate_single_peak_stats_th228(h::Histogram{T}) where T<:Real
10097
W = h.weights
10198
E = first(h.edges)

src/pseudo_prior.jl

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
"""
3-
get_standard_pseudo_prior(h::Histogram, ps::NamedTuple{(:peak_pos, :peak_fwhm, :peak_sigma, :peak_counts, :mean_background, :mean_background_step, :mean_background_std), NTuple{7, T}}, fit_func::Symbol; low_e_tail::Bool=true, fixed_position::Bool=false) where T<:Real
3+
get_standard_pseudo_prior(h::Histogram, ps::NamedTuple{(:peak_pos, :peak_fwhm, :peak_sigma, :peak_counts, :bin_width, :mean_background, :mean_background_step, :mean_background_std), NTuple{8, T}}, fit_func::Symbol; low_e_tail::Bool=true, fixed_position::Bool=false) where T<:Real
44
55
Gets standard pseudo prior of given histogram.
66
@@ -17,8 +17,11 @@ Gets standard pseudo prior of given histogram.
1717
1818
TO DO: function description and arguments.
1919
"""
20-
21-
function get_standard_pseudo_prior(h::Histogram, ps::NamedTuple{(:peak_pos, :peak_fwhm, :peak_sigma, :peak_counts, :mean_background, :mean_background_step, :mean_background_std), NTuple{7, T}}, fit_func::Symbol; low_e_tail::Bool=true, fixed_position::Bool=false) where T<:Real
20+
function get_standard_pseudo_prior(h::Histogram, ps::NamedTuple{(:peak_pos, :peak_fwhm, :peak_sigma, :peak_counts, :bin_width, :mean_background, :mean_background_step, :mean_background_std), NTuple{8, T}}, fit_func::Symbol; low_e_tail::Bool=true, fixed_position::Bool=false) where T<:Real
21+
# base priors common with all functions
22+
window_left = ps.peak_pos - minimum(h.edges[1])
23+
window_right = maximum(h.edges[1]) - ps.peak_pos
24+
# base priors common with all functions
2225
pprior_base = NamedTupleDist(
2326
μ = ifelse(fixed_position, ConstValueDist(ps.peak_pos), Normal(ps.peak_pos, 0.2*ps.peak_sigma)),
2427
σ = weibull_from_mx(ps.peak_sigma, 1.5*ps.peak_sigma),
@@ -55,7 +58,7 @@ function get_standard_pseudo_prior(h::Histogram, ps::NamedTuple{(:peak_pos, :pea
5558
end
5659

5760
"""
58-
get_pseudo_prior(h::Histogram, ps::NamedTuple{(:peak_pos, :peak_fwhm, :peak_sigma, :peak_counts, :mean_background, :mean_background_step, :mean_background_std), NTuple{7, T}}, fit_func::Symbol; pseudo_prior::NamedTupleDist=NamedTupleDist(empty = true), kwargs...) where T<:Real
61+
get_pseudo_prior(h::Histogram, ps::NamedTuple{(:peak_pos, :peak_fwhm, :peak_sigma, :peak_counts, :bin_width, :mean_background, :mean_background_step, :mean_background_std), NTuple{8, T}}, fit_func::Symbol; pseudo_prior::NamedTupleDist=NamedTupleDist(empty = true), kwargs...) where T<:Real
5962
6063
Gets the pseudo prior of the histogram, which is
6164
@@ -73,7 +76,7 @@ Gets the pseudo prior of the histogram, which is
7376
TO DO: check argument descriptions and returns.
7477
"""
7578

76-
function get_pseudo_prior(h::Histogram, ps::NamedTuple{(:peak_pos, :peak_fwhm, :peak_sigma, :peak_counts, :mean_background, :mean_background_step, :mean_background_std), NTuple{7, T}}, fit_func::Symbol; pseudo_prior::NamedTupleDist=NamedTupleDist(empty = true), kwargs...) where T<:Real
79+
function get_pseudo_prior(h::Histogram, ps::NamedTuple{(:peak_pos, :peak_fwhm, :peak_sigma, :peak_counts, :bin_width, :mean_background, :mean_background_step, :mean_background_std), NTuple{8, T}}, fit_func::Symbol; pseudo_prior::NamedTupleDist=NamedTupleDist(empty = true), kwargs...) where T<:Real
7780
standard_pseudo_prior = get_standard_pseudo_prior(h, ps, fit_func; kwargs...)
7881
# use standard priors in case of no overwrites given
7982
if !(:empty in keys(pseudo_prior))

src/utils.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Return the bin width for the given data `x` using the Friedman-Diaconis rule.
141141
# Arguments
142142
* 'x': Given data
143143
"""
144-
function get_friedman_diaconis_bin_width end # DELETE?
144+
function get_friedman_diaconis_bin_width end
145145

146146
function get_friedman_diaconis_bin_width(x::Vector{<:Real})
147147
2 * (quantile(x, 0.75) - quantile(x, 0.25)) / (length(x))

0 commit comments

Comments
 (0)