simonsobs / sorunlib

High level library for running observatory operations using OCS.
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Support adjusting starting position of scan if scan starts late and az_drift is non-zero #137

Closed BrianJKoopman closed 2 weeks ago

BrianJKoopman commented 8 months ago

When scanning a target like a planet we are currently always checking whether the scan started on time, and if not, adjusting the starting position in order to account for the drift of the target since the original start of the scan. In practice this looks like:

run.wait_until('2024-03-11T17:47:12.083594+00:00')
now = datetime.datetime.now(tz=UTC)
scan_start = datetime.datetime(2024, 3, 11, 17, 47, 12, 83594, tzinfo=datetime.timezone.utc)
## edit stop to have time to move to next scan
scan_stop = datetime.datetime(2024, 3, 11, 19, 50, 50, 702470, tzinfo=datetime.timezone.utc)
if now > scan_start:
    # adjust scan parameters
    az = 53.115 + -0.00514*(now-scan_start).total_seconds()
else: 
    az = 53.115
if now > scan_stop:
    # too late, don't scan
    pass
else:
    run.acu.move_to(az, 55)

    print('Waiting until 2024-03-11 17:47:12.083594+00:00 to start scan')
    run.wait_until('2024-03-11T17:47:12.083594+00:00')

    run.seq.scan(
        description='jupiter', 
        stop_time='2024-03-11T19:50:50.702470+00:00', 
        width=17.8, 
        az_drift=-0.00514, 
        subtype='cal',
        tag='jupiter,rising,ws2',
    )

The scheduler implements this here. It'd be nice if we could capture this logic somewhere in sorunlib.

Perhaps it could be added in seq.scan(), but then we need to start passing a position and start time to it. Other ideas?

BrianJKoopman commented 8 months ago

Thinking about this a bit more, maybe a run.acu.move_to_target(az, el, start_time, az_drift) that does this check, and effectively replaces run.acu.move_to() in the example above?