Skip to content

Commit

Permalink
Add start_position argument to seq.scan()
Browse files Browse the repository at this point in the history
Resolves #190.
  • Loading branch information
BrianJKoopman committed Dec 10, 2024
1 parent a971ba5 commit 87ab2e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/sorunlib/seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,22 @@
OP_TIMEOUT = 60


def scan(description, stop_time, width, az_drift=0, tag=None, subtype=None,
min_duration=None):
def scan(description, stop_time, width, az_drift=0, start_position=None,
tag=None, subtype=None, min_duration=None):
"""Run a constant elevation scan, collecting detector data.
Args:
description (str): Description of the field/object being scanned.
stop_time (str): Time in ISO format to scan until, i.e.
"2022-06-21T15:58:00"
width (float): Scan width in azimuth. The scan will start at the
current position and move in the positive azimuth direction.
current position unless specified in ``start_position``. The scan
moves in the positive azimuth direction.
az_drift (float): Drift velocity in deg/s, causing scan extrema to move
accordingly.
start_position (tuple, optional): Starting position given as (azimuth,
elevation). If provided, the telescope will move to this position
before starting the scan.
tag (str, optional): Tag or comma-separated listed of tags to attach to
the operation. Passed through to the smurf stream command.
subtype (str, optional): Operation subtype used to tag the stream.
Expand All @@ -36,7 +40,11 @@ def scan(description, stop_time, width, az_drift=0, tag=None, subtype=None,
if now > scan_stop:
return

if start_position:
run.acu.move_to(*start_position)

# Check there is enough time to perform scan
now = dt.datetime.now(dt.timezone.utc)
if min_duration is not None:
start_by_time = scan_stop - dt.timedelta(seconds=min_duration)
if now > start_by_time:
Expand Down
9 changes: 9 additions & 0 deletions tests/test_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ def test_scan(patch_clients):
seq.scan(description='test', stop_time=target.isoformat(), width=20.)


@patch('sorunlib._internal.time.sleep', MagicMock())
def test_scan_start_position(patch_clients):
# This affects test runtime duration keep it short
target = dt.datetime.now(dt.timezone.utc) + dt.timedelta(seconds=0.01)
seq.scan(description='test', stop_time=target.isoformat(), width=20.,
start_position=(208.5, 60.0))
seq.run.CLIENTS['acu'].go_to.assert_called_with(az=208.5, el=60.0)


@patch('sorunlib._internal.time.sleep', MagicMock())
def test_scan_passed_stop_time(patch_clients):
# This affects test runtime duration keep it short
Expand Down

0 comments on commit 87ab2e3

Please sign in to comment.