Composite models
The model algebra defined by the AbstractSpectralModelKind
yields instances of CompositeModel
, nested to various degrees. These composite models are designed to make as much information about the spectral model available at compile-time, such that rich and optimized generated functions may be assembled purely from the Julia types (see Why & how).
SpectralFitting.CompositeModel
— TypeCompositeModel{T,K,Op,M1,M2} <: AbstractSpectralModel{T,K}
CompositeModel(left_model, right_model, op::AbstractCompositeOperator)
Type resulting from operations combining any number of AbstractSpectralModel
via the model algebra defined from AbstractSpectralModelKind
.
model = PhotoelectricAbsorption() * (PowerLaw() + BlackBody())
typeof(model) <: CompositeModel # true
Each operation binary operation in the model algebra is encoded in the parametric types of the CompositeModel
, where the operation is given by an AbstractCompositeOperator
. Composite models adopt the model kind of the right
model, i.e. M2
, and obey the model algebra accordingly.
Composite models very rarely need to be constructed directly, and are instead obtained by regular model operations.
The propertynames
and getproperty
methods for CompositeModel
are overwritten to access all models in the model tree. For example:
julia> propertynames(PowerLaw() + DeltaLine())
(:a1, :a2)
CompositeModel
has destructure
for working abstractly with model trees.
SpectralFitting.AbstractCompositeOperator
— Typeabstract type AbstractCompositeOperator
Superype of all composition operators. Used to implement the model algebra of AbstractSpectralModelKind
through a trait system.
The Julia symbol corresponding to a given AbstractCompositeOperator
may be obtained through operation_symbol
.
SpectralFitting.AdditionOperator
— TypeAdditionOperator <: AbstractCompositeOperator
AdditionOperator()
Corresponds to the :(+)
symbol.
SpectralFitting.MultiplicationOperator
— TypeMultiplicationOperator <: AbstractCompositeOperator
MultiplicationOperator()
Corresponds to the :(*)
symbol.
SpectralFitting.ConvolutionOperator
— TypeConvolutionOperator <: AbstractCompositeOperator
ConvolutionOperator()
Has no corresponding symbol, since it invokes a function call C(A)
.
SpectralFitting.operation_symbol
— Functionoperation_symbol(::AbstractCompositeOperator)
operation_symbol(::Type{<:AbstractCompositeOperator})
Obtain the model symbol from a given AbstractCompositeOperator
.