|
1 | 1 | import datetime as dt
|
| 2 | +import time |
2 | 3 |
|
3 | 4 | import sorunlib as run
|
4 | 5 |
|
|
9 | 10 | OP_TIMEOUT = 60
|
10 | 11 |
|
11 | 12 |
|
12 |
| -def _stop_scan(): |
13 |
| - acu = run.CLIENTS['acu'] |
14 |
| - |
15 |
| - print("Stopping scan.") |
| 13 | +def _stop_smurfs(): |
16 | 14 | # Stop SMuRF streams
|
17 | 15 | try:
|
18 | 16 | run.smurf.stream('off')
|
19 | 17 | except RuntimeError as e:
|
20 | 18 | print(f"Caught error while shutting down SMuRF streams: {e}")
|
21 | 19 |
|
| 20 | + |
| 21 | +def _stop_scan(): |
| 22 | + acu = run.CLIENTS['acu'] |
| 23 | + |
| 24 | + print("Stopping scan.") |
| 25 | + _stop_smurfs() |
| 26 | + |
22 | 27 | # Stop motion
|
23 | 28 | acu.generate_scan.stop()
|
24 | 29 | resp = acu.generate_scan.wait(timeout=OP_TIMEOUT)
|
@@ -85,3 +90,43 @@ def scan(description, stop_time, width, az_drift=0, tag=None, subtype=None,
|
85 | 90 | monitor_process(acu, 'generate_scan', stop_time)
|
86 | 91 | finally:
|
87 | 92 | _stop_scan()
|
| 93 | + |
| 94 | + |
| 95 | +def el_nod(el1, el2, num=5, pause=5): |
| 96 | + """Perform a set of elevation nods. |
| 97 | +
|
| 98 | + Elevation nods will be peformed at the current azimuth, and will start from |
| 99 | + and return to the current elevation. The nod first moves to ``el1``, |
| 100 | + pauses, then moves to ``el2``, pauses, and then repeats for the |
| 101 | + specified number of iterations. |
| 102 | +
|
| 103 | + Args: |
| 104 | + el1 (float): First elevation to move to during the nod. |
| 105 | + el2 (float): Second elevation to move to during the nod. |
| 106 | + num (int): Number of nods to peform. Defaults to 5. |
| 107 | + pause (float): Length of pause, in seconds, at each elevation. Defaults |
| 108 | + to 5 seconds. |
| 109 | +
|
| 110 | + """ |
| 111 | + acu = run.CLIENTS['acu'] |
| 112 | + |
| 113 | + # Enable SMuRF streams |
| 114 | + run.smurf.stream('on', subtype='cal', tag='el_nods') |
| 115 | + |
| 116 | + try: |
| 117 | + # Grab current telescope position |
| 118 | + resp = acu.monitor.status() |
| 119 | + init_az = resp.session['data']['StatusDetailed']['Azimuth current position'] |
| 120 | + init_el = resp.session['data']['StatusDetailed']['Elevation current position'] |
| 121 | + |
| 122 | + # Perform nods |
| 123 | + for x in range(num): |
| 124 | + run.acu.move_to(az=init_az, el=el1) |
| 125 | + time.sleep(pause) |
| 126 | + run.acu.move_to(az=init_az, el=el2) |
| 127 | + time.sleep(pause) |
| 128 | + else: |
| 129 | + # Return to initial position |
| 130 | + run.acu.move_to(az=init_az, el=init_el) |
| 131 | + finally: |
| 132 | + _stop_smurfs() |
0 commit comments