-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrated and improved from previous iteration
Tests to come
- Loading branch information
Showing
40 changed files
with
472 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,13 @@ uuid = "03019ade-4524-4ecd-af79-46d4f04a1b56" | |
authors = ["Aaron Kaw <[email protected]> and contributors"] | ||
version = "1.0.0-DEV" | ||
|
||
[deps] | ||
IntervalArithmetic = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253" | ||
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3" | ||
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7" | ||
|
||
[compat] | ||
IntervalArithmetic = "0.22.14" | ||
NaNMath = "1.0.2" | ||
Symbolics = "5.34.0" | ||
julia = "1.10" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# New Users Introduction | ||
|
||
"New" could apply to users as some combination of: | ||
|
||
```@contents | ||
Pages = ["01_new_users_introduction.md"] | ||
Depth = 2:2 | ||
``` | ||
|
||
of which this page addresses all three, linked in the above list. | ||
|
||
## New to the Field of Ocean Sonar | ||
|
||
## New to Julia Programming | ||
|
||
## New to Scientific Machine Learning | ||
|
||
## New to this Package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Ocean Acoustics |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Ray Tracing | ||
|
||
## Literature Fidelity | ||
|
||
## References |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Beam Tracing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Pressure Field |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
export uniquesort! | ||
export efficient_sampling | ||
export output_extrema | ||
|
||
const uniquesort! = unique! ∘ sort! | ||
|
||
const cossin = reverse ∘ sincos | ||
const nan_cossin = reverse ∘ nan_sincos | ||
const cossind = reverse ∘ sincosd | ||
const magang(z::Number) = (abs(z), angle(z)) | ||
|
||
function extract_all_underscored_alphanumeric_bodies(text::AbstractString) | ||
idxs = findall(r"([a-z]|[A-Z]|[0-9]|_)+", text) | ||
return getindex.(text, idxs) | ||
end | ||
|
||
function extract_first_underscored_alphanumeric_bodies(text::AbstractString) | ||
return extract_all_underscored_alphanumeric_bodies(text)[1] | ||
end | ||
|
||
function extract_last_underscored_alphanumeric_bodies(text::AbstractString) | ||
return extract_all_underscored_alphanumeric_bodies(text)[end] | ||
end | ||
|
||
function efficient_sampling(f::Function, x1::Real, xN::Real, N::Integer) | ||
# WIP, to be replaced | ||
range(x1, xN, N) | ||
end | ||
|
||
# function efficient_sampling(f::Function, x1::Real, xN::Real, θmin::Real) | ||
# # WIP | ||
# end | ||
|
||
output_extrema(f::Function, ntv::Interval) = (:lo, :hi) .|> bnd -> getproperty(f(ntv).bareinterval, bnd) | ||
output_extrema(f::Function, x_lo::Real, x_hi::Real) = output_extrema(f, interval(x_lo, x_hi)) |
19 changes: 19 additions & 0 deletions
19
src/01_preliminary/01_general/02_flexible_math_functions.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export ocnson_sqrt | ||
|
||
num_fcn(fcn::Function, args::Num...) = Term(fcn, [args...]) |> wrap | ||
|
||
for op in (:sqrt, :cos, :sin, :cossin) | ||
op_string = String(op) | ||
ocnson_op = Symbol("ocnson_" * op_string) | ||
nan_op = Symbol("nan_" * op_string) | ||
eval( | ||
quote | ||
$ocnson_op(x::Real) = $nan_op(x) | ||
$ocnson_op(x::Num) = $op(x) | ||
$ocnson_op(x::Interval) = $op(x) | ||
end | ||
) | ||
end | ||
|
||
ocnson_hypot(args::Number...) = nan_hypot(args...) | ||
ocnson_hypot(args::Union{<:Num, <:Interval}...) = hypot(args...) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
public stringcase | ||
public titlecase | ||
export snakecase | ||
export kebabcase | ||
export pascalcase | ||
|
||
""" | ||
Storage of all words that need to keep their case as is stored here, | ||
e.g. acronyms, articles, prepositions, coordinating conjunctions, etc. | ||
""" | ||
keepcases = [ | ||
"NSW" | ||
"the" | ||
"a" | ||
"to" | ||
] |> uniquesort! | ||
|
||
delims = ( | ||
snake = "_", | ||
space = " ", | ||
kebab = "-" | ||
) | ||
|
||
_stringcasesep(::Val{C}) where C = delims[C] | ||
_stringcasesep(::Val{:camel}) = "" | ||
_stringcasesep(::Val{:Snake}) = _stringcasesep(:snake |> Val) | ||
_stringcasesep(::Val{:Space}) = _stringcasesep(:space |> Val) | ||
_stringcasesep(::Val{:Kebab}) = _stringcasesep(:kebab |> Val) | ||
_stringcasesep(::Val{:Camel}) = _stringcasesep(:camel |> Val) | ||
_stringcasesep(::Val{:pascal}) = _stringcasesep(:Camel |> Val) | ||
_stringcasesep(::Val{:Pascal}) = _stringcasesep(:Camel |> Val) | ||
_stringcasesep(::Val{:title}) = _stringcasesep(:Space |> Val) | ||
|
||
function _firstcap(::Val{C}, char::Char) where C | ||
return if (C in (:pascal, :title)) || isuppercase(String(C)[1]) | ||
uppercase(char) | ||
else | ||
lowercase(char) | ||
end | ||
end | ||
|
||
function _sepcap(::Val{C}, char::Char) where C | ||
return if (C in (:pascal, :title, :camel)) || isuppercase(String(C)[1]) | ||
uppercase(char) | ||
else | ||
lowercase(char) | ||
end | ||
end | ||
|
||
function _wordseparation(case::Val{C}, text::AbstractString) where C | ||
text = text[1:end-1] * _sepcap(case, text[end]) | ||
end | ||
|
||
function _caseconversions(::Val{C}, text::AbstractString; keepcases) where C | ||
boolkeepcase = lowercase(text) .== lowercase.(keepcases) | ||
iskeepcase = any(boolkeepcase) | ||
keepcase = if iskeepcase | ||
keepcases[boolkeepcase |> findall |> only] | ||
else | ||
"" | ||
end | ||
|
||
iscamel = C in (:pascal, :Pascal, :camel, :Camel) | ||
return if iskeepcase && (iscamel ? isuppercase(keepcase[1]) : true) | ||
keepcase | ||
elseif (C in (:pascal, :title, :camel)) || isuppercase(String(C)[1]) | ||
uppercase(text[1]) * text[2:end] | ||
else | ||
text | ||
end | ||
end | ||
|
||
function stringcase(case::Val{C}, text::AbstractString; keepcases = keepcases) where C | ||
tempsep = delims.snake | ||
|
||
# Convert camel word separations to snake separations | ||
camel_regexes = [ | ||
"[a-z][A-Z]" | ||
"[0-9][A-Z]" | ||
"[a-z][0-9]" | ||
"[A-Z][0-9]" | ||
] .|> Regex | ||
for camel_regex = camel_regexes | ||
text = replace(text, | ||
[ | ||
text[idxs] => text[idxs[begin]] * tempsep * text[idxs[end]] | ||
for idxs in findall(camel_regex, text, overlap = true) | ||
]... | ||
) | ||
end | ||
|
||
text = lowercase(text) | ||
|
||
# Convert any delimiters to snake delimiter | ||
text = replace(text, [sep => tempsep for sep in values(delims)]...) | ||
|
||
texts = split(text, tempsep) | ||
|
||
texts = [_caseconversions(case, text, keepcases = keepcases) for text in texts] | ||
|
||
text = join(texts, _stringcasesep(case)) | ||
|
||
text = _firstcap(case, text[1]) * text[2:end] | ||
|
||
return text | ||
end | ||
|
||
stringcase(::Val{:Pascal}, text::AbstractString; keepcases = keepcases) = stringcase(:Camel |> Val, text; keepcases = keepcases) | ||
stringcase(::Val{:pascal}, text::AbstractString; keepcases = keepcases) = stringcase(:Camel |> Val, text; keepcases = keepcases) | ||
stringcase(::Val{:title}, text::AbstractString; keepcases = keepcases) = stringcase(:Space |> Val, text; keepcases = keepcases) | ||
|
||
stringcase(case::Symbol, text::AbstractString; keepcases = keepcases) = stringcase(case |> Val, text; keepcases = keepcases) | ||
stringcase(case::AbstractString, text::AbstractString; keepcases = keepcases) = stringcase(case |> Symbol, text; keepcases = keepcases) | ||
|
||
titlecase(text::AbstractString; keepcases = keepcases) = stringcase(:Space |> Val, text; keepcases = keepcases) | ||
snakecase(text::AbstractString; keepcases = keepcases) = stringcase(:snake |> Val, text; keepcases = keepcases) | ||
kebabcase(text::AbstractString; keepcases = keepcases) = stringcase(:Kebab |> Val, text; keepcases = keepcases) | ||
pascalcase(text::AbstractString; keepcases = keepcases) = stringcase(:Pascal |> Val, text; keepcases = keepcases) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export ModelName | ||
|
||
struct ModelName{m} end | ||
|
||
ModelName(m::Symbol) = ModelName(m |> String) | ||
|
||
ModelName(m::AbstractString) = ModelName{m |> snakecase |> Symbol}() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
abstract type AbstractModellingType <: Function end | ||
abstract type ModellingFunction <: AbstractModellingType end | ||
abstract type ModellingFunctor <: AbstractModellingType end | ||
abstract type ModellingFunctor2D <: ModellingFunctor end | ||
abstract type ModellingFunctor3D <: ModellingFunctor end | ||
|
||
function (::Type{Fun})( | ||
model::Union{Symbol, <:AbstractString}, args::Real...; kw... | ||
) where {Fun <: ModellingFunction} | ||
Fun(model |> ModelName, args...; kw...) | ||
end | ||
|
||
function (::Type{Fct})(model::ModelName; pars...) where {Fct <: ModellingFunctor} | ||
Fct(model, pars) | ||
end | ||
|
||
macro implement_modelling_functor(super_type, name) | ||
@eval begin | ||
struct $name <: $super_type | ||
model::ModelName | ||
pars::Pairs | ||
end | ||
|
||
function $name(model::Union{Symbol, <:AbstractString}, args...; pars...) | ||
$name(model |> ModelName, args...; pars...) | ||
end | ||
|
||
function (fct::$name)(args::Real...) | ||
$name(fct.model, args...; fct.pars...) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
listmodels(modelling_function::AbstractModellingType) = [ | ||
modelpretty(modelling_function, type()) | ||
for type in [ | ||
collect(m.sig.types)[2] for m in methods(modelling_function) | ||
] if type <: ModelName | ||
] | ||
|
||
listmodels(fct::Fct) where {Fct<:ModellingFunctor} = String(Fct) |
Oops, something went wrong.