-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP progress refactoring zooming spectrograms
Work for #120 Started dissemenating a virtual file system into the zooming code and have been generally refactoring.
- Loading branch information
Showing
34 changed files
with
507 additions
and
834 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// <copyright file="AnalysisIo.cs" company="QutEcoacoustics"> | ||
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group). | ||
// </copyright> | ||
|
||
namespace Acoustics.Shared | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Zio; | ||
|
||
public class AnalysisIo | ||
{ | ||
public AnalysisIo(IFileSystem input, IFileSystem output, IFileSystem temp) | ||
{ | ||
this.Input = input; | ||
this.Output = output; | ||
this.Temp = temp ?? input; | ||
} | ||
|
||
public IFileSystem Input { get; } | ||
|
||
public IFileSystem Output { get; } | ||
|
||
public IFileSystem Temp { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// <copyright file="ZioExtensions.cs" company="QutEcoacoustics"> | ||
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group). | ||
// </copyright> | ||
|
||
namespace Zio | ||
{ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using FileSystems; | ||
|
||
public static class ZioExtensions | ||
{ | ||
private static readonly PhysicalFileSystem FileSystem = new PhysicalFileSystem(); | ||
|
||
public static UPath ToUPath(this FileSystemInfo file) | ||
{ | ||
return FileSystem.ConvertPathFromInternal(file.FullName); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
Acoustics/Acoustics.Test/AnalysisPrograms/Draw/Zooming/DrawZoomingTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
// <copyright file="TestAnalyzeLongRecording.cs" company="QutEcoacoustics"> | ||
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group). | ||
// </copyright> | ||
|
||
namespace Acoustics.Test.AnalysisPrograms.Draw.Zooming | ||
{ | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using Acoustics.Shared; | ||
using global::AnalysisPrograms.AnalyseLongRecordings; | ||
using global::AnalysisPrograms.Draw.Zooming; | ||
using global::AudioAnalysisTools.DSP; | ||
using global::AudioAnalysisTools.Indices; | ||
using global::AudioAnalysisTools.LongDurationSpectrograms; | ||
using global::TowseyLibrary; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using TestHelpers; | ||
|
||
[TestClass] | ||
public class DrawZoomingTests : OutputDirectoryTest | ||
{ | ||
private DirectoryInfo resultsDirectory; | ||
|
||
[ClassInitialize] | ||
public void ClassInitialize() | ||
{ | ||
// calculate indices | ||
var recordingPath = PathHelper.ResolveAsset("Recordings", "OxleyCreek_site_1_1060_244333_20140529T081358+1000_120_0.wav"); | ||
var configPath = PathHelper.ResolveConfigFile("Towsey.Acoustic.HiRes.yml"); | ||
var arguments = new AnalyseLongRecording.Arguments | ||
{ | ||
Source = recordingPath, | ||
Config = configPath, | ||
Output = this.outputDirectory, | ||
TempDir = this.outputDirectory.Combine("Temp"), | ||
}; | ||
|
||
AnalyseLongRecording.Execute(arguments); | ||
|
||
this.resultsDirectory = this.outputDirectory.Combine("Towsey.Acoustic"); | ||
|
||
// do some basic checks that the indices were generated | ||
var listOfFiles = this.resultsDirectory.EnumerateFiles().ToArray(); | ||
Assert.AreEqual(33, listOfFiles.Length); | ||
var csvCount = listOfFiles.Count(f => f.Name.EndsWith(".csv")); | ||
Assert.AreEqual(16, csvCount); | ||
var jsonCount = listOfFiles.Count(f => f.Name.EndsWith(".json")); | ||
Assert.AreEqual(2, jsonCount); | ||
var pngCount = listOfFiles.Count(f => f.Name.EndsWith(".png")); | ||
Assert.AreEqual(0, pngCount); | ||
|
||
} | ||
|
||
/// <summary> | ||
/// Tests the rendering of zooming spectrograms for a minute of audio indices | ||
/// </summary> | ||
[TestMethod] | ||
[Timeout(45_000)] | ||
public void TestGenerateTiles() | ||
{ | ||
// generate the zooming spectrograms | ||
var zoomOutput = this.outputDirectory.Combine("Zooming"); | ||
DrawZoomingSpectrograms.Execute( | ||
new DrawZoomingSpectrograms.Arguments() | ||
{ | ||
Output = zoomOutput.FullName, | ||
SourceDirectory = resultsDirectory.FullName, | ||
SpectrogramZoomingConfig = PathHelper.ResolveConfigFile("SpectrogramZoomingConfig.yml"), | ||
ZoomAction = DrawZoomingSpectrograms.Arguments.ZoomActionType.Tile, | ||
}); | ||
|
||
Assert.Fail(); | ||
} | ||
|
||
/// <summary> | ||
/// Tests the rendering of zooming spectrograms for a minute of audio indices | ||
/// </summary> | ||
[TestMethod] | ||
[Timeout(45_000)] | ||
public void TestGenerateTilesSqlite() | ||
{ | ||
// generate the zooming spectrograms | ||
var zoomOutput = this.outputDirectory.CombineFile("Zooming/tiles.sqlite3"); | ||
DrawZoomingSpectrograms.Execute( | ||
new DrawZoomingSpectrograms.Arguments() | ||
{ | ||
Output = zoomOutput.FullName, | ||
SourceDirectory = resultsDirectory.FullName, | ||
SpectrogramZoomingConfig = PathHelper.ResolveConfigFile("SpectrogramZoomingConfig.yml"), | ||
ZoomAction = DrawZoomingSpectrograms.Arguments.ZoomActionType.Tile, | ||
}); | ||
|
||
Assert.IsTrue(File.Exists(zoomOutput.FullName)); | ||
Assert.Fail(); | ||
} | ||
|
||
|
||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Acoustics/Acoustics.Test/AnalysisPrograms/Production/FileSystemProviderTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// <copyright file="FileSystemProviderTests.cs" company="QutEcoacoustics"> | ||
// All code in this file and all associated files are the copyright and property of the QUT Ecoacoustics Research Group (formerly MQUTeR, and formerly QUT Bioacoustics Research Group). | ||
// </copyright> | ||
|
||
namespace Acoustics.Test.AnalysisPrograms.Production | ||
{ | ||
using System; | ||
using System.IO; | ||
using global::AnalysisPrograms.Production; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using TestHelpers; | ||
using Zio; | ||
using Zio.FileSystems; | ||
using Zio.FileSystems.Community.SqliteFileSystem; | ||
|
||
[TestClass] | ||
public class FileSystemProviderTests : OutputDirectoryTest | ||
{ | ||
[DataTestMethod] | ||
[DataRow("")] | ||
[DataRow(null)] | ||
public void TestFullFileSystem(string path) | ||
{ | ||
var fs = FileSystemProvider.DetermineFileSystem(path); | ||
|
||
Assert.IsInstanceOfType(fs, typeof(PhysicalFileSystem)); | ||
} | ||
|
||
[TestMethod] | ||
public void TestSubFileSystem() | ||
{ | ||
var fs = FileSystemProvider.DetermineFileSystem(this.outputDirectory.FullName); | ||
|
||
Assert.IsInstanceOfType(fs, typeof(SubFileSystem)); | ||
|
||
Assert.AreEqual(this.outputDirectory.ToUPath(), ((SubFileSystem)fs).SubPath); | ||
} | ||
|
||
[TestMethod] | ||
public void TestSqliteFileSystem() | ||
{ | ||
var path = this.outputDirectory.FullName + "\\test.sqlite3"; | ||
var fs = FileSystemProvider.DetermineFileSystem(path); | ||
|
||
Assert.IsInstanceOfType(fs, typeof(SqliteFileSystem)); | ||
|
||
StringAssert.Contains(((SqliteFileSystem)fs).ConnectionString, path); | ||
Assert.IsTrue(File.Exists(path)); | ||
} | ||
|
||
[TestMethod] | ||
public void TestInvalidFileSystem() | ||
{ | ||
Assert.ThrowsException<NotSupportedException>( | ||
() => FileSystemProvider.DetermineFileSystem(this.outputDirectory.FullName + "\\test.zip")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...est/TestResources/Recordings/OxleyCreek_site_1_1060_244333_20140529T081358+1000_120_0.wav
Git LFS file not shown
File renamed without changes.
Oops, something went wrong.