PSFModels.jl

Fast, allocation-free PSF representations
Author JuliaAstro
Popularity
4 Stars
Updated Last
1 Year Ago
Started In
November 2020

PSFModels.jl

Build Status PkgEval Coverage License

Stable Dev

Fast, allocation-free point-spread function (PSF) representations

Models

  • PSFModels.Gaussian (or Normal)
  • PSFModels.AiryDisk
  • PSFModels.Moffat

Installation

From the Julia REPL

julia> ]

(@v1.5) pkg> add PSFModels

To import the library

julia> using PSFModels

None of the models are exported to avoid namespace clashes, but it can be verbose. You can either import names directly

julia> using PSFModels: Gaussian

julia> model = Gaussian(8)

or you can create an alias for PSFModels

# julia version 1.5 or below
using PSFModels
const M = PSFModels
# julia version 1.6 or above
using PSFModels as M

model = M.Gaussian(10)

Usage

For more in-depth usage and examples, please see the documentation.

using PSFModels

m = PSFModels.Gaussian(8)           # bivariate gaussian with a FWHM of 8 pixels
m = PSFModels.Gaussian((7.4, 8.2))  # specify FWHM for each axis
m = PSFModels.Gaussian([1 0; 0 1])  # specify FWHM as a correlated matrix

m = PSFModels.Gaussian(12, 25, 8.2) # specifiy location in pixel coordinates
m = PSFModels.Gaussian([12, 25], 8.2)

mf0 = PSFModels.Gaussian{Float32}(8.2) # output guaranteed to be Float32
m[0, 0]      # "index" the model at [y, x]
m[:, 0]
m(0.3, 1.0)  # directly query value at (x, y)
m([1.2, 0.4])

# scalar multiplication or division will create a ScaledPSFModel
20 * m # or `m * 20`
m / 20

# evaluate `m` over its indices forming an array
collect(m)

# broadcasting will take the axes of the other arrays
arr = randn(101, 101)
m .* arr

## (nearly) allocation-free loss function
# get overlapped cutouts for the PSF and the array
inds = map(intersect, axes(arr), axes(m))
arr_stamp = @view arr[inds...]
m_stamp = @view m[inds...]
amp = 1.24
resid = sum(abs2, arr_stamp .- amp .* m_stamp) # chi-square loss

Used By Packages