Skip to content

Commit

Permalink
General upadates to docs, scripts, code style
Browse files Browse the repository at this point in the history
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
  • Loading branch information
atruskie committed Oct 19, 2018
1 parent f798788 commit 9f390ab
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 29 deletions.
15 changes: 9 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
30 changes: 11 additions & 19 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <!-- Drag and drop the log here -->
- I have answered the following questions:
<!-- e.g. Windows 10 Version 1809 -->
- **Operating system:**
<!-- e.g. 18.05.3.6 -->
- **AP.exe version:**
<!-- e.g. N/A if not available or not needed, or instructions on how to get the test data -->
- **The data used can be found:**
- **The command I used:**
- **The config file I used:** <!-- Drag and drop the config here -->


### Screenshots
Expand Down
2 changes: 2 additions & 0 deletions AudioAnalysis.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/CodeEditing/ContextActionTable/DisabledContextActions/=JetBrains_002EReSharper_002EIntentions_002ECSharp_002EContextActions_002EMisc_002ESurroundWithQuotesAction/@EntryIndexedValue">False</s:Boolean>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantCommaInInitializer/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:Boolean x:Key="/Default/CodeInspection/Highlighting/ReadSettingsFromFileLevel/@EntryValue">True</s:Boolean>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ThisQualifier/INSTANCE_MEMBERS_QUALIFY_MEMBERS/@EntryValue">15</s:String>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/BLANK_LINES_BEFORE_SINGLE_LINE_COMMENT/@EntryValue">1</s:Int64>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ACCESSORHOLDER_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ACCESSORHOLDER_ON_SINGLE_LINE/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_AFTER_TYPECAST_PARENTHESES/@EntryValue">False</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/STICK_COMMENT/@EntryValue">False</s:Boolean>

<s:String x:Key="/Default/CodeStyle/CSharpFileLayoutPatterns/Pattern/@EntryValue">&lt;?xml version="1.0" encoding="utf-16"?&gt;&#xD;
&lt;Patterns xmlns="urn:schemas-jetbrains-com:member-reordering-patterns"&gt;&#xD;
&lt;TypePattern DisplayName="Non-reorderable types"&gt;&#xD;
Expand Down
Empty file added CHANGELOG.md
Empty file.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions build/README.md
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

Expand Down
89 changes: 89 additions & 0 deletions scripts/ribbon_plot.ps1
Original file line number Diff line number Diff line change
@@ -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"

}
}

0 comments on commit 9f390ab

Please sign in to comment.