Skip to content

Commit

Permalink
Continued prototyping and some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kapple19 committed Aug 15, 2024
1 parent ea2991b commit fa44287
Show file tree
Hide file tree
Showing 7 changed files with 106 additions and 58 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# General
_*

# Julia
/Manifest.toml
/docs/Manifest.toml
/docs/build/
/test/Manifest.toml

# Typst
*-jlyfish.json
8 changes: 4 additions & 4 deletions demo/fan.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ fan = Fan("Gaussian",
)

r_ntv = interval(r_min, r_max)
z_min = r_ntv |> ati |> inf
z_max = r_ntv |> bty |> sup
z_min = r_ntv |> scen.env.srf.dpt |> inf
z_max = r_ntv |> scen.env.bot.dpt |> sup

fig = Figure()
axis = Axis(fig[1, 1], yreversed = true)
Expand Down Expand Up @@ -52,8 +52,8 @@ fan = Fan("Gaussian",
)

r_ntv = interval(r_min, r_max)
z_min = r_ntv |> ati |> inf
z_max = r_ntv |> bty |> sup
z_min = r_ntv |> scen.env.srf.dpt |> inf
z_max = r_ntv |> scen.env.bot.dpt |> sup

fig = Figure()
axis = Axis(fig[1, 1], yreversed = true)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
export Environment

mutable struct Environment <: ModellingContainer
srf::AcousticInterface{SurfaceInterface}
bot::AcousticInterface{BottomInterface}

atm::AcousticMedium{AtmosphereMedium}
ocn::AcousticMedium{OceanMedium}
sbd::AcousticMedium{SeabedMedium}

orienter::Function

function Environment(;
ocn::AcousticMedium{OceanMedium} = AcousticMedium{OceanMedium}(:Homogeneous),
bot::AcousticInterface{BottomInterface} = AcousticInterface{BottomInterface}(:TranslucentDeep),
atm::AcousticMedium{AtmosphereMedium} = AcousticMedium{AtmosphereMedium}(:Calm),
srf::AcousticInterface{SurfaceInterface} = AcousticInterface{SurfaceInterface}(:Translucent),
sbd::AcousticMedium{SeabedMedium} = AcousticMedium{SeabedMedium}(:Homogeneous),
orienter::Function = (args...) -> orient(SpatialDimensionSize{3}, args...; x₀ = 0.0, y₀ = 0.0, θ = 0.0)
)
new(srf, bot, atm, ocn, sbd, orienter)
end
@kwdef mutable struct Environment <: ModellingContainer
atm::AcousticMedium{AtmosphereMedium} = AcousticMedium{AtmosphereMedium}(:Calm)
ocn::AcousticMedium{OceanMedium} = AcousticMedium{OceanMedium}(:Homogeneous)
sbd::AcousticMedium{SeabedMedium} = AcousticMedium{SeabedMedium}(:Homogeneous)

srf::AcousticInterface{SurfaceInterface} = AcousticInterface{SurfaceInterface}(:Translucent)
bot::AcousticInterface{BottomInterface} = AcousticInterface{BottomInterface}(:TranslucentDeep)

orienter::Function = (args...) -> orient(SpatialDimensionSize{3}, args...; x₀ = 0.0, y₀ = 0.0, θ = 0.0)

NL::Float32 = 0.0
end

## Models
Expand Down
86 changes: 86 additions & 0 deletions src/99_postliminary/03_computations/02_performance_.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
source_level(own::Entity{Signaling}, tgt::Entity{NoiseOnly}, fac::AbsentEntity = AbsentEntity()) = own.SL
source_level(own::Entity{NoiseOnly}, tgt::Entity{NoiseOnly}, fac::AbsentEntity = AbsentEntity()) = tgt.NL
source_level(own::Entity{NoiseOnly}, tgt::Entity{Signaling}, fac::AbsentEntity = AbsentEntity()) = tgt.SL
source_level(own::Entity{NoiseOnly}, tgt::Entity{NoiseOnly}, fac::Entity{Signaling} ) = fac.SL

