StationaryRandomFields.jl API
Index
StationaryRandomFields.AbstractContinuousNoiseSignal
StationaryRandomFields.AbstractNoiseSignal
StationaryRandomFields.AbstractPowerSpectrumModel
StationaryRandomFields.ContinuousNoiseSignal
StationaryRandomFields.DensityAnalytic
StationaryRandomFields.IsAnalytic
StationaryRandomFields.ModelModifier
StationaryRandomFields.ModifiedPowerSpectrumModel
StationaryRandomFields.NoiseSignal
StationaryRandomFields.NotAnalytic
StationaryRandomFields.PowerSpectrumNoiseGenerator
StationaryRandomFields.Renormalize
StationaryRandomFields.Rotate
StationaryRandomFields.SaturatedPowerLaw
StationaryRandomFields.SinglePowerLaw
StationaryRandomFields.Stretch
StationaryRandomFields.amplitude_map
StationaryRandomFields.amplitude_point
StationaryRandomFields.basemodel
StationaryRandomFields.fourieranalytic
StationaryRandomFields.generate_gaussian_noise
StationaryRandomFields.generate_signal_noise
StationaryRandomFields.get_fourier_noise
StationaryRandomFields.get_power_spectrum
StationaryRandomFields.modify
StationaryRandomFields.posangle
StationaryRandomFields.power_map
StationaryRandomFields.power_point
StationaryRandomFields.renormed
StationaryRandomFields.rfftsize
StationaryRandomFields.rotated
StationaryRandomFields.scale_fourier
StationaryRandomFields.stretched
StationaryRandomFields.transform_ν
StationaryRandomFields.unmodified
Docstrings
StationaryRandomFields.AbstractContinuousNoiseSignal Type
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
StationaryRandomFields.AbstractNoiseSignal Type
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 signalsizeof
: returns product of signal dimensionsndims
: returns the number of the dimensionrfftsize
: 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 ofrfftsize(data)
StationaryRandomFields.AbstractPowerSpectrumModel Type
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 returnIsAnalytic()
and the user must to definevisibility_point
. If not analytic thenfourieranalytic
should returnNotAnalytic()
.power_point
: Defines how to compute model power of fourier coefficients pointwise. Note this must be defined iffourieranalytic(::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 iffourieranalytic(::Type{YourModel})==IsAnalytic()
. It should be defined as √(power_point(model, ν...)).amplitude_map
: Maps the fourier amplitude spectrum for a grid of frequencies.
StationaryRandomFields.ContinuousNoiseSignal Type
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
StationaryRandomFields.DensityAnalytic Type
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.
StationaryRandomFields.IsAnalytic Type
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.
StationaryRandomFields.ModelModifier Type
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> 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.
StationaryRandomFields.ModifiedPowerSpectrumModel Type
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 modeltransform
: model transforms
StationaryRandomFields.NoiseSignal Type
struct NoiseSignal{T<:Tuple} <: AbstractNoiseSignal
This is a data type for noise signals of any dimension.
Fields
dims
StationaryRandomFields.NotAnalytic Type
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.
StationaryRandomFields.PowerSpectrumNoiseGenerator Type
PowerSpectrumNoiseGenerator
This is an abstract data type for power spectrum noise generators.
Mandatory methods
generate_signal_noise
: Transforms fourier noise to signal noise in position plane for given power spectrum modelget_fourier_noise
: Computes fourier noise for given signal domain noiseget_power_spectrum
: Returns power spectrum model retrieved from given signal domain noise
StationaryRandomFields.Renormalize Type
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> modify(Gaussian(), Renormalize(2.0)) == 2.0*Gaussian()
true
StationaryRandomFields.Rotate Type
Rotate(ξ)
Type for the rotated model. This is more fine grained control of rotated model.
Example
julia> modify(Gaussian(), Rotate(2.0)) == rotated(Gaussian(), 2.0)
true
StationaryRandomFields.SaturatedPowerLaw Type
$(TYPEDEF)
Type for power law with input dimension {N} and profile:
β refers to the input index. Can be renormalized, stretched, and rotated via ModelModifier.
Fields
FIELDS
StationaryRandomFields.SinglePowerLaw Type
$(TYPEDEF)
Type for single power law with input dimension {N} and profile
Fields
FIELDS
StationaryRandomFields.Stretch Type
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> 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> Stretch(2.0) == Stretch(2.0, 2.0)
true
StationaryRandomFields.amplitude_map Method
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)).
StationaryRandomFields.amplitude_point Method
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, ν...)).
StationaryRandomFields.basemodel Method
basemodel(model::ModifiedPowerSpectrumModel)
Returns the ModifiedPowerSpectrumModel with the last transformation stripped.
Example
julia> basemodel(stretched(Disk(), 1.0, 2.0)) == Disk()
true
StationaryRandomFields.fourieranalytic Method
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.
StationaryRandomFields.generate_gaussian_noise Method
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)
.
StationaryRandomFields.generate_signal_noise Function
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.
StationaryRandomFields.get_fourier_noise Method
get_fourier_noise(psgen::PowerSpectrumNoiseGenerator, signoise::AbstractArray)
Retrieve power-spectrum-scaled fourier noise from given signal noise by transforming to fourier space.
StationaryRandomFields.get_power_spectrum Method
get_power_spectrum(psgen::PowerSpectrumNoiseGenerator, signoise::AbstractArray)
Retrieve power spectrum from given signal noise.
StationaryRandomFields.modify Method
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
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.
StationaryRandomFields.posangle Method
posangle(model)
Returns the rotation angle of the rotated model
StationaryRandomFields.power_map Method
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.
StationaryRandomFields.power_point Function
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()
StationaryRandomFields.renormed Method
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> renormed(m, f) == f*M
true
StationaryRandomFields.rfftsize Method
rfftsize(data::AbstractNoiseSignal)::Tuple
Returns the size of the Fourier-domain signal
StationaryRandomFields.rotated Method
rotated(model, ξ)
Rotates the model by an amount ξ
in radians in the clockwise direction.
StationaryRandomFields.scale_fourier Function
scale_fourier(model::AbstractModifier, ν...)
Returns a number on how to scale the fourier coefficients at the frequency coordinate ν
for an modified model
StationaryRandomFields.stretched Method
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.
StationaryRandomFields.transform_ν Function
transform_ν(model::AbstractModifier, ν...)
Returns a transformed frequency coordinate ν
according to the model
modifier
StationaryRandomFields.unmodified Method
unmodified(model::ModifiedPowerSpectrumModel)
Returns the un-modified model
Example
julia> m = stretched(rotated(Gaussian(), π/4), 2.0, 1.0)
julia> umodified(m) == Gaussian()
true