Skip to content

Commit

Permalink
Add runtests for filters
Browse files Browse the repository at this point in the history
  • Loading branch information
apmypb committed Sep 1, 2024
1 parent b5e6e44 commit eceeecc
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ms_filter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 additions & 0 deletions test/test_ms_filter.jl
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions test/test_sgw_filter.jl
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions test/test_wh_filter.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit eceeecc

Please sign in to comment.