target_strength(own::Entity{Signaling}, tgt::Entity{NoiseOnly}, fac::AbsentEntity = AbsentEntity()) = tgt.TS
target_strength(own::Entity{NoiseOnly}, tgt::Entity, fac::AbsentEntity = AbsentEntity()) = 0.0
target_strength(own::Entity{NoiseOnly}, tgt::Entity{NoiseOnly}, fac::Entity{Signaling} ) = tgt.TS

@kwdef struct OceanGrid
r::Vector{Float64}
z::Vector{Float64}
θ::Vector{Float64}
end

struct SonarPropagation <: ModellingComputation
to_ownship::Fan
from_facilitator::Union{Nothing, Fan}

function SonarPropagation(env::Environment, grid::OceanGrid, own::Entity, fac::AbstractEntity)
new(
Fan(),
fac::AbsentEntity ? nothing : Fan()
)
end
end

transmission_loss(prop::SonarPropagation, own::Entity{Signaling}, tgt::Entity{NoiseOnly}, fac::AbsentEntity = AbsentEntity()) = 2 * prop.from_ownship
transmission_loss(prop::SonarPropagation, own::Entity{NoiseOnly}, tgt::Entity, fac::AbsentEntity = AbsentEntity()) = prop.from_ownship
transmission_loss(prop::SonarPropagation, own::Entity{NoiseOnly}, tgt::Entity{NoiseOnly}, fac::Entity{Signaling} ) = prop.from_ownship + prop.from_facilitator

reverberation_level(env::Environment, prop::SonarPropagation, own::Entity{Signaling}, tgt::Entity{NoiseOnly}, fac::AbsentEntity = AbsentEntity()) = reverberation_level(env, prop, own)
reverberation_level(env::Environment, prop::SonarPropagation, own::Entity{NoiseOnly}, tgt::Entity, fac::AbsentEntity = AbsentEntity()) = 0.0
reverberation_level(env::Environment, prop::SonarPropagation, own::Entity{NoiseOnly}, tgt::Entity{NoiseOnly}, fac::Entity{Signaling} ) = reverberation_level(env, prop, own, fac)

abstract type Processing end

struct Narrowband <: Processing
f::Float64
Pf::Float64
Pd::Float64

"`δt` FFT binwidth."
δt::Float64
end

detection_index(proc::Narrowband) = detection_index(:Narrowband, proc.Pf, proc.Pd)
detection_index(proc::Broadband) = detection_index(:Broadband, proc.Pf, proc.Pd)
detection_index(proc::Intercept) = detection_index(:Intercept, proc.Pf, proc.Pd)
detection_index(proc::ContinuousWave) = detection_index(:ContinuousWave, proc.Pf, proc.Pd)
detection_index(proc::FrequencyModulated) = detection_index(:FrequencyModulated, proc.Pf, proc.Pd)

processing_gain()

detection_threshold()

struct SonarPerformance <: ModellingComputation
SL
TL
TS
NL
RL
AG
SNR
DT
SE
POD

function SonarPerformance(env::Environment, proc::Processing, grid::OceanGrid, own::Entity, tgt::Entity, fac::AbstractEntity = AbsentEntity())
SL = source_level(own, tgt, fac)
prop = SonarPropagation(env, grid, own, fac)
TL = transmission_loss(prop, own, tgt, fac)
TS = target_strength(own, tgt, fac)
NL = env.NL own.NL
RL = reverberation_level(env, prop, own, tgt, fac)
AG = array_gain(env, own)
DT = detection_threshold(own, tgt, fac)

SNR = SL - TL + TS - ((NL - AG) RL)
SE = SNR - DT

POD = probability_of_detection(proc, own, tgt, fac, SE)

new(SL, TL, TS, NL, RL, AG, SNR, DT, SE, POD)
end
end
2 changes: 0 additions & 2 deletions src/99_postliminary/03_conveniences/00_preliminary.jl

This file was deleted.

25 changes: 0 additions & 25 deletions src/99_postliminary/03_conveniences/01_propagation.jl

This file was deleted.

7 changes: 0 additions & 7 deletions src/99_postliminary/03_conveniences/02_performance.jl

This file was deleted.

0 comments on commit fa44287

Please sign in to comment.