Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 3 additions & 65 deletions src/fourierdomain/fourierdomain.jl
Original file line number Diff line number Diff line change
@@ -1,41 +1,7 @@
export FourierDualDomain
import ComradeBase: AbstractFourierDualDomain, FourierTransform,
forward_plan, reverse_plan, imgdomain, visdomain,
algorithm, getplan, getphases, create_plans

abstract type FourierTransform end

export allocate_imgmap, allocate_vismap

"""
$(TYPEDEF)

This defines an abstract cache that can be used to
hold or precompute some computations.
"""
abstract type AbstractFourierDualDomain <: AbstractDomain end

forward_plan(g::AbstractFourierDualDomain) = getfield(g, :plan_forward)
reverse_plan(g::AbstractFourierDualDomain) = getfield(g, :plan_reverse)
imgdomain(g::AbstractFourierDualDomain) = getfield(g, :imgdomain)
visdomain(g::AbstractFourierDualDomain) = getfield(g, :visdomain)
algorithm(g::AbstractFourierDualDomain) = getfield(g, :algorithm)

EnzymeRules.inactive(::typeof(forward_plan), args...) = nothing
EnzymeRules.inactive(::typeof(reverse_plan), args...) = nothing
# ChainRulesCore.@non_differentiable getplan(p)
# ChainRulesCore.@non_differentiable getphases(p)

abstract type AbstractPlan end
getplan(p::AbstractPlan) = getfield(p, :plan)
getphases(p::AbstractPlan) = getfield(p, :phases)
EnzymeRules.inactive(::typeof(getplan), args...) = nothing
EnzymeRules.inactive(::typeof(getphases), args...) = nothing
ChainRulesCore.@non_differentiable getplan(p)
# ChainRulesCore.@non_differentiable getphases(p)

function create_plans(algorithm, imgdomain, visdomain)
plan_forward = create_forward_plan(algorithm, imgdomain, visdomain)
plan_reverse = inverse_plan(plan_forward)
return plan_forward, plan_reverse
end

struct FourierDualDomain{
ID <: AbstractSingleDomain, VD <: AbstractSingleDomain,
Expand Down Expand Up @@ -165,34 +131,6 @@ function FourierDualDomain(
return FourierDualDomain(imgdomain, visdomain, algorithm, plan_forward, plan_reverse)
end

function create_vismap(arr::AbstractArray, g::AbstractFourierDualDomain)
return ComradeBase.create_map(arr, visdomain(g))
end

function create_imgmap(arr::AbstractArray, g::AbstractFourierDualDomain)
return ComradeBase.create_map(arr, imgdomain(g))
end

function visibilitymap_analytic(m::AbstractModel, grid::AbstractFourierDualDomain)
return visibilitymap_analytic(m, visdomain(grid))
end

function visibilitymap_numeric(m::AbstractModel, grid::AbstractFourierDualDomain)
img = intensitymap_analytic(m, imgdomain(grid))
vis = applyft(forward_plan(grid), img)
return vis
end

function intensitymap_analytic(m::AbstractModel, grid::AbstractFourierDualDomain)
return intensitymap_analytic(m, imgdomain(grid))
end

function intensitymap_numeric(m::AbstractModel, grid::AbstractFourierDualDomain)
# This is because I want to make a grid that is the same size as the image
# so we revert to the standard method and not what ever was cached
img = intensitymap_numeric(m, imgdomain(grid))
return img
end

include("fft_alg.jl")
include("nuft/nuft.jl")
91 changes: 1 addition & 90 deletions src/models/multidomain/multidomain.jl
Original file line number Diff line number Diff line change
@@ -1,91 +1,2 @@
export getparam, @unpack_params

"""
abstract type DomainParams

Abstract type for multidomain i.e. time, frequency domain models.
This is to extend existing models that are just definedin the image and
visibility domain and automatically extend them to time and frequency domain.

The interface is simple and to extend this with your own time and frequency models,
most users will just need to define

```julia
struct MyDomainParam{T} <: DomainParams{T} end
function build_param(param::MyDomainParam{Float64}, p)
...
end
where `p` is the point where the model will be evaluated at. For an
example see the [`TaylorSpectralModel`](@ref).

To evaluate the parameter family at a point `p` in the frequency and time
domain use `build_param(param, p)` or just `param(p)`.

For a model parameterized with a `<:DomainParams` the a use should access
the parameters with [`getparam`](@ref) or the `@unpack_params` macro.
```
"""
abstract type DomainParams{T} end

abstract type FrequencyParams{T} <: DomainParams{T} end
abstract type TimeParams{T} <: DomainParams{T} end

"""
paramtype(::Type{<:DomainParams})

Computes the base parameter type of the DomainParams. If `!<:DomainParams` then it just returns
the type.
"""
@inline paramtype(::Type{<:DomainParams{T}}) where {T} = paramtype(T)
@inline paramtype(T::Type{<:Any}) = T

"""
getparam(m, s::Symbol, p)

Gets the parameter value `s` from the model `m` evaluated at the domain `p`.
This is similar to getproperty, but allows for the parameter to be a function of the
domain. Essentially is `m.s <: DomainParams` then `m.s` is evaluated at the parameter `p`.
If `m.s` is not a subtype of `DomainParams` then `m.s` is returned.

!!! warn
Developers should not typically overload this function and instead
target [`build_param`](@ref).

!!! warn
This feature is experimental and is not considered part of the public stable API.

"""
@inline function getparam(m, s::Symbol, p)
ps = getproperty(m, s)
return build_param(ps, p)
end
@inline function getparam(m, ::Val{s}, p) where {s}
return getparam(m, s, p)
end

"""
build_param(param::DomainParams, p)

Constucts the parameters for the `param` model at the point `p`
in the (X/U, Y/V, Ti, Fr) domain. This is a required function for
any `<: DomainParams` and must return a number for the specific
parameter at the point `p`.
"""
@inline function build_param(param::Any, p)
return param
end

function build_param(param::NTuple, p)
return map(x -> build_param(x, p), param)
end

function build_param(param::AbstractArray, p)
return map(x -> build_param(x, p), param)
end

function (m::DomainParams)(p)
return build_param(m, p)
end

include("unpack.jl")
import ComradeBase: DomainParams, getparam, build_param
include("freqtaylor.jl")
41 changes: 0 additions & 41 deletions src/models/multidomain/unpack.jl

This file was deleted.

Loading