Point functions

Gradus.PointFunctionType
struct PointFunction <: AbstractPointFunction
PointFunction(func)

Point functions are functions that are used to calculate physical parameters from geodesic integrations, and to compose more complex models. A number of default and utility PointFunction are defined in Gradus.ConstPointFunctions.

Principally, point functions return a single value per geodesic, and are used to fill rendered images with values, e.g. colouring redshift.

Point functions may be instantiated by wrapping a function with the following signature

function func(m::AbstractMetric{T}, gp::AbstractGeodesicPoint, max_time::T; kwargs...)::T where {T}
    # ...
end

pf = PointFunction(func)
  • The AbstractMetric argument may be used to dispatch for different metrics.
  • gp is an AbstractGeodesicPoint corresponding to a given geodesic.
  • The max_time parameter is the maximum integration time used to integrate the geodesics. This may be useful when trying to determine whether a geodesic terminated early or not.

They may be invoked by invoking the instance

result = pf(m, gp, max_time)
Note

As of version 0.1.0, the kwargs parameter is reserved only for passing optional results when chaining multiple point functions (see below). This is subject to revision and breaking changes in future versions.

Multiple AbstractPointFunction may be chained together using the operator, and are evaluated from right to left

pf3 = pf2 ∘ pf1

This may be useful for constructing filters using FilterPointFunction. When used with two PointFunction objects, the output of the previous PointFunction is passed to the next via the value keyword argument.

source
Gradus.FilterPointFunctionType
struct FilterPointFunction <: AbstractPointFunction
FilterPointFunction(func, default_value)

Point functions used to filter geodesics. They may be constructed with

function func(m::AbstractMetric{T}, gp::AbstractGeodesicPoint, max_time::T; kwargs...)::Bool where {T}
    # ... return Bool
end

fpf = FilterPointFunction(func, NaN64)

The second argument to the constructor is the default value, given to the pixel if the boolean condition of func is false.

Example

A filter for geodesics within a certain radius, used to only calculate redshift within 10 $\r_\text{g}$

func(m, gp, max_time) = gp.u[2] < 10.0
pf = ConstPointFunctions.redshift(m, u) ∘ FilterPointFunction(func, NaN64)
source

Pre-defined point functions

Gradus.ConstPointFunctions.shadowFunction
shadow(m::AbstractMetric, gp::AbstractGeodesicPoint, max_time)

A PointFunction which colours the shadow of the black hole for any disc-less render. Equivalent to ConstPointFunctions.affine_time ∘ ConstPointFunctions.filter_early_term.

source