# Observation Scheduler¶

The observation scheduler allows jobs to be queued-up and performed with minimal human intervention.

While acreroad_1420 only controls the drives, the scheduler is capable of executing a program, for example an observing program.

## Examples¶

The easiest way to understand the functionality of the scheduler is through some examples.

### Drift Scan¶

This code sets up a drift scan. The telescope is positioned pointing due South (at an azimuth of 180 degrees), and at a fixed altitude, with the tracking turned off. As the sky moves overhead the pointing right ascension changes, but the declination remains fixed.

# Set up the scheduler
from acreroad_1420 import drive, schedule
import numpy as np
import astropy
# Make the connection to the drive
connection = drive.Drive('/dev/ttyACM0', 9600, simulate=0)
# Start the queue up
jobs = schedule.Scheduler(drive=connection)

##########################################################################

# For convenience let's have the number of seconds in a day in a variable
day = 24*3600

# Make an observation
jobs.at("08 03 2016 17:10:00",             # Start at 17:10 on 8/3/16
script='/home/astro/srt2016/observing.py', # Run this GNURadio script
position="h180.0 +56.08",                  # Point the telescope at az=180d, alt=+56d
forsec=day                                 # Run the observation for 24*3600 seconds
)


The classes described here run the observation scheduler for the radio telescope.

## Scheduler¶

class acreroad_1420.schedule.Scheduler(drive=None)[source]

Methods

 at sort
at(time, script=None, args=None, position=None, until=None, forsec=None, then=None)[source]

Schedule the execution of a script and the pointing of the telescope to a specific location.

Parameters: time : str, datetime or astropy Time object The time at which the observation should start, i.e. the time when the script will be executed. If the time is given as a string, it should be in the format 17 06 2015 13:14. script : str The filepath of the script which will conduct the observation. This can currently be a Python script, any script with a Shebang or a GNU Radio flowchart. args : str The command-line arguments for the script given in script. position : str or Astropy skycoord A parsable string containing the sky position at which the observation should be conducted, or an astropy skycoord object, or the name of a source. until : datetime or astropy Time object The time at which the obervation should be ended. In the future this can also be the string “set”, in which case the forsec : datetime delta or int The amount of time the observation should be run for, or the datetime delta representing the time period of the observation. then : {python callable, str} An instruction to carry out once the observation has been completed, for example, moving the telescope to the stow position. int The job number assigned to the observation.

Notes

The observation scheduler was written principly for the use of the H1 telescope at the University of Glasgow’s Acre Road Observatory, however the aim of this project was to make a sufficiently general utility that it could be transferred at least to the Observatory’s other radio telescopes.

The scheduler operates using a thread dedicated to maintaining and checking the schedule. Every time a new item is added to the schedule it is sorted, and the scheduler checks whether it is due to start an observation. In order to ensure that an observation can start on time the scheduler will move the telescope in advance, and so up to 2 minutes’ leeway is required between observations to allow this process to occur. The scheduler attempts to predict this movement time in order to avoid excessive outages during small movements.

Examples

This example schedules an observation, runs a script, and then when it finishes, restows the telescope.

>>> # Set up the scheduler
>>> from acreroad_1420 import schedule, drive
>>> import
>>> connection = drive.Drive('/dev/tty.usbserial', 9600, simulate=1)
>>> jobs = schedule.Scheduler(drive=connection)
>>> # Add a job in galactic coordinates
>>> jobs.at('17 06 2015 00:00:00', script='/home/astro/recorder.py', position='g1h12m43.2s +1d12m43s', until='17 06 2016 12:00:00', then=connection.stow)