@@ -266,6 +266,7 @@ def timecode(acutime, now=None):
266
266
comptime = gyear + sec_of_day
267
267
return comptime
268
268
269
+
269
270
def _get_target_az (current_az , current_t , increasing , az_endpoint1 , az_endpoint2 , az_speed , az_drift ):
270
271
# Return the next endpoint azimuth, based on current (az, t)
271
272
# and whether to move in +ve or -ve az direction.
@@ -492,17 +493,17 @@ def check_num_scans():
492
493
493
494
494
495
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 ):
506
507
"""Python generator to produce times, azimuth and elevation positions,
507
508
azimuth and elevation velocities, azimuth and elevation flags for
508
509
arbitrarily long type 3 scan.
@@ -552,23 +553,22 @@ def generate_type3_scan(az_endpoint1, az_endpoint2, az_speed,
552
553
553
554
"""
554
555
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 ))
557
558
558
- return abs (upper - lower )/ np .deg2rad (az_speed )
559
+ return abs (upper - lower ) / np .deg2rad (az_speed )
559
560
560
561
if az_endpoint1 == az_endpoint2 :
561
562
raise ValueError ('Generator requires two different az endpoints!' )
562
563
563
564
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!" )
566
566
567
567
if abs (az_endpoint1 - az_endpoint2 ) > 140 :
568
568
raise ValueError ("Type 2 and 3 scans must have a throw less than or equal to 70 degrees" )
569
569
570
570
# Get center of az range
571
- az_cent = (az_endpoint1 + az_endpoint1 )/ 2. - 90
571
+ az_cent = (az_endpoint1 + az_endpoint1 ) / 2. - 90
572
572
573
573
# Get el throw
574
574
el_throw = abs (el_endpoint2 - el_endpoint1 )
@@ -605,23 +605,23 @@ def get_scan_time(az0, az1, az_speed, az_cent):
605
605
else :
606
606
t0 = start_time
607
607
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 ])}
612
612
t = 0
613
613
el = el_endpoint1
614
614
if step_time < 0.05 :
615
615
raise ValueError ('Time step size too small, must be at least '
616
616
'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 )
618
618
az_flag = 0
619
619
el_flag = 0
620
620
if num_batches is None :
621
621
stop_iter = float ('inf' )
622
622
else :
623
623
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 ))
625
625
626
626
def dec_num_scans ():
627
627
nonlocal num_scans
@@ -631,7 +631,7 @@ def dec_num_scans():
631
631
def check_num_scans ():
632
632
return num_scans is None or num_scans > 0
633
633
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 )
635
635
point_group_batch = 0
636
636
637
637
i = 0
@@ -641,59 +641,59 @@ def check_num_scans():
641
641
for j in range (batch_size ):
642
642
point_block .append (TrackPoint (
643
643
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 ,
645
645
az_flag = az_flag , el_flag = el_flag ,
646
646
group_flag = int (point_group_batch > 0 )))
647
647
648
648
if point_group_batch > 0 :
649
649
point_group_batch -= 1
650
650
651
651
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 :
653
653
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 )
656
656
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 )
658
658
az_flag = 1
659
659
el_flag = 0
660
660
elif az == target_az :
661
661
# Turn around.
662
- t += tt [1 ]
662
+ t += tt [1 ]
663
663
az_vel = - 1 * az_speed
664
- el_vel = 0
664
+ el_vel = 0
665
665
az_flag = 1
666
666
el_flag = 0
667
667
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 )
669
669
dec_num_scans ()
670
670
point_group_batch = MIN_GROUP_NEW_LEG - 1
671
671
else :
672
672
time_remaining = get_scan_time (az , target_az , az_speed , az_cent )
673
673
az = target_az
674
674
t += time_remaining
675
675
az_vel = az_speed
676
- el_vel = 0
676
+ el_vel = 0
677
677
az_flag = 2
678
678
el_flag = 0
679
679
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 :
681
681
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 )
684
684
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 )
686
686
az_flag = 1
687
687
el_flag = 0
688
688
elif az == target_az :
689
689
# Turn around.
690
690
t += tt [- 1 ]
691
691
az_vel = az_speed
692
- el_vel = 0
692
+ el_vel = 0
693
693
az_flag = 1
694
694
el_flag = 0
695
695
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 )
697
697
dec_num_scans ()
698
698
point_group_batch = MIN_GROUP_NEW_LEG - 1
699
699
else :
@@ -715,17 +715,18 @@ def check_num_scans():
715
715
716
716
yield point_block
717
717
718
+
718
719
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 ):
729
730
"""Python generator to produce times, azimuth and elevation positions,
730
731
azimuth and elevation velocities, azimuth and elevation flags for
731
732
arbitrarily long type 2 scan.
@@ -772,17 +773,17 @@ def generate_type2_scan(az_endpoint1, az_endpoint2, az_speed,
772
773
773
774
"""
774
775
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 )
786
787
787
788
788
789
def plan_scan (az_end1 , az_end2 , el , v_az = 1 , a_az = 1 , az_start = None ):
0 commit comments