Skip to content

Commit

Permalink
Rewrite unit tests to work with new method of using multiple decibel …
Browse files Browse the repository at this point in the history
…thresholds.

Issue #390
  • Loading branch information
towsey authored and atruskie committed Nov 1, 2020
1 parent 43ab9f9 commit 2648ea0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public class AustBitternTests : OutputDirectoryTest
/// <summary>
/// The canonical recording used for this recognizer is a 30 second recording made by Liz Znidersic at Medeas Cove, St Helens, 2016-12-17.
/// </summary>
//private static readonly FileInfo TestAsset = PathHelper.ResolveAsset("Recordings", "medeas_cove_2-2_1831_471228_20161217_232352_30_0.wav");
private static readonly FileInfo TestAsset = new FileInfo(@"C:\Ecoacoustics\WavFiles\TestNoiseRecordings\Cotton_BBN1_20170406_202404_Truck.wav");
private static readonly FileInfo TestAsset = PathHelper.ResolveAsset("Recordings", "medeas_cove_2-2_1831_471228_20161217_232352_30_0.wav");
//private static readonly FileInfo TestAsset = new FileInfo(@"C:\Ecoacoustics\WavFiles\TestNoiseRecordings\West_Knoll_St_Bees_WindRain_20080917-133000.wav");
//private static readonly FileInfo ConfigFile = PathHelper.ResolveConfigFile("RecognizerConfigFiles", "Towsey.BotaurusPoiciloptilus.yml");
private static readonly FileInfo ConfigFile = PathHelper.ResolveConfigFile(@"C:\Ecoacoustics\ConfigFiles\Towsey.BotaurusPoiciloptilus.yml");
private static readonly BotaurusPoiciloptilus Recognizer = new BotaurusPoiciloptilus();
Expand Down Expand Up @@ -68,14 +68,14 @@ public void TestRecognizer()

var onlyEvent = (CompositeEvent)events[0];

//note this event contains only three syllables but 7 events because have used two decibel thresholds.
Assert.AreEqual(12, onlyEvent.ComponentCount);
//note this event contains four syllables and one echo, therefore five components.
Assert.AreEqual(5, onlyEvent.ComponentCount);
Assert.AreEqual(5.12, onlyEvent.EventStartSeconds);
Assert.AreEqual(12.256, onlyEvent.EventEndSeconds);
Assert.AreEqual(105, onlyEvent.LowFrequencyHertz);
Assert.AreEqual(180, onlyEvent.HighFrequencyHertz);
Assert.AreEqual(28.078038296020, onlyEvent.Score, TestHelper.AllowedDelta);
Assert.AreEqual(0.024466803702, onlyEvent.ScoreNormalized, TestHelper.AllowedDelta);
Assert.AreEqual(21.716400254142027, onlyEvent.Score, TestHelper.AllowedDelta);
Assert.AreEqual(0.947014602243972, onlyEvent.ScoreNormalized, TestHelper.AllowedDelta);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Acoustics.Test.AnalysisPrograms.Recognizers
using global::AudioAnalysisTools.WavTools;
using global::TowseyLibrary;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using static global::AudioAnalysisTools.Events.Types.EventPostProcessing;

