diff --git a/Project.toml b/Project.toml index 99ba64a..3187a07 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "NoisySignalIntegration" uuid = "bdbab1c0-76f6-415c-8ec7-0d0463b9bd16" authors = ["Nils Luettschwager "] -version = "0.2.0" +version = "0.2.1" [deps] Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" diff --git a/docs/make.jl b/docs/make.jl index eae1909..7fd718a 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -2,6 +2,7 @@ import Pkg Pkg.activate(@__DIR__) using Documenter +using Plots # this needs to be imported here so that Require.jl includes animate_draws when building docs using NoisySignalIntegration # include doctests from docstrings diff --git a/docs/src/API.md b/docs/src/API.md index d6d50e3..f338e72 100644 --- a/docs/src/API.md +++ b/docs/src/API.md @@ -60,4 +60,10 @@ trapz ```@docs @samples +``` + +## Misc + +```@docs +animate_draws ``` \ No newline at end of file diff --git a/docs/src/guide.md b/docs/src/guide.md index 76f6ae4..7adfb01 100644 --- a/docs/src/guide.md +++ b/docs/src/guide.md @@ -317,6 +317,17 @@ wb_1, wb_2 = UncertainBound(positions, width_distribution, uncertain_spectrum) plot(uncertain_spectrum, [wb_1, wb_2]; size=(400, 500), local_baseline=true) ``` +An alternative to the plot function is the [`animate_draws`](@ref) function which allows you +to visualize the Monte-Carlo draws in a gif animation: + +```@example FTIR +NoisySignalIntegration.animate_draws( + uncertain_spectrum, [wb_1, wb_2]; + size=(300, 150), + local_baseline=true +) +``` + ## Running the integration algorithm The integration is performed with the function [`mc_integrate`](@ref). We have diff --git a/src/animate.jl b/src/animate.jl index 680e0d7..9ac631d 100644 --- a/src/animate.jl +++ b/src/animate.jl @@ -4,6 +4,7 @@ using .Plots animate_draws(uc::UncertainCurve, bnds::Vector{UncertainBound}; n=20, fps=5, filepath=nothing, kw...) Create a gif animation showing the first `n` random draws. +Requires the Plots.jl package. Create an animation of the Monte-Carlo iterations when integrating the `UncertainCurve` `uc` using the `UncertainBound`s `bnds`. @@ -14,7 +15,8 @@ Create an animation of the Monte-Carlo iterations when integrating the `fps`: frames-per-second -`filepath`: if provided, the gif-animation will be stored using this filepath +`filepath`: if provided, the gif-animation will be stored using this filepath, +otherwise a temporary file will be created. Further keyword arguments are passed on the `Plots.plot()` function. """ @@ -33,4 +35,6 @@ function animate_draws( end fp = filepath === nothing ? tempname()*".gif" : filepath return gif(anim, fp, fps=fps) -end \ No newline at end of file +end + +export animate_draws \ No newline at end of file diff --git a/src/integration.jl b/src/integration.jl index a0b3ca7..a5c8b3a 100644 --- a/src/integration.jl +++ b/src/integration.jl @@ -28,8 +28,13 @@ The core integration function that is used to numerically integrate each draw. Defaults to `NoisySignalIntegration.trapz`. The function that is used to substitute [`trapz`](@ref) must share its call signature. -`subtract_baseline`: -If true, for each draw a local baseline defined by the integration window start and end point will be subtracted. +`subtract_baseline` (deprecated in favor of `local_baseline`): +If true, for each draw a local linear baseline defined by the integration window start and end point will be subtracted. + +`local_baseline`: +If true, for each draw a local linear baseline defined by the integration window start and end point will be subtracted. +The y-values of the start and end point are derived from a weighted average over the start and end point distributions, see +[the documentation](https://nluetts.github.io/NoisySignalIntegration.jl/dev/baseline/#Build-in) for further information. """ function mc_integrate(uc::UncertainCurve{T, N}, bnds::Vector{UncertainBound{T, M}}; intfun=trapz, subtract_baseline=false, local_baseline=false) where {T, M, N}