API/Reference
PSFModels.PSFModels
PSFModels.AiryDisk
PSFModels.Gaussian
PSFModels.Moffat
PSFModels.Normal
PSFModels.PSFModel
PSFModels.ScaledPSFModel
PSFModels.PSFModel
— TypePSFModels.PSFModel{T} <: AbstractMatrix{T}
Abstract type for PSF models.
In general, all PSFModel
s 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
)
method | description |
---|---|
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
PSFModels.ScaledPSFModel
— TypePSFModels.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
Gaussian
PSFModels.Gaussian
— TypePSFModels.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 x̂
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.
PSFModels.Normal
— TypePSFModels.Normal
An alias for PSFModels.Gaussian
model = Gaussian(10)
plot(model; title="Gaussian(fwhm=10)")
Airy Disk
PSFModels.AiryDisk
— TypePSFModels.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)
model = AiryDisk(10)
plot(model; title="AiryDisk(fwhm=10)")
Moffat
PSFModels.Moffat
— TypePSFModels.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 x̂
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.
model = Moffat(10)
plot(model; title="Moffat(fwhm=10)")