diff --git a/src/ms_filter.jl b/src/ms_filter.jl index 9ad8536..8c17838 100644 --- a/src/ms_filter.jl +++ b/src/ms_filter.jl @@ -84,7 +84,7 @@ function RadiationDetectorDSP.rdfilt!(output::AbstractVector, @inbounds for i in eachindex(input) center = fi.m + i sum = fma(kernel[1], _y[center], sum) - @simd for j in Base.OneTo(length(kernel)-1) + @simd for j in Base.OneTo(length(kernel)-2) k_j = kernel[j+1] sum = fma(k_j, _y[center + j+1], sum) sum = fma(k_j, _y[center - (j+1)], sum) diff --git a/test/runtests.jl b/test/runtests.jl index 812f79d..619072d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -8,5 +8,8 @@ Test.@testset "Package LegendDSP" begin # include("test_SOMETHING.jl") include("test_multiintersect.jl") include("test_docs.jl") + include("test_ms_filter.jl") + include("test_sgw_filter.jl") + include("test_wh_filter.jl") isempty(Test.detect_ambiguities(LegendDSP)) end # testset diff --git a/test/test_ms_filter.jl b/test/test_ms_filter.jl new file mode 100644 index 0000000..8492e32 --- /dev/null +++ b/test/test_ms_filter.jl @@ -0,0 +1,19 @@ +using Test +using LegendDSP +using RadiationDetectorDSP +using RadiationDetectorSignals +using Unitful + +@testset "Test ModifiedSincFilter" begin + n = 600 + noise = 1. + t = range(0u"μs", 20u"μs", 2*n) + signal = vcat(zeros(n), 10*ones(n)) + (noise*rand(2*n) .- noise/2) + wf = RDWaveform(t, signal) + + # define filter parameters and filter + flt = ModifiedSincFilter(d=4, m=1u"μs") + + # apply filter to signal + @test_nowarn wf_new = flt(wf) +end \ No newline at end of file diff --git a/test/test_sgw_filter.jl b/test/test_sgw_filter.jl new file mode 100644 index 0000000..8d96e53 --- /dev/null +++ b/test/test_sgw_filter.jl @@ -0,0 +1,19 @@ +using Test +using LegendDSP +using RadiationDetectorDSP +using RadiationDetectorSignals +using Unitful + +@testset "Test WeightedSavitzkyGolayFilter" begin + n = 600 + noise = 1. + t = range(0u"μs", 20u"μs", 2*n) + signal = vcat(zeros(n), 10*ones(n)) + (noise*rand(2*n) .- noise/2) + wf = RDWaveform(t, signal) + + # define filter parameters and filter + flt = WeightedSavitzkyGolayFilter(length=1u"μs", degree=3, weightType=2) + + # apply filter to signal + @test_nowarn wf_new = flt(wf) +end \ No newline at end of file diff --git a/test/test_wh_filter.jl b/test/test_wh_filter.jl new file mode 100644 index 0000000..3dbd571 --- /dev/null +++ b/test/test_wh_filter.jl @@ -0,0 +1,19 @@ +using Test +using LegendDSP +using RadiationDetectorDSP +using RadiationDetectorSignals +using Unitful + +@testset "Test WhittakerHendersonFilter" begin + n = 600 + noise = 1. + t = range(0u"μs", 20u"μs", 2*n) + signal = vcat(zeros(n), 10*ones(n)) + (noise*rand(2*n) .- noise/2) + wf = RDWaveform(t, signal) + + # define filter parameters and filter + flt = WhittakerHendersonFilter(p=3, λ=4) + + # apply filter to signal + @test_nowarn wf_new = flt(wf) +end \ No newline at end of file