From 6fd25d45acfdf4a68e9a78902959e8516ca354c4 Mon Sep 17 00:00:00 2001 From: adriaanph Date: Fri, 13 Mar 2020 11:38:33 +0200 Subject: [PATCH 1/2] Check that target is up for duration of raster Added straight-forward code to check that the source remains above horizon for the estimated duration of the raster. To facilitate this, I had to re-factor the code to separate (A) selection of the raster scan pattern from (B) the execution of the selected pattern. This change does not affect any of the scan patterns or other logic. --- observation/point_source_scan.py | 40 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/observation/point_source_scan.py b/observation/point_source_scan.py index a96e8077..c8edbbfb 100755 --- a/observation/point_source_scan.py +++ b/observation/point_source_scan.py @@ -91,36 +91,35 @@ class NoTargetsUpError(Exception): targets_before_loop = len(targets_observed) # Iterate through source list, picking the next one that is up for target in pointing_sources.iterfilter(el_limit_deg=opts.horizon): - session.label('raster') - user_logger.info("Doing scan of '%s' with current azel (%s, %s)", - target.description, *target.azel()) # Do different raster scan on strong and weak targets if not opts.quick and not opts.fine: if opts.source_strength == 'strong' or \ - (opts.source_strength == 'auto' and target.flux_density(opts.centre_freq) > 10.0): - session.raster_scan(target, num_scans=5, scan_duration=30, scan_extent=6.0, - scan_spacing=0.25, scan_in_azimuth=not opts.scan_in_elevation, - projection=opts.projection) + (opts.source_strength == 'auto' and target.flux_density(opts.centre_freq) > 10.0): + raster_params = dict(num_scans=5, scan_duration=30, scan_extent=6.0, scan_spacing=0.25) else: - session.raster_scan(target, num_scans=5, scan_duration=60, scan_extent=4.0, - scan_spacing=0.25, scan_in_azimuth=not opts.scan_in_elevation, - projection=opts.projection) + raster_params = dict(num_scans=5, scan_duration=60, scan_extent=4.0, scan_spacing=0.25) else: # The branch for Quick and Fine scans if opts.quick: - session.raster_scan(target, num_scans=3, scan_duration=15, scan_extent=5.0, - scan_spacing=0.5, scan_in_azimuth=not opts.scan_in_elevation, - projection=opts.projection) + raster_params = dict(num_scans=3, scan_duration=15, scan_extent=5.0, scan_spacing=0.5) elif opts.fine: - session.raster_scan(target, num_scans=5, scan_duration=60, scan_extent=1.0, - scan_spacing=4. / 60., scan_in_azimuth=not opts.scan_in_elevation, - projection=opts.projection) + raster_params = dict(num_scans=5, scan_duration=60, scan_extent=1.0, scan_spacing=4/60.) else: # if opts.search_fine: - session.raster_scan(target, num_scans=9, scan_duration=60, scan_extent=2.0, - scan_spacing=5. / 60., scan_in_azimuth=not opts.scan_in_elevation, - projection=opts.projection) - + raster_params = dict(num_scans=9, scan_duration=60, scan_extent=2.0, scan_spacing=5/60.) + + # Confirm that the target will be "up" for the entire duration. + raster_duration = raster_params["num_scans"] * (raster_params["scan_duration"] + 2) # Extra for slew + if not session.target_visible(target, duration=raster_duration): + continue + + # Perform raster scan on this target + session.label('raster') + user_logger.info("Doing scan of '%s' with current azel (%s, %s)", + target.description, *target.azel()) + session.raster_scan(target, projection=opts.projection, scan_in_azimuth=not opts.scan_in_elevation, + **raster_params) targets_observed.append(target.name) skip_file.write(target.description + "\n") + # The default is to do only one iteration through source list if opts.min_time <= 0.0: keep_going = False @@ -128,6 +127,7 @@ class NoTargetsUpError(Exception): elif time.time() - start_time >= opts.min_time: keep_going = False break + if keep_going and len(targets_observed) == targets_before_loop: user_logger.warning("No targets are currently visible - " "stopping script instead of hanging around") From 4d2fa32b48b84bf0989f20327f38f355bac0e420 Mon Sep 17 00:00:00 2001 From: adriaanph Date: Wed, 18 Mar 2020 17:19:53 +0200 Subject: [PATCH 2/2] Added nd_time to visibility check As requested in PR #428 I've now added similar code as in session.raster_scan() to anticipate the potential noise diode cycle time per scan. --- observation/point_source_scan.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/observation/point_source_scan.py b/observation/point_source_scan.py index c8edbbfb..0a35b917 100755 --- a/observation/point_source_scan.py +++ b/observation/point_source_scan.py @@ -81,6 +81,9 @@ class NoTargetsUpError(Exception): session.standard_setup(**vars(opts)) session.capture_start() + nd_duration = session.nd_params['on'] + session.nd_params['off'] + nd_duration = nd_duration if session.nd_params['period'] >= 0 else 0. + start_time = time.time() targets_observed = [] # Keep going until the time is up @@ -107,7 +110,9 @@ class NoTargetsUpError(Exception): raster_params = dict(num_scans=9, scan_duration=60, scan_extent=2.0, scan_spacing=5/60.) # Confirm that the target will be "up" for the entire duration. - raster_duration = raster_params["num_scans"] * (raster_params["scan_duration"] + 2) # Extra for slew + nd_time = nd_duration * raster_params["scan_duration"] / max(session.nd_params['period'], + raster_params["scan_duration"]) + raster_duration = raster_params["num_scans"] * (raster_params["scan_duration"]+nd_time+2) # Extra for slew if not session.target_visible(target, duration=raster_duration): continue