Skip to content

Commit

Permalink
Add AtmosProfile types
Browse files Browse the repository at this point in the history
  • Loading branch information
charleskawczynski committed Feb 9, 2022
1 parent e09e376 commit 8c51c96
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/AtmosProfileTypes.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8c51c96

Please sign in to comment.