diff --git a/observation/point_source_scan.py b/observation/point_source_scan.py index f269594e..20b69332 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 @@ -91,36 +94,37 @@ 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(session.get_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(session.get_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. + 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 + + # 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 +132,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")