Skip to content

StationaryRandomFields.jl API

Index

Docstrings

StationaryRandomFields.AbstractContinuousNoiseSignal Type
julia
AbstractContinuousNoiseSignal

This is an abstract data type for N dimensional continuous signal data on which signal noise will be generated. The data type extends the AbstractNoiseSignal data type for use in PowerSpectrumNoiseGenerator methods.

Mandatory fields

  • noisesignal::AbstractNoiseSignal: noise signal object

source

StationaryRandomFields.AbstractNoiseSignal Type
julia
AbstractNoiseSignal

This is an abstract data type for signal data on which powerspectrum noises will be created. The data type contains information to define the dimensions and sizes of data, and provides various methods.

Mandatory fields

  • dims::Tuple: dimension of data

Mandatory methods

  • size: returns the size of the signal

  • sizeof: returns product of signal dimensions

  • ndims: returns the number of the dimension

  • rfftsize: returns the size of the signal in the Fourier plane (for rfft)

  • rfftfreq: returns the frequency grid along each dimension in the Fourier plane (for rfft)

  • generate_gaussian_noise: returns Gaussian noises in Fourier domain with the size of rfftsize(data)

source

StationaryRandomFields.AbstractPowerSpectrumModel Type
julia
AbstractPowerSpectrumModel{N}

The abstract model type for a PowerSpectrum at N dimension. To instantiate your own model type you should subtype from this model. Additionally you need to implement the following methods to satify the interface:

Mandatory Methods

  • fourieranalytic: Defines whether the model fourier coefficients can be computed analytically. If yes then this should return IsAnalytic() and the user must to define visibility_point. If not analytic then fourieranalytic should return NotAnalytic().

  • power_point: Defines how to compute model power of fourier coefficients pointwise. Note this must be defined if fourieranalytic(::Type{YourModel})==IsAnalytic().

  • power_map: Maps the fourier power spectrum for a set of frequencies.

Optional Methods

  • amplitude_point: Defines how to compute model amplitudes of fourier coefficients pointwise. Note this must be defined if fourieranalytic(::Type{YourModel})==IsAnalytic(). It should be defined as √(power_point(model, ν...)).

  • amplitude_map: Maps the fourier amplitude spectrum for a grid of frequencies.

source

StationaryRandomFields.ContinuousNoiseSignal Type
julia
struct ContinuousNoiseSignal{T, N<:AbstractNoiseSignal, D<:Tuple, P, PI} <: AbstractContinuousNoiseSignal

Data type for continuous noise signals. Input an AbstractNoiseSignal and the corresponding dimensions, RFFT plan, and inverse RFFT plan will automatically be defined. The type of data (default Float64) may also be specified.

Fields

  • noisesignal

  • dims

  • plan

  • invplan

source

StationaryRandomFields.DensityAnalytic Type
julia
DensityAnalytic

Internal type for specifying the nature of the model functions. Whether they can be easily evaluated pointwise analytic. This is an internal type that may change.

source

StationaryRandomFields.IsAnalytic Type
julia
struct IsAnalytic <: StationaryRandomFields.DensityAnalytic

Defines a trait that a states that a model is analytic. This is usually used with an abstract model where we use it to specify whether a model has a analytic fourier transform and/or image.

source

StationaryRandomFields.ModelModifier Type
julia
abstract type ModelModifier{T}

General type for a model modifier. These transform any model using simple Fourier transform properties. To modify a model you can use the ModifiedPowerSpectrumModel{N} constructor or the modify function.

julia
julia> visanalytic(stretched(Disk(), 2.0, 2.0)) == visanalytic(Disk())
true

To implement a model transform you need to specify the following methods:

See the docstrings of those methods for guidance on implementation details.

Additionally these methods assume the modifiers are of the form

I(x,y) -> fᵢ(x,y)I(gᵢ(x,y)) V(u,v) -> fᵥ(u,v)V(gᵥ(u,v))

where g are the transform_image/uv functions and f are the scale_image/uv function.

source

StationaryRandomFields.ModifiedPowerSpectrumModel Type
julia
struct ModifiedPowerSpectrumModel{N, M<:AbstractPowerSpectrumModel{N}, T<:Tuple} <: AbstractPowerSpectrumModel{N}

