Skip to content

Commit 27f0dc8

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent cf437dd commit 27f0dc8

File tree

2 files changed

+82
-81
lines changed

2 files changed

+82
-81
lines changed

socs/agents/acu/agent.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,32 +2219,32 @@ def generate_scan(self, session, params):
22192219
free_form = False
22202220
if params["type"] == 1:
22212221
g = sh.generate_constant_velocity_scan(az_endpoint1=az_endpoint1,
2222-
az_endpoint2=az_endpoint2,
2223-
az_speed=az_speed, acc=az_accel,
2224-
el_endpoint1=el_endpoint1,
2225-
el_endpoint2=el_endpoint2,
2226-
el_speed=el_speed,
2227-
az_first_pos=plan['init_az'],
2228-
**scan_params)
2222+
az_endpoint2=az_endpoint2,
2223+
az_speed=az_speed, acc=az_accel,
2224+
el_endpoint1=el_endpoint1,
2225+
el_endpoint2=el_endpoint2,
2226+
el_speed=el_speed,
2227+
az_first_pos=plan['init_az'],
2228+
**scan_params)
22292229
elif params["type"] == 2:
2230-
free_form = True
2230+
free_form = True
22312231
g = sh.generate_type2_scan(az_endpoint1=az_endpoint1,
2232-
az_endpoint2=az_endpoint2,
2233-
az_speed=az_speed, acc=az_accel,
2234-
el_endpoint1=el_endpoint1,
2235-
az_first_pos=plan['init_az'],
2236-
**scan_params)
2232+
az_endpoint2=az_endpoint2,
2233+
az_speed=az_speed, acc=az_accel,
2234+
el_endpoint1=el_endpoint1,
2235+
az_first_pos=plan['init_az'],
2236+
**scan_params)
22372237
elif params["type"] == 3:
2238-
free_form = True
2238+
free_form = True
22392239
azonly = False
22402240
g = sh.generate_type3_scan(az_endpoint1=az_endpoint1,
2241-
az_endpoint2=az_endpoint2,
2242-
az_speed=az_speed, acc=az_accel,
2243-
el_endpoint1=el_endpoint1,
2244-
el_endpoint2=el_endpoint2,
2245-
el_freq=el_freq,
2246-
az_first_pos=plan['init_az'],
2247-
**scan_params)
2241+
az_endpoint2=az_endpoint2,
2242+
az_speed=az_speed, acc=az_accel,
2243+
el_endpoint1=el_endpoint1,
2244+
el_endpoint2=el_endpoint2,
2245+
el_freq=el_freq,
2246+
az_first_pos=plan['init_az'],
2247+
**scan_params)
22482248
else:
22492249
raise ValueError("Scan type must be 1, 2, or 3")
22502250

socs/agents/acu/drivers.py

Lines changed: 61 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ def timecode(acutime, now=None):
266266
comptime = gyear + sec_of_day
267267
return comptime
268268

269+
269270
def _get_target_az(current_az, current_t, increasing, az_endpoint1, az_endpoint2, az_speed, az_drift):
270271
# Return the next endpoint azimuth, based on current (az, t)
271272
# and whether to move in +ve or -ve az direction.
@@ -492,17 +493,17 @@ def check_num_scans():
492493

493494

494495
def generate_type3_scan(az_endpoint1, az_endpoint2, az_speed,
495-
acc, el_endpoint1, el_endpoint2,
496-
el_freq=.15,
497-
num_batches=None,
498-
num_scans=None,
499-
start_time=None,
500-
wait_to_start=10.,
501-
step_time=1.,
502-
batch_size=500,
503-
az_start='mid_inc',
504-
az_first_pos=None,
505-
az_drift=None):
496+
acc, el_endpoint1, el_endpoint2,
497+
el_freq=.15,
498+
num_batches=None,
499+
num_scans=None,
500+
start_time=None,
501+
wait_to_start=10.,
502+
step_time=1.,
503+
batch_size=500,
504+
az_start='mid_inc',
505+
az_first_pos=None,
506+
az_drift=None):
506507
"""Python generator to produce times, azimuth and elevation positions,
507508
azimuth and elevation velocities, azimuth and elevation flags for
508509
arbitrarily long type 3 scan.
@@ -552,23 +553,22 @@ def generate_type3_scan(az_endpoint1, az_endpoint2, az_speed,
552553
553554
"""
554555
def get_scan_time(az0, az1, az_speed, az_cent):
555-
upper = -1*np.cos(np.deg2rad(az1 - az_cent))
556-
lower = -1*np.cos(np.deg2rad(az0 - az_cent))
556+
upper = -1 * np.cos(np.deg2rad(az1 - az_cent))
557+
lower = -1 * np.cos(np.deg2rad(az0 - az_cent))
557558

558-
return abs(upper - lower)/np.deg2rad(az_speed)
559+
return abs(upper - lower) / np.deg2rad(az_speed)
559560

