From 8c51c96f3fe244bf9992454540a9efee9c6636ae Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Tue, 8 Feb 2022 16:20:43 -0800 Subject: [PATCH] Add AtmosProfile types --- src/AtmosProfileTypes.jl | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/AtmosProfileTypes.jl diff --git a/src/AtmosProfileTypes.jl b/src/AtmosProfileTypes.jl new file mode 100644 index 0000000..131e36c --- /dev/null +++ b/src/AtmosProfileTypes.jl @@ -0,0 +1,40 @@ +#= This is an experimental design, but perhaps it's not needed.=# +module AtmosProfileTypes + +abstract type AbstractProfileType end +abstract type AbstractProfile1D <: AbstractProfileType end +abstract type AbstractProfile2D <: AbstractProfileType end +struct zProfile <: AbstractProfile1D end +struct tProfile <: AbstractProfile1D end +struct tzProfile <: AbstractProfile2D end + +""" + AtmosphericProfile{T}(profile::P) + +An atmospheric profile, which is callable +object or function with arguments: + + - `profile(z)` (altitude [m]) + - `profile(t)` (time [s]) + - `profile(t, z)` (time [s], altitude [m]) + +For example, if we just use a function, we have +```julia +profile = z-> 2*z +``` +We can call this function with `profile(10.0)`. +""" +struct AtmosphericProfile{T, P} + profile::P + AtmosphericProfile{T}(profile::P) where {T, P} = new{T, P}(profile) +end + +function (p::AtmosphericProfile{<:AbstractProfile2D})(t, z) + p.profile(t, z) +end + +function (p::AtmosphericProfile{<:AbstractProfile1D})(z_or_t) + p.profile(z_or_t) +end + +end # module \ No newline at end of file