Skip to content

Commit

Permalink
export animate_draws and include it in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nluetts committed Jul 6, 2021
1 parent 05857cd commit cbdd460
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "NoisySignalIntegration"
uuid = "bdbab1c0-76f6-415c-8ec7-0d0463b9bd16"
authors = ["Nils Luettschwager <[email protected]>"]
version = "0.2.0"
version = "0.2.1"

[deps]
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Expand Down
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions docs/src/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,10 @@ trapz

```@docs
@samples
```

## Misc

```@docs
animate_draws
```
11 changes: 11 additions & 0 deletions docs/src/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions src/animate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand All @@ -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.
"""
Expand All @@ -33,4 +35,6 @@ function animate_draws(
end
fp = filepath === nothing ? tempname()*".gif" : filepath
return gif(anim, fp, fps=fps)
end
end

export animate_draws
9 changes: 7 additions & 2 deletions src/integration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down

0 comments on commit cbdd460

Please sign in to comment.