Container type for models that have been transformed in some way. For a list of potential modifiers or transforms see subtypes(ModelModifiers).

Fields

  • model: base model

  • transform: model transforms

source

StationaryRandomFields.NoiseSignal Type
julia
struct NoiseSignal{T<:Tuple} <: AbstractNoiseSignal

This is a data type for noise signals of any dimension.

Fields

  • dims

source

StationaryRandomFields.NotAnalytic Type
julia
struct NotAnalytic <: StationaryRandomFields.DensityAnalytic

Defines a trait that a states that a model is analytic. This is usually used with an abstract model where we use it to specify whether a model has does not have a easy analytic fourier transform and/or intensity function.

source

StationaryRandomFields.PowerSpectrumNoiseGenerator Type
julia
PowerSpectrumNoiseGenerator

This is an abstract data type for power spectrum noise generators.

Mandatory methods

source

StationaryRandomFields.Renormalize Type
julia
struct Renormalize{T} <: StationaryRandomFields.ModelModifier{T}

Renormalizes the flux of the model to the new value scale*flux(model). We have also overloaded the Base.😗 operator as syntactic sugar although I may get rid of this.

Example

julia
julia> modify(Gaussian(), Renormalize(2.0)) == 2.0*Gaussian()
true

source

StationaryRandomFields.Rotate Type
julia
Rotate(ξ)

Type for the rotated model. This is more fine grained control of rotated model.

Example

julia
julia> modify(Gaussian(), Rotate(2.0)) == rotated(Gaussian(), 2.0)
true

source

StationaryRandomFields.SaturatedPowerLaw Type
julia
$(TYPEDEF)

Type for power law with input dimension {N} and profile: P(\nu) = |\nu| ^{\beta} \end{cases} when inscale < |ν| < outscale. When |ν| > outscale: P(ν) = 0. When |ν| < inscale: P(nu)=(inscale)betaendcases.

β refers to the input index. Can be renormalized, stretched, and rotated via ModelModifier.

Fields

FIELDS

source

StationaryRandomFields.SinglePowerLaw Type
julia
$(TYPEDEF)

Type for single power law with input dimension {N} and profile P(\nu) = |\nu| ^{\beta} \end{cases} where β is the input index and ν is frequency. Can be renormalized, stretched, and rotated via ModelModifier.

Fields

FIELDS

source

StationaryRandomFields.Stretch Type
julia
Stretch(α, β)
Stretch(r)

Stretched the model in the x and y directions, i.e. the new intensity is Iₛ(x,y) = 1/(αβ) I(x/α, y/β), where were renormalize the intensity to preserve the models flux.

Example

julia
julia> modify(Gaussian(), Stretch(2.0)) == stretched(Gaussian(), 2.0, 1.0)
true

If only a single argument is given it assumes the same stretch is applied in both direction.

julia
julia> Stretch(2.0) == Stretch(2.0, 2.0)
true

source

StationaryRandomFields.amplitude_map Method
julia
amplitude_map(model::AbstractPowerSpectrumModel, data)

Function that maps the amplitude function of a signal data frequency grid. The intended input "data" is the frequency grid output by FFTW.rfftfreq. Alternatively a SignalNoise or ContinuousSignalNoise object can be input, and the corresponding frequency grid will be computed and mapped.

In default, it should be defined as .√(power_point(model, data)).

source

StationaryRandomFields.amplitude_point Method
julia
amplitude_point(model::AbstractPowerSpectrumModel, ν...)

Function that computes the pointwise amplitude of fourier component at a set of frequencies ν. This must be implemented in the model interface if fourieranalytic(::Type{MyModel}) == IsAnalytic().

In default, it should be defined as √(power_point(model, ν...)).

source

StationaryRandomFields.basemodel Method
julia
basemodel(model::ModifiedPowerSpectrumModel)

Returns the ModifiedPowerSpectrumModel with the last transformation stripped.

Example

julia
julia> basemodel(stretched(Disk(), 1.0, 2.0)) == Disk()
true

source

StationaryRandomFields.fourieranalytic Method
julia
fourieranalytic(::Type{<:AbstractPowerSpectrumModel})

