Skip to content

Commit

Permalink
Rendering of Gaps & Joins in concatenated sp.grams
Browse files Browse the repository at this point in the history
Changed name of class to GapsAndJoins.cs. Split indices class in two.
Chanded the rendering of NoGaps option. A little bit of Resharper.
  • Loading branch information
towsey authored and atruskie committed Dec 18, 2017
1 parent ddde715 commit fb5a196
Show file tree
Hide file tree
Showing 12 changed files with 486 additions and 398 deletions.
16 changes: 8 additions & 8 deletions AudioAnalysis/AnalysisPrograms/ConcatenateIndexFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ public static void Execute(Arguments arguments)

var dictionaryOfSummaryIndices = LdSpectrogramStitching.ConcatenateAllSummaryIndexFiles(summaryIndexFiles, resultsDir, indexGenerationData, opFileStem);

// REALITY CHECK - check for continuous zero indices or anything else that might indicate defective signal
// or incomplete analysis of recordings
var indexErrors = ErroneousIndexSegments.DataIntegrityCheck(dictionaryOfSummaryIndices, arguments.GapRendering);
ErroneousIndexSegments.WriteErrorsToFile(indexErrors, resultsDir, opFileStem);
// REALITY CHECK - check for continuous zero indices or anything else that might indicate defective signal,
// incomplete analysis of recordings, recording gaps or file joins.
var gapsAndJoins = GapsAndJoins.DataIntegrityCheck(dictionaryOfSummaryIndices, arguments.GapRendering);
GapsAndJoins.WriteErrorsToFile(gapsAndJoins, resultsDir, opFileStem);

if (arguments.DrawImages)
{
Expand All @@ -333,7 +333,7 @@ public static void Execute(Arguments arguments)

// ###### NOW CONCATENATE THE SPECTRAL INDICES, DRAW IMAGES AND SAVE IN RESULTS DIRECTORY
var dictionaryOfSpectralIndices1 = LdSpectrogramStitching.ConcatenateAllSpectralIndexFiles(subDirectories, keys, indexGenerationData);
indexErrors.AddRange(ErroneousIndexSegments.DataIntegrityCheck(dictionaryOfSpectralIndices1, arguments.GapRendering));
gapsAndJoins.AddRange(GapsAndJoins.DataIntegrityCheck(dictionaryOfSpectralIndices1, arguments.GapRendering));

// Calculate the index distribution statistics and write to a json file. Also save as png image
var indexDistributions = IndexDistributions.WriteSpectralIndexDistributionStatistics(dictionaryOfSpectralIndices1, resultsDir, opFileStem);
Expand All @@ -353,7 +353,7 @@ public static void Execute(Arguments arguments)
indexDistributions,
siteDescription,
arguments.SunRiseDataFile,
indexErrors,
gapsAndJoins,
ImageChrome.With);
}

Expand Down Expand Up @@ -414,8 +414,8 @@ public static void Execute(Arguments arguments)
}

// REALITY CHECK - check for zero signal and anything else that might indicate defective signal
List<ErroneousIndexSegments> indexErrors = ErroneousIndexSegments.DataIntegrityCheck(summaryDict, arguments.GapRendering);
ErroneousIndexSegments.WriteErrorsToFile(indexErrors, resultsDir, opFileStem1);
List<GapsAndJoins> indexErrors = GapsAndJoins.DataIntegrityCheck(summaryDict, arguments.GapRendering);
GapsAndJoins.WriteErrorsToFile(indexErrors, resultsDir, opFileStem1);

// DRAW SUMMARY INDEX IMAGES AND SAVE IN RESULTS DIRECTORY
if (arguments.DrawImages)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static void Execute(Arguments arguments)

double[] zeroSignalArray = summaryIndices.Select(si => si.ZeroSignal).ToArray();

var indexErrors = ErroneousIndexSegments.DataIntegrityCheckForZeroSignal(zeroSignalArray);
var indexErrors = GapsAndJoins.DataIntegrityCheckForZeroSignal(zeroSignalArray);

//config.IndexCalculationDuration = TimeSpan.FromSeconds(1.0);
//config.XAxisTicInterval = TimeSpan.FromSeconds(60.0);
Expand Down
53 changes: 28 additions & 25 deletions AudioAnalysis/AnalysisPrograms/Sandpit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public static void Dev(Arguments arguments)
Log.WriteLine("# Start Time = " + tStart.ToString(CultureInfo.InvariantCulture));

