From 9f390ab03cb6c89871dd7906b42412765ec4b45a Mon Sep 17 00:00:00 2001 From: Anthony Truskinger Date: Fri, 19 Oct 2018 12:22:31 +1000 Subject: [PATCH] General upadates to docs, scripts, code style A bunch of maintenance changes. Tweaks to code style to adhere to our style guide, started creatin of a Release protocols document, added a copy of our ribbon generation script --- .editorconfig | 15 +++-- .github/ISSUE_TEMPLATE/bug_report.md | 30 ++++------ AudioAnalysis.sln.DotSettings | 2 + CHANGELOG.md | 0 CONTRIBUTING.md | 2 +- build/README.md | 17 ++++++ scripts/README.md | 6 +- scripts/ribbon_plot.ps1 | 89 ++++++++++++++++++++++++++++ 8 files changed, 132 insertions(+), 29 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 build/README.md create mode 100644 scripts/ribbon_plot.ps1 diff --git a/.editorconfig b/.editorconfig index 5057d58aa..ed9cf4555 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,6 +2,8 @@ # Common Settings ################# +# How resharper interprets these rules: https://www.jetbrains.com/help/resharper/EditorConfig_Index.html + # This file is the top-most EditorConfig file root = true @@ -66,7 +68,7 @@ dotnet_style_predefined_type_for_member_access = true:warning # Modifier preferences # https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#normalize_modifiers dotnet_style_require_accessibility_modifiers = always:warning -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async +csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning dotnet_style_readonly_field = true:warning # Expression-level preferences # https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#expression_level @@ -89,12 +91,12 @@ dotnet_style_prefer_conditional_expression_over_assignment = false [*.{cs,csx,cake}] # Implicit and explicit types # https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#implicit-and-explicit-types -csharp_style_var_for_built_in_types = true:warning -csharp_style_var_when_type_is_apparent = true:warning -csharp_style_var_elsewhere = true:warning +csharp_style_var_for_built_in_types = true:none +csharp_style_var_when_type_is_apparent = true:none +csharp_style_var_elsewhere = true:none # Expression-bodied members # https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference#expression_bodied_members -csharp_style_expression_bodied_methods = true:warning +csharp_style_expression_bodied_methods = when_on_single_line:warning csharp_style_expression_bodied_constructors = true:warning csharp_style_expression_bodied_operators = true:warning csharp_style_expression_bodied_properties = true:warning @@ -148,7 +150,7 @@ csharp_space_after_cast = false:warning csharp_space_after_keywords_in_control_flow_statements = true:warning csharp_space_between_method_declaration_parameter_list_parentheses = false:warning csharp_space_between_method_call_parameter_list_parentheses = false:warning -csharp_space_between_parentheses = expressions:warning +#csharp_space_between_parentheses = csharp_space_before_colon_in_inheritance_clause = true:warning csharp_space_after_colon_in_inheritance_clause = true:warning csharp_space_around_binary_operators = before_and_after:warning @@ -167,6 +169,7 @@ csharp_space_after_comma = true:warning csharp_space_after_dot = false:warning csharp_space_after_semicolon_in_for_statement = true:warning csharp_space_around_declaration_statements = do_not_ignore:warning +csharp_space_around_dot = false:warning csharp_space_before_comma = false:warning csharp_space_before_dot = false:warning csharp_space_before_semicolon_in_for_statement = false:warning diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 69106d7e5..74a4b07e4 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -17,25 +17,17 @@ A clear and concise description of what you expected to happen. ## Diagnostics -- [ ] I Confirm I have followed [the instructions for reporting a bug](https://github.com/QutEcoacoustics/audio-analysis/blob/master/docs/bug_report.md) -- [ ] I have attached a log - - ... -- [ ] I have answered the following questions - -**Operating system:** - ... - -**AP.exe version:** - ... - -**The data used can be found:** - ... - -**The command I used:** - ... - -**The config file I used:** - ... +- I Confirm I have followed [the instructions for reporting a bug](https://github.com/QutEcoacoustics/audio-analysis/blob/master/docs/bug_report.md) +- I have attached a log +- I have answered the following questions: + + - **Operating system:** + + - **AP.exe version:** + + - **The data used can be found:** + - **The command I used:** + - **The config file I used:** ### Screenshots diff --git a/AudioAnalysis.sln.DotSettings b/AudioAnalysis.sln.DotSettings index 5fb627954..06db6cbcf 100644 --- a/AudioAnalysis.sln.DotSettings +++ b/AudioAnalysis.sln.DotSettings @@ -1,6 +1,7 @@  False DO_NOT_SHOW + True 15 1 NEVER @@ -8,6 +9,7 @@ False True False + <?xml version="1.0" encoding="utf-16"?> <Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"> <TypePattern DisplayName="Non-reorderable types"> diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..e69de29bb diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6708bfb46..33f350334 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -26,7 +26,7 @@ Best Practices Required Software ----------------- -The required software for devleoping new code (not running the program) includes: +The required software for developing new code (not running the program) includes: - A Windows OS (we're working on making this Linux compatible) - Visual Studio 2017 diff --git a/build/README.md b/build/README.md new file mode 100644 index 000000000..15433ef9e --- /dev/null +++ b/build/README.md @@ -0,0 +1,17 @@ +# Build folder + +This folder contains script used to build resources for the audio-analysis +project. + + + +## Creating a release + +1. Make sure tests pass +1. Update changelog +1. Push a commit to with the token `[RELEASE]` somewhere in the commit message + +Ensure: +- Zenodo record published +- Update the citation in the readme +- Github Release has been published \ No newline at end of file diff --git a/scripts/README.md b/scripts/README.md index e69251968..da399d8d0 100644 --- a/scripts/README.md +++ b/scripts/README.md @@ -6,7 +6,7 @@ This has a few advantages: **It simplifies the code**. We don't need to know about the particular way you store your data, or the way you want your data processed. -**It allows for greater customiszation**. By building a set of composable +**It allows for greater customization**. By building a set of composable tools, it allows you to choose what analysis done, and when. You wan't it all? You got it. You only want the first bit done once, and the second done 100 times with parameter sweeps? Go for it. @@ -28,14 +28,14 @@ include it here as an example for others to use. ## PowerShell You'll see a lot of scripts in this folder that are written in PowerShell. -If you're not familar with it, you can consider it as the Windows equivalent +If you're not familiar with it, you can consider it as the Windows equivalent of the Bash shell. @atruskie like's PowerShell because in their personal opinion, the syntax is more reasonable than Bash, and the enhanced support for dates, times, and regular expressions are well worth the investment. As of [PowerShell 6.0](https://github.com/PowerShell/PowerShell#-powershell) the shell is cross platform and well worth investigating. If you're not -convinced, the scripts should be easy enough to reimplment in your favourite +convinced, the scripts should be easy enough to reimplement in your favourite language (like Bash)--and we would of course appreciate any translated scripts sent back to us as contributed examples. diff --git a/scripts/ribbon_plot.ps1 b/scripts/ribbon_plot.ps1 new file mode 100644 index 000000000..a1b040c5d --- /dev/null +++ b/scripts/ribbon_plot.ps1 @@ -0,0 +1,89 @@ +# Creates a single image that shows ribbon plots stacked vertically +# Anthony Truskinger 2018 +# +# For each image file with the phrase "SpectralRibbon" in it's name +# found in a given directory it: +# - Groups the image based on it's type (e.g. ACI-ENT-EVN) +# - Sorts the images by date +# - Joins the spectral ribbons together to make a ribbon plot +# - Generates a date strip image +# - Then joins the date strip image to the ribbon plot +# - And saves the resulting image to the same folder +# +# Assumptions: +# - The input directories contain indices results +# - You want a grid of 1xN images (This could be paramterized in an update to the script) +# - The user will modify the $working_dirs variable before they run the script + + +$working_dirs = @( + "Y:\Results\20181010-115050\ConcatResult\TimedGaps\Sturt\2015July\Mistletoe", + "Y:\Results\20181010-115050\ConcatResult\TimedGaps\Sturt\2016Sep\Stud\CardA" +) + +$image_wildcard = "*.SpectralRibbon.png" + + +foreach ($working_dir in $working_dirs) { + Write-Output "Generating ribbon plots for $working_dir" + $all_images = Get-ChildItem -Recurse $working_dir -Include $image_wildcard + + # sort and bucket images + $image_types = @{} + + foreach ($image in $all_images) { + if ($image.FullName -match ".*(\d{8}).*__([-\w]{11})\..*") { + $date = [datetime]::ParseExact($Matches[1], "yyyyMMdd", [cultureinfo]::InvariantCulture) + $type = $Matches[2] + + $image_date = [PSCustomObject]@{ + Date = $date + File = $image + } + + if (-not $image_types[$type]) { + $image_types[$type] = @(, $image_date) + } + else { + $image_types[$type] += $image_date + } + } + else { + throw "Unexpected file name pattern encountered $image" + } + } + + foreach ($image_type in $image_types.Keys) { + + $sorted_images = $image_types[$image_type] | Sort-Object Date + + $n = $sorted_images.Count + # stack ribbons + $command = "magick montage -background '#333' -tile '1x' -gravity West -geometry +4+4 " + $command += ($sorted_images | ForEach-Object { + + " '$($_.File.FullName)' " + }) -join ' ' + $command += " '$working_dir/stacked_ribbon_plot_$image_type`_ribbons.png'" + + Write-Output "Generating ribbon plot for $image_type..." + Invoke-Expression $command + + # stack labels + $command = "magick -background '#333' -fill '#FFF' -gravity Center " + $command += ($sorted_images | ForEach-Object { + $date = $_.Date.ToString("yyyy-MM-dd") + " -size 200x40 -gravity center label:'$date'" + }) -join ' ' + $command += " -append '$working_dir/stacked_ribbon_plot_$image_type`_dates.png'" + + Write-Output "Generating y-axis for $image_type..." + Invoke-Expression $command + + # combine labels, ribbons, and then stick an axis on the bottom + $two_map = (Get-ChildItem ($sorted_images[0].File.Directory.FullName + "/*2Maps.png")).FullName + Write-Output "Joining ribbon plot, y-axis, and x-axis for $image_type..." + magick "$working_dir/stacked_ribbon_plot_$image_type`_dates.png" "$working_dir/stacked_ribbon_plot_$image_type`_ribbons.png" +append "xwd:-" | magick -gravity SouthEast "xwd:-" `( "$two_map" -crop "1440x18+0+0" -background '#333' -splice 4x0+0+0 `) -append "$working_dir/stacked_ribbon_plot_$image_type.png" + + } +} \ No newline at end of file