Skip to content

Commit

Permalink
Adds useful defaults to ConcatenateIndexFiles command
Browse files Browse the repository at this point in the history
Noe directory filter, file stem name, and both config files have defaults

Needs testing!
  • Loading branch information
atruskie committed Feb 10, 2020
1 parent ae7501e commit 8bc9008
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions src/AnalysisPrograms/ConcatenateIndexFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace AnalysisPrograms
using System.Reflection;
using System.Threading.Tasks;
using Acoustics.Shared;
using Acoustics.Shared.ConfigFile;
using Acoustics.Shared.Csv;
using AnalysisPrograms.Production;
using AnalysisPrograms.Production.Arguments;
Expand Down Expand Up @@ -77,8 +78,9 @@ public class Arguments : SubCommandBase
[LegalFilePath]
public DirectoryInfo OutputDirectory { get; set; }

[Option(Description = "Used to get the required data.csv files, which are assumed to be in a matching dir or sub-directory. E.g. use name of audio file suffix e.g.: *.wav")]
public string DirectoryFilter { get; set; }
[Option(Description =
"Used to get the required data.csv files, which are assumed to be in a matching dir or sub-directory. E.g. use name of audio file suffix e.g.: `*.wav`. The default is `*.wav`")]
public string DirectoryFilter { get; set; } = "*.wav";

[Option(
CommandOptionType.SingleValue,
Expand Down Expand Up @@ -173,6 +175,8 @@ public static void Execute(Arguments arguments)
!
! THIS IS A BETA COMMAND.
! It generally works but only for very narrow scenarios. Your mileage *will* vary.
!
! DO NOT USE THE OUTPUT INDICES FOR QUANTITATIVE ANALYSIS.
!");

if (arguments.InputDataDirectory != null)
Expand Down Expand Up @@ -267,6 +271,12 @@ public static void Execute(Arguments arguments)
output.Create();
}

if (arguments.FileStemName.IsNullOrEmpty())
{
arguments.FileStemName = arguments.InputDataDirectories.First().Name;
Log.Warn($"FileStemName was empty had a default value of `{arguments.FileStemName}` was used");
}

string outputFileStem = arguments.FileStemName;

// SET UP DEFAULT SITE LOCATION INFO -- DISCUSS IWTH ANTHONY
Expand All @@ -283,8 +293,28 @@ public static void Execute(Arguments arguments)

// the following are required if drawing the index images
IndexGenerationData indexGenerationData = null;
FileInfo indexPropertiesConfig = null;
FileInfo indexPropertiesConfig;
if (arguments.IndexPropertiesConfig.IsNullOrEmpty())
{
indexPropertiesConfig = ConfigFile.Default<IndexPropertiesCollection>();
Log.Warn($"IndexPropertiesConfig file not provided, using default: {indexPropertiesConfig}");
}
else
{
indexPropertiesConfig = ConfigFile.Resolve(arguments.IndexPropertiesConfig.ToString());
}

FileInfo ldSpectrogramConfigFile = null;
LdSpectrogramConfig ldSpectrogramConfig = null;
if (arguments.FalseColourSpectrogramConfig.IsNullOrEmpty())
{
ldSpectrogramConfigFile = ConfigFile.Default<LdSpectrogramConfig>();
Log.Warn($"FalseColourSpectrogramConfig file not provided, using default: {ldSpectrogramConfig}");
}
else
{
ldSpectrogramConfigFile = ConfigFile.Resolve(arguments.FalseColourSpectrogramConfig.ToString());
}

if (arguments.DrawImages)
{
Expand All @@ -299,9 +329,8 @@ public static void Execute(Arguments arguments)

// prepare the LDFC spgm config file or set up a default config
// WARNING: This default config is used when testing. If you alter these defaults, Unit Test results may be affected.
var colourSpectrogramConfig = arguments?.FalseColourSpectrogramConfig?.ToFileInfo();
ldSpectrogramConfig = (colourSpectrogramConfig?.Exists ?? false)
? LdSpectrogramConfig.ReadYamlToConfig(colourSpectrogramConfig)
ldSpectrogramConfig = (ldSpectrogramConfigFile?.Exists ?? false)
? LdSpectrogramConfig.ReadYamlToConfig(ldSpectrogramConfigFile)
: new LdSpectrogramConfig();

// the user should have provided ColorMap arguments which we insert here
Expand Down

0 comments on commit 8bc9008

Please sign in to comment.