Skip to content

Commit dfcc22b

Browse files
committed
stokes I works with only 1 par hand
1 parent 5d839f3 commit dfcc22b

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "VLBIData"
22
uuid = "679fc9cc-3e84-11e9-251b-cbd013bd8115"
33
authors = ["Alexander Plavin <alexander@plav.in>"]
4-
version = "0.5.10"
4+
version = "0.5.11"
55

66
[deps]
77
AccessorsExtra = "33016aad-b69d-45be-9359-82a41f556fd4"

src/polarizedtypes.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ function uvtable_values_to(::Type{IPol}, uvtbl)
2222
grs = @p uvtbl group_vg((;_.datetime, _.freq_spec, _.spec))
2323
return map(grs) do gr
2424
par_hands = @p gr filter(x -> is_parallel_hands(x.stokes))
25-
length(par_hands) == 2 || error("expected 2 parallel-hand Stokes per group, got $(length(par_hands))")
26-
val = sum(x -> x.value, par_hands) / 2
25+
length(par_hands) (1, 2) || error("expected 1 or 2 parallel-hand Stokes per group, got $(length(par_hands))")
26+
val = mean(x -> x.value, par_hands)
2727
@p let
2828
first(gr)
2929
@set __.value = val

test/runtests.jl

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,31 @@ end
278278
ipol_lin = VLBI.uvtable_values_to(IPol, uvtbl_lin)
279279
@test ipol_lin[1].value == 5.0
280280

281-
# IPol: error when only 1 parallel hand
282-
@test_throws "expected 2 parallel-hand" VLBI.uvtable_values_to(IPol, uvtbl_err)
281+
# IPol: from single parallel hand (RR only)
282+
uvtbl_single_rr = [
283+
(datetime=1, freq_spec=100.0, spec=1, stokes=:RR, value=11.0),
284+
(datetime=1, freq_spec=100.0, spec=1, stokes=:LR, value=12.0),
285+
(datetime=1, freq_spec=100.0, spec=1, stokes=:RL, value=13.0),
286+
]
287+
ipol_single = VLBI.uvtable_values_to(IPol, uvtbl_single_rr)
288+
@test length(ipol_single) == 1
289+
@test ipol_single[1].value == 11.0
290+
@test !haskey(ipol_single[1], :stokes)
291+
292+
# IPol: from single parallel hand (LL only)
293+
uvtbl_single_ll = [
294+
(datetime=1, freq_spec=100.0, spec=1, stokes=:LL, value=7.0),
295+
]
296+
ipol_single_ll = VLBI.uvtable_values_to(IPol, uvtbl_single_ll)
297+
@test length(ipol_single_ll) == 1
298+
@test ipol_single_ll[1].value == 7.0
299+
300+
# IPol: error when no parallel hands
301+
uvtbl_no_par = [
302+
(datetime=1, freq_spec=100.0, spec=1, stokes=:LR, value=12.0),
303+
(datetime=1, freq_spec=100.0, spec=1, stokes=:RL, value=13.0),
304+
]
305+
@test_throws "expected 1 or 2 parallel-hand" VLBI.uvtable_values_to(IPol, uvtbl_no_par)
283306
end
284307

285308
@testitem "_" begin

0 commit comments

Comments
 (0)