//Audio2CsvOverOneFile();
Audio2CsvOverMultipleFiles();
//Audio2CsvOverMultipleFiles();
//DrawLongDurationSpectrogram();
//ConcatenateIndexFilesAndSpectrograms();
ConcatenateIndexFilesAndSpectrograms();
//TestReadingFileOfSummaryIndices();
//TestsOfFrequencyScales();
//TestAnalyseLongRecordingUsingArtificialSignal();
Expand Down Expand Up @@ -93,31 +93,34 @@ public static void Audio2CsvOverMultipleFiles()
{
string drive = "G";
string outputDir = $"{ drive}:\\SensorNetworks\\Output\\IvanCampos\\Indexdata";
/*
string recordingDir = $"{ drive}:\\SensorNetworks\\WavFiles\\IvanCampos";
string configPath =
@"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\Towsey.Acoustic.yml";
string searchPattern = "*.wav";
//FileInfo[] csvFiles = IndexMatrices.GetFilesInDirectories(subDirectories, pattern);
string[] files = Directory.GetFiles(recordingDir, searchPattern);
LoggedConsole.WriteLine("File Count = " + files.Length);

for (int i = 0; i < files.Length; i++)
// (1) calculate the indices looping over mulitple files.
if (false)
{
string outputDirectory = outputDir + "\\" + i;
var devArguments = new AnalyseLongRecording.Arguments
string recordingDir = $"{drive}:\\SensorNetworks\\WavFiles\\IvanCampos";
string configPath =
@"C:\Work\GitHub\audio-analysis\AudioAnalysis\AnalysisConfigFiles\Towsey.Acoustic.yml";
string searchPattern = "*.wav";

//FileInfo[] csvFiles = IndexMatrices.GetFilesInDirectories(subDirectories, pattern);
string[] files = Directory.GetFiles(recordingDir, searchPattern);
LoggedConsole.WriteLine("File Count = " + files.Length);

for (int i = 0; i < files.Length; i++)
{
Source = files[i].ToFileInfo(),
Config = configPath.ToFileInfo(),
Output = outputDirectory.ToDirectoryInfo(),
MixDownToMono = true,
};
AnalyseLongRecording.Execute(devArguments);
string outputDirectory = $"{outputDir}\\{i:d3}";
var devArguments = new AnalyseLongRecording.Arguments
{
Source = files[i].ToFileInfo(),
Config = configPath.ToFileInfo(),
Output = outputDirectory.ToDirectoryInfo(),
MixDownToMono = true,
};
AnalyseLongRecording.Execute(devArguments);
}
}
*/

// now do the CONCATENATION
// (2) now do the CONCATENATION
DirectoryInfo[] dataDirs =
{
new DirectoryInfo(outputDir),
Expand Down Expand Up @@ -596,11 +599,10 @@ public static void ConcatenateIndexFilesAndSpectrograms()
string gapRendering = "TimedGaps"; // the default
bool concatenateEverythingYouCanLayYourHandsOn = false; // default is 24-hour blocks

/*
// ########################## CONCATENATION of Sarah Lowe's recordings
// The drive: work = G; home = E
drive = "G";

/*
// top level directory
DirectoryInfo[] dataDirs =
{
Expand All @@ -617,8 +619,8 @@ public static void ConcatenateIndexFilesAndSpectrograms()
// change PMN to POW because PMN not available in these recordings
colorMap2 = "BGN-PMN-R3D";
*/
// ########################## END of Sarah Lowe's recordings
*/

/*
// ########################## CONCATENATION of Yvonne's recordings of SM2 and SM4
Expand Down Expand Up @@ -655,6 +657,7 @@ public static void ConcatenateIndexFilesAndSpectrograms()
FileInfo sunriseDatafile = null;

concatenateEverythingYouCanLayYourHandsOn = true;

// start and end dates INCLUSIVE
dtoStart = new DateTimeOffset(2012, 08, 08, 0, 0, 0, TimeSpan.Zero);
dtoEnd = new DateTimeOffset(2012, 08, 08, 0, 0, 0, TimeSpan.Zero);
Expand Down
3 changes: 2 additions & 1 deletion AudioAnalysis/AudioAnalysisTools/AudioAnalysisTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,14 @@
<Compile Include="EventStatistics\EventStatisticsConfiguration.cs" />
<Compile Include="EventStatistics\EventStatisticsCalculate.cs" />
<Compile Include="FrommoltProject.cs" />
<Compile Include="Indices\ErroneousIndexSegments.cs" />
<Compile Include="Indices\GapsAndJoins.cs" />
<Compile Include="Indices\IndexCalculate.cs" />
<Compile Include="Indices\IndexCalculateConfig.cs" />
<Compile Include="Indices\IndexDistributions.cs" />
<Compile Include="Indices\IndexGenerationData.cs" />
<Compile Include="Indices\IndexMatrices.cs" />
<Compile Include="Indices\IndexProperties.cs" />
<Compile Include="Indices\SpectralIndexValues.cs" />
<Compile Include="Indices\SpectralIndicesToAndFromTable.cs" />
<Compile Include="Indices\SummaryIndexValues.cs" />
<Compile Include="Indices\InitialiseIndexProperties.cs" />
Expand Down
Loading

0 comments on commit fb5a196

Please sign in to comment.