diff --git a/ext/VLBISkyModelsMakieExt.jl b/ext/VLBISkyModelsMakieExt.jl index da30131..180951b 100644 --- a/ext/VLBISkyModelsMakieExt.jl +++ b/ext/VLBISkyModelsMakieExt.jl @@ -191,11 +191,11 @@ Makie.@recipe(PolImage, img) do scene end # # We need this because DimensionalData tries to be too dang smart -function Makie.convert_arguments(::Type{<:PolImage}, img::IntensityMap{<:StokesParams,2}, args...) +function Makie.convert_arguments(::Type{<:PolImage}, img::IntensityMap{<:StokesParams,2}, + args...) return (img,) end - # function Makie.MakieCore.conversion_trait(P::Type{<:PolImage}) # # @info "HERE" # return P @@ -252,13 +252,12 @@ function Makie.plot!(plot::PolImage{<:Tuple{<:IntensityMap{<:StokesParams}}}) # return crange # end hm = heatmap!(plot, Xo, Yo, imgI; - colormap=plot.colormap, - colorscale=plot.colorscale, - colorrange=plot.colorrange, - alpha=plot.alpha, - nan_color=plot.nan_color, - lowclip=plot.lowclip, - ) + colormap=plot.colormap, + colorscale=plot.colorscale, + colorrange=plot.colorrange, + alpha=plot.alpha, + nan_color=plot.nan_color, + lowclip=plot.lowclip,) rotate!(hm, pa[]) @@ -389,10 +388,10 @@ function imageviz(img::IntensityMap; dkwargs = Dict(kwargs) if eltype(img) <: Real res = get(dkwargs, :size, (625, 500)) - cmap= get(dkwargs, :colormap, :inferno) + cmap = get(dkwargs, :colormap, :inferno) else res = get(dkwargs, :size, (640, 600)) - cmap= get(dkwargs, :colormap, :grayC) + cmap = get(dkwargs, :colormap, :grayC) end bkgcolor = isnothing(backgroundcolor) ? Makie.to_colormap(cmap)[begin] : backgroundcolor @@ -406,9 +405,8 @@ function imageviz(img::IntensityMap; dxdy = prod(rad2μas.(values(pixelsizes(img)))) imguas = IntensityMap(parent(img) ./ dxdy, - RectiGrid((X(rad2μas(img.X)), Y(rad2μas(img.Y))); - posang=ComradeBase.posang(axisdims(img))) - ) + RectiGrid((X(rad2μas(img.X)), Y(rad2μas(img.Y))); + posang=ComradeBase.posang(axisdims(img)))) pl = _imgviz!(fig, ax, imguas; scale_length, dkwargs...) resize_to_layout!(fig) return pl @@ -510,22 +508,19 @@ function DDM._surface2(A::IntensityMap, plotfunc, attributes, replacements) # Plot attribute generation dx, dy = DD.dims(A2) - user_attributes = Makie.Attributes(; - transformation=(;rotation=-ComradeBase.posang(axisdims(A))), - interpolate=false, - attributes...) - plot_attributes = Makie.Attributes(; - axis=(; - xlabel=DD.label(dx), - ylabel=DD.label(dy), - title=DD.refdims_title(A), - ), - ) + user_attributes = Makie.Attributes(; + transformation=(; + rotation=-ComradeBase.posang(axisdims(A))), + interpolate=false, + attributes...) + plot_attributes = Makie.Attributes(; + axis=(; + xlabel=DD.label(dx), + ylabel=DD.label(dy), + title=DD.refdims_title(A),),) merged_attributes = merge(user_attributes, plot_attributes, lookup_attributes) return A1, A2, args, merged_attributes end - - end diff --git a/src/fourierdomain/nuft/dft_alg.jl b/src/fourierdomain/nuft/dft_alg.jl index f8b55aa..f035e7a 100644 --- a/src/fourierdomain/nuft/dft_alg.jl +++ b/src/fourierdomain/nuft/dft_alg.jl @@ -20,7 +20,7 @@ function plan_nuft_spatial(::DFTAlg, imagegrid::AbstractRectiGrid, dft = similar(Array{Complex{eltype(imagegrid)}}, length(visdomain), size(imagegrid)[1:2]...) @fastmath for i in eachindex(Y), j in eachindex(X), k in eachindex(visp) - uvr = rmat*SVector(uv.U[k], uv.V[k]) + uvr = rmat * SVector(uv.U[k], uv.V[k]) u = uvr[1] v = uvr[2] # - sign is taken care of in _visibilitymap diff --git a/src/fourierdomain/nuft/nfft_alg.jl b/src/fourierdomain/nuft/nfft_alg.jl index b9f5d2c..16127b6 100644 --- a/src/fourierdomain/nuft/nfft_alg.jl +++ b/src/fourierdomain/nuft/nfft_alg.jl @@ -61,7 +61,8 @@ function make_phases(::NFFTAlg, imgdomain::AbstractRectiGrid, visdomain::Unstruc v = visp.V rm = ComradeBase.rotmat(imgdomain)' # Correct for the nFFT phase center and the img phase center - return cispi.((_rotatex.(u, v, Ref(rm)) .* (dx - 2 * x0) .+ _rotatey.(u, v, Ref(rm)) .* (dy - 2 * y0))) + return cispi.((_rotatex.(u, v, Ref(rm)) .* (dx - 2 * x0) .+ + _rotatey.(u, v, Ref(rm)) .* (dy - 2 * y0))) end # Allow NFFT to work with ForwardDiff. diff --git a/src/models/modifiers.jl b/src/models/modifiers.jl index 89fe5f0..03dfd66 100755 --- a/src/models/modifiers.jl +++ b/src/models/modifiers.jl @@ -204,7 +204,6 @@ function modify(m::AbstractModel, transforms...) return ModifiedModel(m, transforms) end - @inline function visibility_point(m::M, p) where {M<:ModifiedModel} mbase = m.model transform = m.transform diff --git a/src/utility.jl b/src/utility.jl index 2e63ce1..27f9aba 100644 --- a/src/utility.jl +++ b/src/utility.jl @@ -91,8 +91,7 @@ function convolve!(img::IntensityMap{<:Real}, m::AbstractModel) ds = (u, v, dims(img)[3:end]...) griduv = RectiGrid(ds; executor=executor(img), header=header(img), - posang=ComradeBase.posang(axisdims(img)) - ) + posang=ComradeBase.posang(axisdims(img))) puv = domainpoints(griduv) # TODO maybe ask a user to pass a vis buffer as well? diff --git a/test/rotgrid.jl b/test/rotgrid.jl index 0f0cbc6..18ce9a6 100644 --- a/test/rotgrid.jl +++ b/test/rotgrid.jl @@ -1,14 +1,14 @@ function testrot(m, g, gr, uv; alg=NFFTAlg(), atoli=5e-4, atolu=1e-6) - Ut = uv.*ones(length(uv))' + Ut = uv .* ones(length(uv))' Vt = ones(length(uv)) .* uv' guv = UnstructuredDomain((U=vec(Ut), V=vec(Vt))) gfour = FourierDualDomain(g, guv, NFFTAlg()) grfour = FourierDualDomain(gr, guv, NFFTAlg()) - mn= VLBISkyModels.NonAnalyticTest(m) + mn = VLBISkyModels.NonAnalyticTest(m) img = intensitymap(m, g) - imgr= intensitymap(m, gr) + imgr = intensitymap(m, gr) @test isapprox(img, regrid(imgr, g), atol=atoli) @@ -24,7 +24,7 @@ end @testset "Rotated Grid" begin g = imagepixels(6.0, 6.0, 256, 256) - gr= imagepixels(6.0, 6.0, 256, 256; posang=π/4) + gr = imagepixels(6.0, 6.0, 256, 256; posang=π / 4) uv = range(-2.0, 2.0) @@ -36,7 +36,7 @@ end @testset "Rotated Grid and shifted" begin g = imagepixels(6.0, 6.0, 256, 256, 0.25, 0.25) - gr= imagepixels(6.0, 6.0, 256, 256, 0.25, 0.25; posang=π/4) + gr = imagepixels(6.0, 6.0, 256, 256, 0.25, 0.25; posang=π / 4) uv = range(-2.0, 2.0) @@ -48,7 +48,7 @@ end @testset "Rotated Grid and shifted model" begin g = imagepixels(6.0, 6.0, 256, 256) - gr= imagepixels(6.0, 6.0, 256, 256; posang=π/4) + gr = imagepixels(6.0, 6.0, 256, 256; posang=π / 4) uv = range(-2.0, 2.0) @@ -60,12 +60,12 @@ end @testset "Polarized Rotated Grid" begin g = imagepixels(6.0, 6.0, 256, 256) - gr= imagepixels(6.0, 6.0, 256, 256; posang=π/4) + gr = imagepixels(6.0, 6.0, 256, 256; posang=π / 4) uv = range(-2.0, 2.0) m = modify(Gaussian(), Stretch(0.25, 0.5)) - pm = PolarizedModel(m, 0.1 * m, -0.2*m, 0.01*m) + pm = PolarizedModel(m, 0.1 * m, -0.2 * m, 0.01 * m) testrot(pm, g, gr, uv) testrot(pm, g, gr, uv; alg=FFTAlg()) testrot(pm, g, gr, uv; alg=DFTAlg()) @@ -73,12 +73,12 @@ end @testset "Rotated Grid and shifted" begin g = imagepixels(6.0, 6.0, 256, 256, 0.25, 0.25) - gr= imagepixels(6.0, 6.0, 256, 256, 0.25, 0.25; posang=π/4) + gr = imagepixels(6.0, 6.0, 256, 256, 0.25, 0.25; posang=π / 4) uv = range(-2.0, 2.0) m = modify(Gaussian(), Stretch(0.25, 0.5)) - pm = PolarizedModel(m, 0.1 * m, -0.2*m, 0.01*m) + pm = PolarizedModel(m, 0.1 * m, -0.2 * m, 0.01 * m) testrot(pm, g, gr, uv) testrot(pm, g, gr, uv; alg=FFTAlg()) testrot(pm, g, gr, uv; alg=DFTAlg()) @@ -86,15 +86,13 @@ end @testset "Rotated Grid and shifted model" begin g = imagepixels(6.0, 6.0, 256, 256) - gr= imagepixels(6.0, 6.0, 256, 256; posang=π/4) + gr = imagepixels(6.0, 6.0, 256, 256; posang=π / 4) uv = range(-2.0, 2.0) m = modify(Gaussian(), Stretch(0.25, 0.5), Shift(0.1, 0.1)) - pm = PolarizedModel(m, 0.1 * m, -0.2*m, 0.01*m) + pm = PolarizedModel(m, 0.1 * m, -0.2 * m, 0.01 * m) testrot(pm, g, gr, uv) testrot(pm, g, gr, uv; alg=FFTAlg()) testrot(pm, g, gr, uv; alg=DFTAlg()) end - -