Skip to content

Commit

Permalink
Getting ideas in
Browse files Browse the repository at this point in the history
  • Loading branch information
kapple19 committed Aug 6, 2024
1 parent 13a05c9 commit f0fff78
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 1 deletion.
11 changes: 11 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,16 @@ uuid = "03019ade-4524-4ecd-af79-46d4f04a1b56"
authors = ["Aaron Kaw <[email protected]> and contributors"]
version = "1.0.0-DEV"

[deps]
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[weakdeps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"

[extensions]
OceanSonarAbstractTreesExt = "AbstractTrees"

[compat]
AbstractTrees = "0.4"
InteractiveUtils = "1.11.0"
julia = "1.10"
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
OceanSonar = "03019ade-4524-4ecd-af79-46d4f04a1b56"
10 changes: 10 additions & 0 deletions ext/OceanSonarAbstractTreesExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module OceanSonarAbstractTreesExt
using OceanSonar
using AbstractTrees

import AbstractTrees: children

children(ST::Type{<:SonarType}) = subtypes(ST)
children(AM::Type{<:OceanSonar.AbstractModeller}) = subtypes(AM)

end
8 changes: 8 additions & 0 deletions src/00_preliminary/01_general/01_auxiliary.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# TODO: Update when Unitful.jl is incorporated into package.
function (levels...)
10log10(
(
@. 10^(levels/10)
) |> splat(+)
)
end
25 changes: 25 additions & 0 deletions src/03_processing/01_sonar_types.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export SonarType
export Passive
export Narrowband
export Broadband
export Intercept
export Active
export Monostatic
export Bistatic
export NoiseLimited
export ReverberationLimited

abstract type SonarType end

abstract type Passive <: SonarType end
abstract type Active <: SonarType end

abstract type Narrowband <: Passive end
abstract type Broadband <: Passive end
abstract type Intercept <: Passive end

abstract type Monostatic <: Active end
abstract type Bistatic <: Active end

abstract type NoiseLimited <: Monostatic end
abstract type ReverberationLimited <: Monostatic end
21 changes: 21 additions & 0 deletions src/03_processing/02_sonar_terms/signal_to_noise_ratio.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
"""
```
signal_to_noise_ratio(::Type{<:Passive}, SL::Real, PL::Real, NL::Real, DI::Real)::Float64
```
Computes the Signal-to-Noise Ratio (SNR) [dB] as a function of (Abraham, 2019, Section 2.3.4):
* `SL` Source Level [dB // μPa² m² @ 1 m]
* `PL` Propagation Loss [dB // m²]
* `NL` Noise Level [dB // μPa²]
* `AG` Array Gain [dB]
Implementation of Equation 2.48 of Abraham (2019).
"""
function signal_to_noise_ratio(::Type{<:Passive}, SL::Real, PL::Real, NL::Real, AG::Real)::Float64
SL - PL - NL + AG
end

function signal_to_noise_ratio(::Type{<:Monostatic}, SL::Real, PL::Real, TS::Real, RL::Real, NL::Real)::Float64
SL - 2PL + TS - (NL RL)
end
2 changes: 2 additions & 0 deletions src/06_postliminary/03_conveniences/00_preliminary.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
abstract type ConvenienceConfiguration end
abstract type ConvenienceComputation end
25 changes: 25 additions & 0 deletions src/06_postliminary/03_conveniences/01_propagation.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
struct PropagationConfiguration{Model <: ModelName} <: ConvenienceConfiguration
coherence::ModelName
beam::ModelName
end

struct Propagation2D{Model <: ModelName} <: ConvenienceComputation
config::PropagationConfiguration{Model}

r::Vector{Float64}
z::Vector{Float64}
p::Matrix{ComplexF64}
PL::Matrix{Float64}
end

struct Propagation3D{Model <: ModelName} <: ConvenienceComputation
config::PropagationConfiguration{Model}

# r::Vector{Float64}
# θ::Vector{Float64}
x::Vector{Float64}
y::Vector{Float64}
z::Vector{Float64}
p::Array{ComplexF64, 3}
PL::Array{Float64, 3}
end
7 changes: 7 additions & 0 deletions src/06_postliminary/03_conveniences/02_performance.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
struct PerformanceConfiguration <: ConvenienceConfiguration
sonar_type::SonarType
end

struct Performance2D <: ConvenienceConfiguration
prop::Propagation2D
end
8 changes: 7 additions & 1 deletion src/OceanSonar.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
module OceanSonar

export subtypes

using InteractiveUtils: subtypes

"""
```
include_subroots(path::AbstractString)
Expand All @@ -23,7 +27,7 @@ function include_subroots(current_path::AbstractString)
elseif isfile(subpath)
endswith(subpath, "_.jl") && continue
subpath == current_path && continue
@debug "Including: $subpath"
# @info "Including: $subpath"
subpath
else
error("What is ", subpath, "?")
Expand All @@ -33,4 +37,6 @@ end

include_subroots(@__FILE__)

const TRIGGER_RECOMPILATION_BY_CHANGING_THIS_NUMBER = 0

end
6 changes: 6 additions & 0 deletions test/99_postliminary/abstract_trees.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
using OceanSonar
using AbstractTrees
using Test

print_tree(SonarType)
print_tree(OceanSonar.AbstractModeller)
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
JET = "c3a54625-cd67-489e-a8e7-0a5a0ff4e31b"
OceanSonar = "03019ade-4524-4ecd-af79-46d4f04a1b56"
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ using SafeTestsets
@safetestset "Linting" include("00_preliminary/01_code_quality/linting.jl")
@safetestset "Docstrings" include("00_preliminary/01_code_quality/docstrings.jl")
end

name = "Postliminary Tests"
@time @testset "$name" begin
@info "Testing $name"
@safetestset "Abstract Trees" include("99_postliminary/abstract_trees.jl")
end
end

0 comments on commit f0fff78

Please sign in to comment.