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.CompositeModelType
CompositeModel{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.

source