Skip to content

Commit 31564d4

Browse files
committed
feat: add type 2 and 3 scans to generate scan
1 parent a1860ac commit 31564d4

File tree

2 files changed

+381
-33
lines changed

2 files changed

+381
-33
lines changed

socs/agents/acu/agent.py

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@
3131
'ccat': {
3232
'az_speed': 2,
3333
'az_accel': 1,
34+
'el_freq': .15,
3435
},
3536
'satp': {
3637
'az_speed': 1,
3738
'az_accel': 1,
39+
'el_freq': 0,
3840
},
3941
}
4042

@@ -234,7 +236,7 @@ def __init__(self, agent, acu_config='guess',
234236
sun_config=self.sun_config)
235237
self._reset_sun_params()
236238

237-
# Scan params (default vel / accel).
239+
# Scan params (default vel / accel / el freq).
238240
self.default_scan_params = \
239241
dict(INIT_DEFAULT_SCAN_PARAMS[self.platform_type])
240242
for _k in self.default_scan_params.keys():
@@ -1781,6 +1783,7 @@ def set_speed_mode(self, session, params):
17811783

17821784
@ocs_agent.param('az_speed', type=float, default=None)
17831785
@ocs_agent.param('az_accel', type=float, default=None)
1786+
@ocs_agent.param('el_freq', type=float, default=None)
17841787
@ocs_agent.param('reset', default=False, type=bool)
17851788
@inlineCallbacks
17861789
def set_scan_params(self, session, params):
@@ -1793,13 +1796,15 @@ def set_scan_params(self, session, params):
17931796
az_speed (float, optional): The azimuth scan speed.
17941797
az_accel (float, optional): The (average) azimuth
17951798
acceleration at turn-around.
1799+
el_freq (float, optional): The frequency of elevation nods in
1800+
type 3 scans.
17961801
reset (bool, optional): If True, reset all params to default
17971802
values before applying any updates passed explicitly here.
17981803
17991804
"""
18001805
if params['reset']:
18011806
self.scan_params.update(self.default_scan_params)
1802-
for k in ['az_speed', 'az_accel']:
1807+
for k in ['az_speed', 'az_accel', 'el_freq']:
18031808
if params[k] is not None:
18041809
self.scan_params[k] = params[k]
18051810
self.log.info('Updated default scan params to {sp}', sp=self.scan_params)
@@ -2009,6 +2014,7 @@ def line_batcher(ff_scan, t_shift=0., n=10):
20092014
@ocs_agent.param('el_endpoint1', type=float, default=None)
20102015
@ocs_agent.param('el_endpoint2', type=float, default=None)
20112016
@ocs_agent.param('el_speed', type=float, default=0.)
2017+
@ocs_agent.param('el_freq', type=float, default=None)
20122018
@ocs_agent.param('num_scans', type=float, default=None)
20132019
@ocs_agent.param('start_time', type=float, default=None)
20142020
@ocs_agent.param('wait_to_start', type=float, default=None)
@@ -2018,6 +2024,8 @@ def line_batcher(ff_scan, t_shift=0., n=10):
20182024
'mid_inc', 'mid_dec'])
20192025
@ocs_agent.param('az_drift', type=float, default=None)
20202026
@ocs_agent.param('az_only', type=bool, default=True)
2027+
@ocs_agent.param('type', default=1, choices=[1, 2, 3])
2028+
@ocs_agent.param('az_vel_ref', type=float, default=1)
20212029
@ocs_agent.param('scan_upload_length', type=float, default=None)
20222030
@inlineCallbacks
20232031
def generate_scan(self, session, params):
@@ -2068,12 +2076,18 @@ def generate_scan(self, session, params):
20682076
positive az velocity), 'mid_dec' (negative az velocity),
20692077
or 'mid' (velocity oriented towards endpoint2).
20702078
az_drift (float): if set, this should be a drift velocity
2071-
in deg/s. The scan extrema will move accordingly. This
2072-
can be used to better follow compact sources as they
2073-
rise or set through the focal plane.
2079+
in deg/s. The scan extrema will move accordingly. This
2080+
can be used to better follow compact sources as they
2081+
rise or set through the focal plane.
20742082
az_only (bool): if True (the default), then only the
20752083
Azimuth axis is put in ProgramTrack mode, and the El axis
20762084
is put in Stop mode.
2085+
type (int): What type of scan to use. Only 1, 2, 3 are valid.
2086+
Type 1 is a constant elevation scan.
2087+
Type 2 includes a variation in az speed that scales as sin(az).
2088+
Type 3 is a Type 2 with an sinusoidal el nod.
2089+
az_vel_ref (float or None): azimuth to center the velocity profile at.
2090+
If None then the average of the endpoints is used.
20772091
scan_upload_length (float): number of seconds for each set
20782092
of uploaded points. If this is not specified, the
20792093
track manager will try to use as short a time as is
@@ -2096,14 +2110,18 @@ def generate_scan(self, session, params):
20962110
az_endpoint2 = params['az_endpoint2']
20972111
el_endpoint1 = params['el_endpoint1']
20982112
el_endpoint2 = params['el_endpoint2']
2113+
az_vel_ref = params['az_vel_ref']
20992114

21002115
# Params with defaults configured ...
21012116
az_speed = params['az_speed']
21022117
az_accel = params['az_accel']
2118+
el_freq = params['el_freq']
21032119
if az_speed is None:
21042120
az_speed = self.scan_params['az_speed']
21052121
if az_accel is None:
21062122
az_accel = self.scan_params['az_accel']
2123+
if el_freq is None:
2124+
el_freq = self.scan_params['el_freq']
21072125

21082126
# Do we need to limit the az_accel? This limit comes from a
21092127
# maximum jerk parameter; the equation below (without the
@@ -2206,18 +2224,43 @@ def generate_scan(self, session, params):
22062224
return False, f'Start position seek failed with message: {msg}'
22072225

22082226
# Prepare the point generator.
2209-
g = sh.generate_constant_velocity_scan(az_endpoint1=az_endpoint1,
2210-
az_endpoint2=az_endpoint2,
2211-
az_speed=az_speed, acc=az_accel,
2212-
el_endpoint1=el_endpoint1,
2213-
el_endpoint2=el_endpoint2,
2214-
el_speed=el_speed,
2215-
az_first_pos=plan['init_az'],
2216-
**scan_params)
2227+
free_form = False
2228+
if params["type"] == 1:
2229+
g = sh.generate_constant_velocity_scan(az_endpoint1=az_endpoint1,
2230+
az_endpoint2=az_endpoint2,
2231+
az_speed=az_speed, acc=az_accel,
2232+
el_endpoint1=el_endpoint1,
2233+
el_endpoint2=el_endpoint2,
2234+
el_speed=el_speed,
2235+
az_first_pos=plan['init_az'],
2236+
**scan_params)
2237+
elif params["type"] == 2:
2238+
free_form = True
2239+
g = sh.generate_type2_scan(az_endpoint1=az_endpoint1,
2240+
az_endpoint2=az_endpoint2,
2241+
az_speed=az_speed, acc=az_accel,
2242+
el_endpoint1=el_endpoint1,
2243+
az_vel_ref=az_vel_ref,
2244+
az_first_pos=plan['init_az'],
2245+
**scan_params)
2246+
elif params["type"] == 3:
2247+
free_form = True
2248+
azonly = False
2249+
g = sh.generate_type3_scan(az_endpoint1=az_endpoint1,
2250+
az_endpoint2=az_endpoint2,
2251+
az_speed=az_speed, acc=az_accel,
2252+
el_endpoint1=el_endpoint1,
2253+
el_endpoint2=el_endpoint2,
2254+
el_freq=el_freq,
2255+
az_vel_ref=az_vel_ref,
2256+
az_first_pos=plan['init_az'],
2257+
**scan_params)
2258+
else:
2259+
raise ValueError("Scan type must be 1, 2, or 3")
22172260

22182261
return (yield self._run_track(
22192262
session=session, point_gen=g, step_time=step_time,
2220-
azonly=azonly, point_batch_count=point_batch_count))
2263+
azonly=azonly, point_batch_count=point_batch_count, free_form=free_form))
22212264

22222265
@inlineCallbacks
22232266
def _run_track(self, session, point_gen, step_time, azonly=False,

0 commit comments

Comments
 (0)