560561
if az_endpoint1 == az_endpoint2:
561562
raise ValueError('Generator requires two different az endpoints!')
562563

563564
if az_drift is not None:
564-
raise ValueError ("Az drift not supported for type 2 or 3 scans!")
565-
565+
raise ValueError("Az drift not supported for type 2 or 3 scans!")
566566

567567
if abs(az_endpoint1 - az_endpoint2) > 140:
568568
raise ValueError("Type 2 and 3 scans must have a throw less than or equal to 70 degrees")
569569

570570
# Get center of az range
571-
az_cent = (az_endpoint1 + az_endpoint1)/2. - 90
571+
az_cent = (az_endpoint1 + az_endpoint1) / 2. - 90
572572

573573
# Get el throw
574574
el_throw = abs(el_endpoint2 - el_endpoint1)
@@ -605,23 +605,23 @@ def get_scan_time(az0, az1, az_speed, az_cent):
605605
else:
606606
t0 = start_time
607607

608-
vel_0 = az_speed/np.sin(np.deg2rad(az_endpoint1 - az_cent))
609-
vel_1 = az_speed/np.sin(np.deg2rad(az_endpoint2 - az_cent))
610-
min_tt = {1:(0.85 * abs(vel_0) / 9 * 11.616)**.5, -1:(0.85 * abs(vel_1) / 9 * 11.616)**.5}
611-
tt = {1: max(2*vel_0/acc, min_tt[1]), -1: max(2*vel_1/acc, min_tt[-1])}
608+
vel_0 = az_speed / np.sin(np.deg2rad(az_endpoint1 - az_cent))
609+
vel_1 = az_speed / np.sin(np.deg2rad(az_endpoint2 - az_cent))
610+
min_tt = {1: (0.85 * abs(vel_0) / 9 * 11.616)**.5, -1: (0.85 * abs(vel_1) / 9 * 11.616)**.5}
611+
tt = {1: max(2 * vel_0 / acc, min_tt[1]), -1: max(2 * vel_1 / acc, min_tt[-1])}
612612
t = 0
613613
el = el_endpoint1
614614
if step_time < 0.05:
615615
raise ValueError('Time step size too small, must be at least '
616616
'0.05 seconds')
617-
el_vel = el_throw*el_freq*2*np.pi*np.cos(t*el_freq*2*np.pi)
617+
el_vel = el_throw * el_freq * 2 * np.pi * np.cos(t * el_freq * 2 * np.pi)
618618
az_flag = 0
619619
el_flag = 0
620620
if num_batches is None:
621621
stop_iter = float('inf')
622622
else:
623623
stop_iter = num_batches
624-
batch_size = int(np.ceil(get_scan_time(az_endpoint1, az_endpoint2, az_speed, az_cent)/step_time))
624+
batch_size = int(np.ceil(get_scan_time(az_endpoint1, az_endpoint2, az_speed, az_cent) / step_time))
625625

626626
def dec_num_scans():
627627
nonlocal num_scans
@@ -631,7 +631,7 @@ def dec_num_scans():
631631
def check_num_scans():
632632
return num_scans is None or num_scans > 0
633633

634-
target_az = _get_target_az(az, t, increasing, az_endpoint1, az_endpoint2, az_speed/np.sin(np.deg2rad(az - az_cent)), az_drift)
634+
target_az = _get_target_az(az, t, increasing, az_endpoint1, az_endpoint2, az_speed / np.sin(np.deg2rad(az - az_cent)), az_drift)
635635
point_group_batch = 0
636636

637637
i = 0
@@ -641,59 +641,59 @@ def check_num_scans():
641641
for j in range(batch_size):
642642
point_block.append(TrackPoint(
643643
timestamp=t + t0,
644-
az=az, el=el, az_vel=az_vel/np.sin(np.deg2rad(az - az_cent)), el_vel=el_vel,
644+
az=az, el=el, az_vel=az_vel / np.sin(np.deg2rad(az - az_cent)), el_vel=el_vel,
645645
az_flag=az_flag, el_flag=el_flag,
646646
group_flag=int(point_group_batch > 0)))
647647

648648
if point_group_batch > 0:
649649
point_group_batch -= 1
650650

