Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that target is up for duration of raster #428

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 25 additions & 20 deletions observation/point_source_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -91,43 +94,45 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In session's raster_scan there is already a check like this:

        # Calculate average time that noise diode is operated per scan,
        # to add to scan duration in check below
        nd_time = session.nd_params['on'] + session.nd_params['off']
        nd_time *= scan_duration / max(session.nd_params['period'],
                                       scan_duration)
        nd_time = nd_time if session.nd_params['period'] >= 0 else 0.
        # Check whether target is visible for entire duration of raster scan
        if not session.target_visible(target,
                                      (scan_duration + nd_time) * num_scans):
            user_logger.warning("Skipping raster scan, as target %r will be "
                                "below horizon", target.name)
            return False

Doesn't that work? Maybe this script just needs to check the return value of session.raster_scan.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i agree, will strip this code from my PR.

i also think the doc comment in session.track(), scan() & raster_scan() should explicitly state that this visibility check is performed. @ajoubertza i'll leave that decision and follow-up to you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hang on, i take that back.

to address the original issue #5 one must skip out before the code reaches session.raster_scan(), since otherwise there will still be a compscan with a small number of dumps but without raster data.

Copy link
Contributor

@ludwigschwardt ludwigschwardt Mar 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. This is an artifact of the way compscan labels work. If we ever had kattelmod-driven scripts, you could chuck out the raster scan without an actual label. Hey, one is allowed to dream...

Thinking about it again, we could actually rework raster_scan and friends to include this functionality, although we would have to fix existing observation scripts - a potentially daunting task. Could you make a ticket so that we can remember? Anton can advise which project (CB?).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ludwigschwardt You can use the MT project.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ludwigschwardt you should make your own ticket - i don't particularly care for the task that you have identified, and you are best placed to describe what you think must be done. i am only interested in seeing my change through against the current code base.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ludwigschwardt what's the status? has the raster_scan functionality been reworked?.


# 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
# If the time is up, stop immediately
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")
Expand Down