Skip to content
Merged
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
19 changes: 17 additions & 2 deletions src/observations/operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@ function add_fractional_noise!(dvis::EHTObservationTable{<:Union{EHTVisibilityDa
return dvis
end

function add_fractional_noise!(dcl::EHTObservationTable{<:ClosureProducts}, ferr)
conf = arrayconfig(dcl)
nois = noise(dcl)
vis = getfield(conf, :vis)
nvi = getfield(conf, :noise)
dmat = designmat(conf)
map!(nvi, nvi, vis) do e, m
fe = sqrt.(e.^2 .+ ferr.^2*abs2(m))
return fe
end
# update the noise covariance matrix
nois .= dmat*Diagonal(abs2.(nvi./vis))*transpose(dmat)
return dcl
end


"""
add_fractional_noise(dvis::AbstractObservationTable, ferr)
Expand All @@ -29,8 +44,8 @@ data is identical except the noise is replaced with
where `σ` is dvis[:noise] and `V` is dvis[:measurement].

!!! warning
We do not implement this function for closures since the error should be added directly to the
visibilities.
When the datum type <: ClosureProducts, we do not update the noise covariance matrix.
This means that cross-correlation may be slightly incorrect.
"""
function add_fractional_noise(dvis, ferr)
dvis = deepcopy(dvis)
Expand Down
5 changes: 5 additions & 0 deletions test/Core/observation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ end
@test visn[:measurement] ≈ vis[:measurement]
@test visn[:noise] ≈ hypot.(vis[:noise], 0.01 .* abs.(vis[:measurement]))

cpn = add_fractional_noise(cphase, 0.01)
@test cpn[:measurement] ≈ cphase[:measurement]
@test getfield(arrayconfig(cpn), :noise) ≈ hypot.(vis[:noise], 0.01 .* abs.(vis[:measurement]))
@test cpn.noise ≈ parent(Comrade.factornoisecovariance(arrayconfig(cpn)))

cohn = add_fractional_noise(dcoh, 0.01)
@test cohn[:measurement] ≈ dcoh[:measurement]
@test cohn[:noise].:1 ≈ hypot.(dcoh[:noise].:1, 0.01 .* abs.(tr.(dcoh[:measurement]))/2)
Expand Down
Loading