diff --git a/tests/Acoustics.Test/AnalysisPrograms/Recognizers/GenericRecognizerTests.cs b/tests/Acoustics.Test/AnalysisPrograms/Recognizers/GenericRecognizerTests.cs index edb2420cb..fae7f8ef2 100644 --- a/tests/Acoustics.Test/AnalysisPrograms/Recognizers/GenericRecognizerTests.cs +++ b/tests/Acoustics.Test/AnalysisPrograms/Recognizers/GenericRecognizerTests.cs @@ -44,7 +44,7 @@ public void TestConfigSerialization() Profiles = new Dictionary() { { "TestAed", new Aed.AedConfiguration() { BandpassMinimum = 12345 } }, - { "TestOscillation", new OscillationParameters() { DecibelThreshold = 123 } }, + { "TestOscillation", new OscillationParameters() { DecibelThresholds = new double?[] { 123.0 } } }, { "TestBlob", new BlobParameters() { BottomHertzBuffer = 456 } }, { "TestWhistle", new OnebinTrackParameters() { TopHertzBuffer = 789 } }, }, @@ -76,7 +76,7 @@ public void TestConfigSerialization() Assert.IsInstanceOfType(config2.Profiles["TestWhistle"], typeof(OnebinTrackParameters)); Assert.AreEqual((config2.Profiles["TestAed"] as Aed.AedConfiguration)?.BandpassMinimum, 12345); - Assert.AreEqual((config2.Profiles["TestOscillation"] as OscillationParameters)?.DecibelThreshold, 123); + Assert.AreEqual((config2.Profiles["TestOscillation"] as OscillationParameters)?.DecibelThresholds, 123); Assert.AreEqual((config2.Profiles["TestBlob"] as BlobParameters)?.BottomHertzBuffer, 456); Assert.AreEqual((config2.Profiles["TestWhistle"] as OnebinTrackParameters)?.TopHertzBuffer, 789); } @@ -182,7 +182,7 @@ public void TestWhistleAlgorithm() TopHertzBuffer = 0, MinDuration = 4, MaxDuration = 6, - DecibelThreshold = 1.0, + DecibelThresholds = new double?[] { 1.0 }, SpeciesName = "NoName", } }, @@ -331,8 +331,9 @@ public void TestOnebinTrackAlgorithm() MaxHertz = 6000, MinDuration = 0.2, MaxDuration = 1.1, - DecibelThreshold = 2.0, + DecibelThresholds = new double?[] { 2.0 }, CombinePossibleSyllableSequence = false, + //SyllableStartDifference = TimeSpan.FromSeconds(0.2), //SyllableHertzGap = 300, }; @@ -360,18 +361,15 @@ public void TestOnebinTrackAlgorithm() //var image1 = SpectrogramTools.GetSonogramPlusCharts(spectrogram, null, null, null); //results.Sonogram.GetImage().Save(this.outputDirectory + "\\debug.png"); - var plots = new List(); - var (spectralEvents, dBArray) = OnebinTrackAlgorithm.GetOnebinTracks( + var (spectralEvents, plotList) = OnebinTrackAlgorithm.GetOnebinTracks( spectrogram, parameters, - segmentStartOffset); + segmentStartOffset, + "TestProfile"); // draw a plot of max decibels in each frame - double decibelNormalizationMax = 5 * parameters.DecibelThreshold.Value; - var dBThreshold = parameters.DecibelThreshold.Value / decibelNormalizationMax; - var normalisedDecibelArray = DataTools.NormaliseInZeroOne(dBArray, 0, decibelNormalizationMax); - var plot1 = new Plot("decibel max", normalisedDecibelArray, dBThreshold); - plots.Add(plot1); + var plots = new List(); + plots.AddRange(plotList); var allResults = new RecognizerResults() { @@ -424,7 +422,7 @@ public void TestForwardTrackAlgorithm() MaxHertz = 6000, MinDuration = 0.2, MaxDuration = 1.1, - DecibelThreshold = 2.0, + DecibelThresholds = new double?[] { 2.0 }, CombinePossibleHarmonics = false, HarmonicsStartDifference = TimeSpan.FromSeconds(0.2), HarmonicsHertzGap = 200, @@ -456,18 +454,14 @@ public void TestForwardTrackAlgorithm() //results.Sonogram.GetImage().Save(this.outputDirectory + "\\debug.png"); var segmentStartOffset = TimeSpan.Zero; - var plots = new List(); - var (spectralEvents, dBArray) = ForwardTrackAlgorithm.GetForwardTracks( + var (spectralEvents, plotList) = ForwardTrackAlgorithm.GetForwardTracks( spectrogram, parameters, - segmentStartOffset); + segmentStartOffset, + "TestProfile"); - // draw a plot of max decibels in each frame - double decibelNormalizationMax = 5 * parameters.DecibelThreshold.Value; - var dBThreshold = parameters.DecibelThreshold.Value / decibelNormalizationMax; - var normalisedDecibelArray = DataTools.NormaliseInZeroOne(dBArray, 0, decibelNormalizationMax); - var plot1 = new Plot("decibel max", normalisedDecibelArray, dBThreshold); - plots.Add(plot1); + var plots = new List(); + plots.AddRange(plotList); var allResults = new RecognizerResults() { @@ -514,7 +508,7 @@ public void TestOneframeTrackAlgorithm() MaxHertz = 11000, MinBandwidthHertz = 100, MaxBandwidthHertz = 5000, - DecibelThreshold = 2.0, + DecibelThresholds = new double?[] { 2.0 }, }; //Set up the virtual recording. @@ -540,18 +534,14 @@ public void TestOneframeTrackAlgorithm() //results.Sonogram.GetImage().Save(this.outputDirectory + "\\debug.png"); var segmentStartOffset = TimeSpan.Zero; - var plots = new List(); - var (spectralEvents, dBArray) = OneframeTrackAlgorithm.GetOneFrameTracks( + var (spectralEvents, plotList) = OneframeTrackAlgorithm.GetOneFrameTracks( spectrogram, parameters, - segmentStartOffset); + segmentStartOffset, + "TestProfile"); - // draw a plot of max decibels in each frame - double decibelNormalizationMax = 5 * parameters.DecibelThreshold.Value; - var dBThreshold = parameters.DecibelThreshold.Value / decibelNormalizationMax; - var normalisedDecibelArray = DataTools.NormaliseInZeroOne(dBArray, 0, decibelNormalizationMax); - var plot1 = new Plot("decibel max", normalisedDecibelArray, dBThreshold); - plots.Add(plot1); + var plots = new List(); + plots.AddRange(plotList); var allResults = new RecognizerResults() { @@ -601,7 +591,7 @@ public void Test1UpwardsTrackAlgorithm() MaxHertz = 11000, MinBandwidthHertz = 100, MaxBandwidthHertz = 5000, - DecibelThreshold = 2.0, + DecibelThresholds = new double?[] { 2.0 }, CombineProximalSimilarEvents = true, SyllableStartDifference = TimeSpan.FromSeconds(0.2), SyllableHertzDifference = 300, @@ -631,17 +621,13 @@ public void Test1UpwardsTrackAlgorithm() var segmentStartOffset = TimeSpan.Zero; var plots = new List(); - var (spectralEvents, dBArray) = UpwardTrackAlgorithm.GetUpwardTracks( + var (spectralEvents, plotList) = UpwardTrackAlgorithm.GetUpwardTracks( spectrogram, parameters, - segmentStartOffset); + segmentStartOffset, + "TestProfile"); - // draw a plot of max decibels in each frame - double decibelNormalizationMax = 5 * parameters.DecibelThreshold.Value; - var dBThreshold = parameters.DecibelThreshold.Value / decibelNormalizationMax; - var normalisedDecibelArray = DataTools.NormaliseInZeroOne(dBArray, 0, decibelNormalizationMax); - var plot1 = new Plot("decibel max", normalisedDecibelArray, dBThreshold); - plots.Add(plot1); + plots.AddRange(plotList); var allResults = new RecognizerResults() { @@ -691,7 +677,7 @@ public void Test2UpwardsTrackAlgorithm() MaxHertz = 6000, MinBandwidthHertz = 200, MaxBandwidthHertz = 5000, - DecibelThreshold = 2.0, + DecibelThresholds = new double?[] { 2.0 }, CombineProximalSimilarEvents = false, SyllableStartDifference = TimeSpan.FromSeconds(0.2), SyllableHertzDifference = 300, @@ -719,17 +705,14 @@ public void Test2UpwardsTrackAlgorithm() var plots = new List(); // do a SECOND TEST of the vertical tracks - var (spectralEvents, dBArray) = UpwardTrackAlgorithm.GetUpwardTracks( + var (spectralEvents, plotList) = UpwardTrackAlgorithm.GetUpwardTracks( spectrogram, parameters, - segmentStartOffset); + segmentStartOffset, + "TestProfile"); // draw a plot of max decibels in each frame - double decibelNormalizationMax = 5 * parameters.DecibelThreshold.Value; - var dBThreshold = parameters.DecibelThreshold.Value / decibelNormalizationMax; - var normalisedDecibelArray = DataTools.NormaliseInZeroOne(dBArray, 0, decibelNormalizationMax); - var plot2 = new Plot("decibel max", normalisedDecibelArray, dBThreshold); - plots.Add(plot2); + plots.AddRange(plotList); var allResults2 = new RecognizerResults() {