[TestClass]
public class GenericRecognizerTests : OutputDirectoryTest
Expand Down Expand Up @@ -107,20 +108,20 @@ public void TestBlobAlgorithm()
}
},
},
PostProcessing = new GenericRecognizer.PostProcessingConfig()
PostProcessing = new PostProcessingConfig()
{
CombineOverlappingEvents = false,

// filter on bandwidth
Bandwidth = new GenericRecognizer.BandwidthConfig()
Bandwidth = new BandwidthConfig()
{
ExpectedBandwidth = 2400,
BandwidthStandardDeviation = 10,
},

// filter on acousstic activity in sidebands.
// zero indicates no filtering.
SidebandActivity = new GenericRecognizer.SidebandConfig()
SidebandActivity = new SidebandConfig()
{
UpperHertzBuffer = 0,
LowerHertzBuffer = 0,
Expand Down Expand Up @@ -171,20 +172,20 @@ public void TestOscillationAlgorithm()
}
},
},
PostProcessing = new GenericRecognizer.PostProcessingConfig()
PostProcessing = new PostProcessingConfig()
{
CombineOverlappingEvents = false,

// filter on bandwidth
Bandwidth = new GenericRecognizer.BandwidthConfig()
Bandwidth = new BandwidthConfig()
{
ExpectedBandwidth = 350,
BandwidthStandardDeviation = 20,
},

// filter on acousstic activity in sidebands.
// zero indicates no filtering.
SidebandActivity = new GenericRecognizer.SidebandConfig()
SidebandActivity = new SidebandConfig()
{
UpperHertzBuffer = 0,
LowerHertzBuffer = 0,
Expand Down Expand Up @@ -233,20 +234,20 @@ public void TestWhistleAlgorithm()
}
},
},
PostProcessing = new GenericRecognizer.PostProcessingConfig()
PostProcessing = new PostProcessingConfig()
{
CombineOverlappingEvents = false,

// filter on bandwidth
Bandwidth = new GenericRecognizer.BandwidthConfig()
Bandwidth = new BandwidthConfig()
{
ExpectedBandwidth = 90,
BandwidthStandardDeviation = 10,
},

// filter on acousstic activity in sidebands.
// zero indicates no filtering.
SidebandActivity = new GenericRecognizer.SidebandConfig()
SidebandActivity = new SidebandConfig()
{
UpperHertzBuffer = 0,
LowerHertzBuffer = 0,
Expand Down Expand Up @@ -379,6 +380,8 @@ public void TestHarmonicsAlgorithm()
public void TestOnebinTrackAlgorithm()
{
// Set up the recognizer parameters.
double? decibelThreshold = 2.0;

var parameters = new OnebinTrackParameters()
{
MinHertz = 500,
Expand Down Expand Up @@ -418,6 +421,7 @@ public void TestOnebinTrackAlgorithm()
var (spectralEvents, plotList) = OnebinTrackAlgorithm.GetOnebinTracks(
spectrogram,
parameters,
decibelThreshold,
segmentStartOffset,
"TestProfile");

Expand Down Expand Up @@ -980,20 +984,20 @@ public void TestAedAlgorithm()
}
},
},
PostProcessing = new GenericRecognizer.PostProcessingConfig()
PostProcessing = new PostProcessingConfig()
{
CombineOverlappingEvents = false,

// filter on bandwidth
Bandwidth = new GenericRecognizer.BandwidthConfig()
Bandwidth = new BandwidthConfig()
{
ExpectedBandwidth = 3000,
BandwidthStandardDeviation = 1000,
},

// filter on acousstic activity in sidebands.
// zero indicates no filtering.
SidebandActivity = new GenericRecognizer.SidebandConfig()
SidebandActivity = new SidebandConfig()
{
UpperHertzBuffer = 0,
LowerHertzBuffer = 0,
Expand Down Expand Up @@ -1070,20 +1074,20 @@ public void TestMultipleAlgorithms()
}
},
},
PostProcessing = new GenericRecognizer.PostProcessingConfig()
PostProcessing = new PostProcessingConfig()
{
CombineOverlappingEvents = false,

// filter on bandwidth
Bandwidth = new GenericRecognizer.BandwidthConfig()
Bandwidth = new BandwidthConfig()
{
ExpectedBandwidth = 3000,
BandwidthStandardDeviation = 1000,
},

// filter on acousstic activity in sidebands.
// zero indicates no filtering.
SidebandActivity = new GenericRecognizer.SidebandConfig()
SidebandActivity = new SidebandConfig()
{
UpperHertzBuffer = 0,
LowerHertzBuffer = 0,
Expand Down

0 comments on commit 2648ea0

Please sign in to comment.