opened
adriaanph
username_0
there's a bug (legacy, not from recent changes) in [observation/interferometric_pointing.py](https://github.com/ska-sa/katsdpscripts/blob/master/observation/interferometric_pointing.py). the actual recorded data shows that the first offset on each target ("offset0") is ignored, so the actual measured pattern is [bore sight, offset1, offset2, ..., offsetN]

```
ds = katdal.open("http://archive-gw-1.kat.ac.za:7480/1584002146/1584002146_sdp_l0.full.rdb",ref_ant="m000")
ds.select(ants='m000', scans='track')
#print(ds)
figure(figsize=(6,6))
title(ds.name)
for cs in ds.compscans():
    for s,scan in enumerate(ds.scans()):
        plot(ds.target_x, ds.target_y, '+', color='C%d'%cs[0], label=("CS %d"%cs[0] if s==0 else None))
xlabel("target_x"); ylabel("target_y"); legend()
```

in short, the "unrolled" code currently does:
```
session.label('interferometric_pointing')
session.track(target,duration)
offset_target=[+1.5,0]; session.ants.req.offset_fixed(offset_target[0], offset_target[1], opts.projection); session.track(target,duration)
offset_target=[0,+1.5]; session.ants.req.offset_fixed(offset_target[0], offset_target[1], opts.projection); session.track(target,duration)
offset_target=[-1.5,0]; session.ants.req.offset_fixed(offset_target[0], offset_target[1], opts.projection); session.track(target,duration)
offset_target=[0,-1.5]; session.ants.req.offset_fixed(offset_target[0], offset_target[1], opts.projection); session.track(target,duration)
```

i have tried adding 
`session.ants.req.mode('POINT);` after each `req.fixed_offset` but that did not make any difference.
(Legacy bug) first offset ignored in interferometric_pointing.py
issue
created
adriaanph
username_0
here's one case which suggests that it works some times: the first 11 compscans "skip" the first offset, but then from CS11 onward the expected pattern is reproduced perfectly.

```
ds = katdal.open("http://archive-gw-1.kat.ac.za:7480/1583338764/1583338764_sdp_l0.full.rdb",ref_ant="m000")
ds.select(ants='m000', scans='track')
for cs in ds.compscans():
    offsets = []
    for s,scan in enumerate(ds.scans()):
        offsets.append("%+.1f,%+.1f"%(ds.target_x.mean(), ds.target_y.mean()))
    print("CS %d\t%s"%(cs[0], offsets))
```

CS 0 	['+0.0,-0.0', '+0.0,-0.0', '+0.0,+1.5', '-1.5,-0.0', '+0.0,-1.5']
CS 1 	['+0.0,-0.0', '+0.0,+0.0', '+0.0,+1.5', '-1.5,+0.0', '+0.0,-1.5']
CS 2 	['+0.0,-0.0', '-0.0,-0.0', '-0.0,+1.5', '-1.5,-0.0', '+0.0,-1.5']
CS 3 	['-0.0,-0.0', '-0.0,+0.0', '-0.0,+1.5', '-1.5,+0.0', '-0.0,-1.5']
CS 4 	['-0.0,+0.0', '+0.0,-0.0', '+0.0,+1.5', '-1.5,+0.0', '+0.0,-1.5']
CS 5 	['-0.0,-0.0', '+0.0,+0.0', '+0.0,+1.5', '-1.5,+0.0', '-0.0,-1.5']
CS 6 	['+0.0,-0.0', '+0.0,-0.0', '+0.0,+1.5', '-1.5,-0.0', '-0.0,-1.5']
CS 7 	['+0.0,-0.0', '+0.0,+0.0', '+0.0,+1.5', '-1.5,+0.0', '+0.0,-1.5']
CS 8 	['-0.0,-0.0', '+0.0,-0.0', '-0.0,+1.5', '-1.5,-0.0', '+0.0,-1.5']
CS 9 	['+0.0,-0.0', '-0.0,+0.0', '+0.0,+1.5', '-1.5,-0.0', '-0.0,-1.5']
CS 10	['-0.0,+0.0', '-0.0,+0.0', '+0.0,+1.5', '-1.5,-0.0', '-0.0,-1.5']
CS 11	['+0.0,-0.0', '+1.5,+0.0', '+0.0,+1.5', '-1.5,+0.0', '+0.0,-1.5']
CS 12	['-0.0,-0.0', '+1.5,-0.0', '+0.0,+1.5', '-1.5,+0.0', '-0.0,-1.5']
CS 13	['+0.0,+0.0', '+1.5,-0.0', '+0.0,+1.5', '-1.5,-0.0', '-0.0,-1.5']
CS 14	['-0.0,+0.0', '+1.5,-0.0', '+0.0,+1.5', '-1.5,+0.0', '-0.0,-1.5']
CS 15	['+0.0,-0.0', '+1.5,-0.0', '-0.0,+1.5', '-1.5,-0.0', '+0.0,-1.5']
CS 16	['-0.0,-0.0', '+1.5,+0.0', '-0.0,+1.5', '-1.5,-0.0', '-0.0,-1.5']
CS 17	['+0.0,+0.0', '+1.5,-0.0', '+0.0,+1.5', '-1.5,+0.0', '+0.0,-1.5']
comment
created
ludwigschwardt
username_1
Right... I've figured it out by referring back to the canonical interferometric pointing script, [observation/reference_pointing.py](https://github.com/ska-sa/katsdpscripts/blob/master/observation/reference_pointing.py). 😛 

When the tags are stripped off the target before the first offset, it becomes a different target. This means that it is actually set on the antenna proxies, which clears the fixed offset, thereby killing the first offset.

My humble suggestion is to run this script on a catalogue without any tags.
comment
created
ludwigschwardt
username_1
Another thing to be aware of: if you are looping over the same target, the initial track will remember the last offset of the previous iteration and you'll lose the initial (0, 0) offset. It's best to explicitly clear the offset before the first track.
comment
created
ludwigschwardt
username_1
Another tip: there is no need anymore for the `ref_ant="m000"` parameter to `katdal.open`. In fact, it can be dangerous if you happened to pick a busted dish. The default "reference antenna" is `array`, which is the prescriptive reference (i.e. what the array should have done, instead of what one dish is actually doing).
comment
created
adriaanph
username_0
awesome, thanks!
comment
closed
adriaanph
username_0
issue
created
adriaanph
username_0
i've just tried out a "fix" and it worked perfectly. i'll proceed with the change proposal in github now.
thanks again!
comment