Skip to content

Commit

Permalink
Fix recipe for calibration and FWHM fit
Browse files Browse the repository at this point in the history
  • Loading branch information
theHenks committed Nov 11, 2024
1 parent d6bbde2 commit f9036f6
Showing 1 changed file with 17 additions and 22 deletions.
39 changes: 17 additions & 22 deletions ext/LegendSpecFitsRecipesBaseExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,9 @@ end
framestyle := :box
xformatter := :plain
yformatter := :plain
margins := (0, :mm)

Check warning on line 803 in ext/LegendSpecFitsRecipesBaseExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/LegendSpecFitsRecipesBaseExt.jl#L803

Added line #L803 was not covered by tests
if !isempty(report.gof)
layout --> @layout([a{0.8h}; b{0.2h}])
margins --> (-11.5, :mm)
link --> :x
end
@series begin
Expand Down Expand Up @@ -835,6 +835,10 @@ end
label := "Data (x-Error x$(xerrscaling), y-Error x$(yerrscaling))"
end
markercolor --> :black
if !isempty(report.gof)
xguide := ""
xticks := []

Check warning on line 840 in ext/LegendSpecFitsRecipesBaseExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/LegendSpecFitsRecipesBaseExt.jl#L838-L840

Added lines #L838 - L840 were not covered by tests
end
xerror := uncertainty.(report.x) .* xerrscaling
yerror := uncertainty.(report.y) .* yerrscaling
value.(report.x), value.(report.y)
Expand All @@ -855,6 +859,10 @@ end
ms --> 3
markershape --> :circle
markerstrokecolor --> :black
if !isempty(report.gof)
xguide := ""
xticks := []

Check warning on line 864 in ext/LegendSpecFitsRecipesBaseExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/LegendSpecFitsRecipesBaseExt.jl#L862-L864

Added lines #L862 - L864 were not covered by tests
end
linewidth --> 0.5
markercolor --> :silver
xerror := uncertainty.(additional_pts.x) .* xerrscaling
Expand Down Expand Up @@ -901,7 +909,8 @@ end
subplot --> 2
label --> ""
markercolor --> :black
ylabel --> "Residuals (σ)"
yguide := "Residuals (σ)"
top_margin --> (-4, :mm)

Check warning on line 913 in ext/LegendSpecFitsRecipesBaseExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/LegendSpecFitsRecipesBaseExt.jl#L912-L913

Added lines #L912 - L913 were not covered by tests
ylims --> (-5, 5)
yticks --> ([-3, 0, 3])
value.(report.x), report.gof.residuals_norm
Expand All @@ -921,14 +930,14 @@ end
else
NamedTuple()
end
xlabel := "Energy (keV)"
legend := :topleft
framestyle := :box
xlims := (0, 3000)
xticks := (0:500:3000, ["$i" for i in 0:500:3000])
@series begin
grid --> :all
xerrscaling --> xerrscaling
xlabel := "Energy (keV)"

Check warning on line 940 in ext/LegendSpecFitsRecipesBaseExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/LegendSpecFitsRecipesBaseExt.jl#L940

Added line #L940 was not covered by tests
yerrscaling --> yerrscaling
additional_pts --> additional_pts
(par = report.par, f_fit = report.f_fit, x = report.x, y = report.y, gof = get(report, :gof, NamedTuple()))
Expand All @@ -954,36 +963,22 @@ end
if report.type == :cal
additional_pts = if !isempty(additional_pts)
μ_cal = report.f_fit.(additional_pts.μ) .* report.e_unit
(x = additional_pts.μ, y = additional_pts.peaks,
residuals_norm = (value.(μ_cal) .- additional_pts.peaks)./ uncertainty.(μ_cal))
(x = additional_pts.μ, y = ustrip.(report.e_unit, additional_pts.peaks),

Check warning on line 966 in ext/LegendSpecFitsRecipesBaseExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/LegendSpecFitsRecipesBaseExt.jl#L966

Added line #L966 was not covered by tests
residuals_norm = (value.(μ_cal) .- additional_pts.peaks) ./ uncertainty.(μ_cal))
else
NamedTuple()
end
xlabel := "Energy (ADC)"
legend := :bottomright
framestyle := :box
xlims := (0, 168000)
xticks := (0:16000:176000)
xlims := (0, 1.1*maximum(value.(report.x)))

Check warning on line 972 in ext/LegendSpecFitsRecipesBaseExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/LegendSpecFitsRecipesBaseExt.jl#L972

Added line #L972 was not covered by tests
@series begin
xlabel := "Energy (ADC)"
ylabel := "Energy ($(report.e_unit))"

Check warning on line 975 in ext/LegendSpecFitsRecipesBaseExt.jl

View check run for this annotation

Codecov / codecov/patch

ext/LegendSpecFitsRecipesBaseExt.jl#L974-L975

Added lines #L974 - L975 were not covered by tests
grid --> :all
xerrscaling --> xerrscaling
yerrscaling --> yerrscaling
additional_pts := additional_pts
(par = report.par, f_fit = report.f_fit, x = report.x, y = report.y, gof = report.gof)
end
@series begin
seriestype := :hline
label := L"Q_{\beta \beta}"
color := :green
fillalpha := 0.2
linewidth := 2.5
xticks := :none
ylabel := "Energy ($(report.e_unit))"
ylims := (0, 1.2*value(maximum(report.y)))
yticks := (500:500:3000)
subplot := 1
[2039]
end
end
end

Expand Down

0 comments on commit f9036f6

Please sign in to comment.