API/Reference

PSFModels.PSFModelType
PSFModels.PSFModel{T} <: AbstractMatrix{T}

Abstract type for PSF models.

In general, all PSFModels have a set of pre-determined axes (the size is set upon creation) but they are lazy. That is, no memory is allocated and the values are calculated on the fly.

Interface

The interface to define a model is as follows (for an example model Model)

methoddescription
Model()constructor(s)
Base.size(m::Model)size, necessary for AbstractArray interface
Base.axes(m::Model)axes, necessary for AbstractArray interface
(m::Model)(point::AbstractVector)evaluate the model at the point in 2d space (x, y)

browsing through the implementation of PSFModels.Gaussian should give a good idea of how to create a model

source
PSFModels.ScaledPSFModelType
PSFModels.ScaledPSFModel(amp, model)

A lazy wrapper for a PSFModel that adds the scalar amplitude amp to the given model. This is convenient to avoid broadcasting and materializing an array from a PSFModel because the scalar multiplication can be chained to the original model's output.

Examples

julia> g = PSFModels.Gaussian(10);

julia> g(0, 0)
1.0

julia> m1 = 20 * g; # construct implicitly using scalar * or /

julia> m1(0, 0)
20.0

julia> maximum(g / 100) # scalar division works, too
0.01

julia> m2 = PSFModels.ScaledPSFModel(20, g); # construct explicitly

julia> m1 == m2
true
source

Gaussian

PSFModels.GaussianType
PSFModels.Gaussian(fwhm; maxsize=3)
PSFModels.Gaussian(position, fwhm; maxsize=3)
PSFModels.Gaussian(x, y, fwhm; maxsize=3)
PSFModels.Gaussian(::Polar, fwhm; maxsize=3, origin=(0, 0))
PSFModels.Gaussian{T}(args...; kwargs...)

An unnormalized bivariate Gaussian distribution. The position can be specified in (x, y) coordinates as a Tuple, AbstractVector, or as separate arguments. By default the model is placed at the origin. The position can also be given as a CoordinateTransformations.Polar, optionally centered around origin.

The fwhm can be a scalar (isotropic), vector/tuple (diagonal), or a matrix (correlated). For efficient calculations, we recommend using StaticArrays. Here, maxsize is a multiple of the fwhm, and can be given as a scalar or as a tuple for each axis.

The output type can be specified, and will default to Float64. The amplitude is unnormalized, meaning the maximum value will always be 1. This is distinct from the probability distribution (pdf) of a bivariate Gaussian which assures the model sums to 1. This means the models act like a transmission weighting instead of a probability weighting.

Functional form

f(x | x̂, FWHM) = exp[-4ln(2) * ||x - x̂|| / FWHM^2]

where and x are position vectors (indices) ||⋅|| represents the square-distance, and FWHM is the full width at half-maximum. If FWHM is a vector or tuple, the weighting is applied along each axis.

If the FWHM is a correlated matrix, the functional form uses the square-Mahalanobis distance

f(x | x̂, Q) = exp[-4ln(2) * (x - x̂)ᵀ Q (x - x̂)]

where Q is the inverse covariance matrix (or precision matrix). This is equivalent to the inverse of the FWHM matrix after squaring each element.

source
model = Gaussian(10)
plot(model; title="Gaussian(fwhm=10)")

Airy Disk

PSFModels.AiryDiskType
PSFModels.AiryDisk(fwhm; maxsize=3)
PSFModels.AiryDisk(position, fwhm; maxsize=3)
PSFModels.AiryDisk(x, y, fwhm; maxsize=3)
PSFModels.AiryDisk(::Polar, fwhm; maxsize=3, origin=(0, 0))
PSFModels.AiryDisk{T}(args...; kwargs...)

An unnormalized Airy disk. The position can be specified in (x, y) coordinates as a Tuple, AbstractVector, or as separate arguments. By default the model is placed at the origin. The position can also be given as a CoordinateTransformations.Polar, optionally centered around origin.

The fwhm can be a scalar (isotropic) or vector/tuple (diagonal). For efficient calculations, we recommend using StaticArrays. Here, maxsize is a multiple of the fwhm, and can be given as a scalar or as a tuple for each axis.

The output type can be specified, and will default to Float64. The amplitude is unnormalized, meaning the maximum value will always be 1. This means the models act like a transmission weighting.

Functional form

The Airy disk is a distribution over the radius r (the square-Euclidean distance)

f(x | x̂, FWHM) = [ 2J₁(q) / q ]^2

where J₁ is the first order Bessel function of the first kind and

q ≈ π * r / (0.973 * FWHM)
source
model = AiryDisk(10)
plot(model; title="AiryDisk(fwhm=10)")

Moffat

PSFModels.MoffatType
PSFModels.Moffat(fwhm; maxsize=3)
PSFModels.Moffat(position, fwhm; maxsize=3)
PSFModels.Moffat(x, y, fwhm; maxsize=3)
PSFModels.Moffat(::Polar, fwhm; maxsize=3, origin=(0, 0))
PSFModels.Moffat{T}(args...; kwargs...)

An unnormalized Airy disk. The position can be specified in (x, y) coordinates as a Tuple, AbstractVector, or as separate arguments. By default the model is placed at the origin. The position can also be given as a CoordinateTransformations.Polar, optionally centered around origin.

The fwhm can be a scalar (isotropic) or vector/tuple (diagonal). For efficient calculations, we recommend using StaticArrays. Here, maxsize is a multiple of the fwhm, and can be given as a scalar or as a tuple for each axis.

The output type can be specified, and will default to Float64. The amplitude is unnormalized, meaning the maximum value will always be 1. This means the models act like a transmission weighting.

Functional form

f(x | x̂, FWHM) = 1 / [1 + ||x - x̂|| / (FWHM / 2)^2]

where and x are position vectors (indices) ||⋅|| represents the square-distance, and FWHM is the full width at half-maximum. If FWHM is a vector or tuple, the weighting is applied along each axis.

source
model = Moffat(10)
plot(model; title="Moffat(fwhm=10)")