Determines whether the model is pointwise analytic in Fourier domain, i.e. we can evaluate its fourier transform at an arbritrary point.

If IsAnalytic() then it will try to call visibility_point to calculate the complex visibilities. Otherwise it fallback to using the FFT that works for all models that can compute an image.

source

StationaryRandomFields.generate_gaussian_noise Method
julia
generate_gaussian_noise(data::AbstractNoiseSignal; rng=Random.default_rng())

Generate complex gausisian noises on Fourier space over the frequency space expected for Real FFT. This return a complex array, which is consistent with Fourier-domain representation of a real uncorrelated Gaussian noise with the zero mean and variance of sizeof(data) in signal-domain. The size of the output array is given by rfftsize(data).

source

StationaryRandomFields.generate_signal_noise Function
julia
generate_signal_noise(psgen::PowerSpectrumNoiseGenerator)

Converts fourier domain gaussian noise to signal noise, corresponding to the continuous noise signal and power spectrum contained in psgen. Scaling the gaussian fourier noise by the power law function and then transforming to the signal domain with an inverse rfft generates the signal noise.

source

StationaryRandomFields.get_fourier_noise Method
julia
get_fourier_noise(psgen::PowerSpectrumNoiseGenerator, signoise::AbstractArray)

Retrieve power-spectrum-scaled fourier noise from given signal noise by transforming to fourier space.

source

StationaryRandomFields.get_power_spectrum Method
julia
get_power_spectrum(psgen::PowerSpectrumNoiseGenerator, signoise::AbstractArray)

Retrieve power spectrum from given signal noise.

source

StationaryRandomFields.modify Method
julia
modify(m::AbstractPowerSpectrumModel, transforms...)

Modify a given model using the set of transforms. This is the most general function that allows you to apply a sequence of model transformation for example

julia
modify(Gaussian(), Stretch(2.0, 1.0), Rotate(π/4), Shift(1.0, 2.0), Renorm(2.0))

will create a asymmetric Gaussian with position angle π/4 shifted to the position (1.0, 2.0) with a flux of 2 Jy. This is similar to Flux's chain.

source

StationaryRandomFields.posangle Method
julia
posangle(model)

Returns the rotation angle of the rotated model

source

StationaryRandomFields.power_map Method
julia
power_map(model, gridofν)

Function that maps the power law function of a signal data frequency grid. The intended input "data" is the frequency grid output by FFTW.rfftfreq. Alternatively a SignalNoise or ContinuousSignalNoise object can be input, and the corresponding frequency grid will be computed and mapped.

source

StationaryRandomFields.power_point Function
julia
power_point(model::AbstractPowerSpectrumModel, ν...)

Function that computes the pointwise amplitude of fourier component at a set of frequencies ν. This must be implemented in the model interface if fourieranalytic(::Type{MyModel}) == IsAnalytic()

source

StationaryRandomFields.renormed Method
julia
renormed(model, f)

Renormalizes the model m to have total flux f*flux(m). This can also be done directly by calling Base.:* i.e.,

julia
julia> renormed(m, f) == f*M
true

source

StationaryRandomFields.rfftsize Method
julia
rfftsize(data::AbstractNoiseSignal)::Tuple

Returns the size of the Fourier-domain signal

source

StationaryRandomFields.rotated Method
julia
rotated(model, ξ)

Rotates the model by an amount ξ in radians in the clockwise direction.

source

StationaryRandomFields.scale_fourier Function
julia
scale_fourier(model::AbstractModifier, ν...)

Returns a number on how to scale the fourier coefficients at the frequency coordinate ν for an modified model

source

StationaryRandomFields.stretched Method
julia
stretched(model, α)

Stretches the model m according to the formula Vₛ(u) = V(u1/α1, u2/α2, ...), where were renormalize the intensity to preserve the models flux.

source

StationaryRandomFields.transform_ν Function
julia
transform_ν(model::AbstractModifier, ν...)

Returns a transformed frequency coordinate ν according to the model modifier

source

StationaryRandomFields.unmodified Method
julia
unmodified(model::ModifiedPowerSpectrumModel)

Returns the un-modified model

Example

julia
julia> m = stretched(rotated(Gaussian(), π/4), 2.0, 1.0)
julia> umodified(m) == Gaussian()
true

source