Skip to content
Open
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
14 changes: 11 additions & 3 deletions src/sorunlib/seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@ def _stop_scan():
print("Scan finished.")


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 @@ -53,7 +57,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
Loading