651651
if increasing:
652-
if get_scan_time(az, target_az, az_speed, az_cent) > 2*step_time:
652+
if get_scan_time(az, target_az, az_speed, az_cent) > 2 * step_time:
653653
t += step_time
654-
az += step_time*az_speed/np.sin(np.deg2rad(az - az_cent))
655-
el = el_endpoint1 + el_throw*np.sin(t*el_freq*2*np.pi)
654+
az += step_time * az_speed / np.sin(np.deg2rad(az - az_cent))
655+
el = el_endpoint1 + el_throw * np.sin(t * el_freq * 2 * np.pi)
656656
az_vel = az_speed
657-
el_vel = el_throw*el_freq*2*np.pi*np.cos(t*el_freq*2*np.pi)
657+
el_vel = el_throw * el_freq * 2 * np.pi * np.cos(t * el_freq * 2 * np.pi)
658658
az_flag = 1
659659
el_flag = 0
660660
elif az == target_az:
661661
# Turn around.
662-
t += tt[1]
662+
t += tt[1]
663663
az_vel = -1 * az_speed
664-
el_vel = 0
664+
el_vel = 0
665665
az_flag = 1
666666
el_flag = 0
667667
increasing = False
668-
target_az = _get_target_az(az, t, increasing, az_endpoint1, az_endpoint2, az_speed/np.sin(np.deg2rad(az - az_cent)), az_drift)
668+
target_az = _get_target_az(az, t, increasing, az_endpoint1, az_endpoint2, az_speed / np.sin(np.deg2rad(az - az_cent)), az_drift)
669669
dec_num_scans()
670670
point_group_batch = MIN_GROUP_NEW_LEG - 1
671671
else:
672672
time_remaining = get_scan_time(az, target_az, az_speed, az_cent)
673673
az = target_az
674674
t += time_remaining
675675
az_vel = az_speed
676-
el_vel = 0
676+
el_vel = 0
677677
az_flag = 2
678678
el_flag = 0
679679
else:
680-
if get_scan_time(az, target_az, az_speed, az_cent) > 2*step_time:
680+
if get_scan_time(az, target_az, az_speed, az_cent) > 2 * step_time:
681681
t += step_time
682-
az -= step_time*az_speed/np.sin(np.deg2rad(az - az_cent))
683-
el = el_endpoint1 + el_throw*np.sin(t*el_freq*2*np.pi)
682+
az -= step_time * az_speed / np.sin(np.deg2rad(az - az_cent))
683+
el = el_endpoint1 + el_throw * np.sin(t * el_freq * 2 * np.pi)
684684
az_vel = -1 * az_speed
685-
el_vel = el_throw*el_freq*2*np.pi*np.cos(t*el_freq*2*np.pi)
685+
el_vel = el_throw * el_freq * 2 * np.pi * np.cos(t * el_freq * 2 * np.pi)
686686
az_flag = 1
687687
el_flag = 0
688688
elif az == target_az:
689689
# Turn around.
690690
t += tt[-1]
691691
az_vel = az_speed
692-
el_vel = 0
692+
el_vel = 0
693693
az_flag = 1
694694
el_flag = 0
695695
increasing = True
696-
target_az = _get_target_az(az, t, increasing, az_endpoint1, az_endpoint2, az_speed/np.sin(np.deg2rad(az - az_cent)), az_drift)
696+
target_az = _get_target_az(az, t, increasing, az_endpoint1, az_endpoint2, az_speed / np.sin(np.deg2rad(az - az_cent)), az_drift)
697697
dec_num_scans()
698698
point_group_batch = MIN_GROUP_NEW_LEG - 1
699699
else:
@@ -715,17 +715,18 @@ def check_num_scans():
715715

716716
yield point_block
717717

718+
718719
def generate_type2_scan(az_endpoint1, az_endpoint2, az_speed,
719-
acc, el_endpoint1,
720-
num_batches=None,
721-
num_scans=None,
722-
start_time=None,
723-
wait_to_start=10.,
724-
step_time=1.,
725-
batch_size=500,
726-
az_start='mid_inc',
727-
az_first_pos=None,
728-
az_drift=None):
720+
acc, el_endpoint1,
721+
num_batches=None,
722+
num_scans=None,
723+
start_time=None,
724+
wait_to_start=10.,
725+
step_time=1.,
726+
batch_size=500,
727+
az_start='mid_inc',
728+
az_first_pos=None,
729+
az_drift=None):
729730
"""Python generator to produce times, azimuth and elevation positions,
730731
azimuth and elevation velocities, azimuth and elevation flags for
731732
arbitrarily long type 2 scan.
@@ -772,17 +773,17 @@ def generate_type2_scan(az_endpoint1, az_endpoint2, az_speed,
772773
773774
"""
774775
return generate_type3_scan(az_endpoint1, az_endpoint2, az_speed,
775-
acc, el_endpoint1, el_endpoint1,
776-
el_freq=0,
777-
num_batches=num_batches,
778-
num_scans=num_scans,
779-
start_time=start_time,
780-
wait_to_start=wait_to_start,
781-
step_time=step_time,
782-
batch_size=batch_size,
783-
az_start=az_start,
784-
az_first_pos=az_first_pos,
785-
az_drift=az_drift)
776+
acc, el_endpoint1, el_endpoint1,
777+
el_freq=0,
778+
num_batches=num_batches,
779+
num_scans=num_scans,
780+
start_time=start_time,
781+
wait_to_start=wait_to_start,
782+
step_time=step_time,
783+
batch_size=batch_size,
784+
az_start=az_start,
785+
az_first_pos=az_first_pos,
786+
az_drift=az_drift)
786787

787788

788789
def plan_scan(az_end1, az_end2, el, v_az=1, a_az=1, az_start=None):

0 commit comments

Comments
 (0)