}

Guider

Overview

The guider software uses a camera to take images, analyze for offsets, and drive the telescope to remove the offsets.  The guider also has utilities to setup a guide star.  While the guider is running, users can tweak guide parameters.

Guider Commands

The Shack-Hartmann is meant to be as simple as possible.  It sets the stage according to the type of object to observe, and it exposes the camera and writes images.

centroid

Centroid a star position.  This also sets the guide star to the centroided star.

  • centroid time=S [window=X0,Y0,X1,Y1] [bin=N] [bin=X,Y] [on=X,Y] or
  • centroid file=NAME [on=X,Y]

expose

     Take an open-shutter exposure.

  • expose time=S [window=X0,Y0,X1,Y1] [bin=N] [bin=X,Y]

findstars

    Take an exposure and locate the stars sorted by the best.

  • findstars time=S [window=X0,Y0,X1,Y1] [bin=N] [bin=X,Y]

guide centerOn

  • guide centerOn=404.19,162.76 cradius=5.0 exptime=1.0 bin=1 window=0,0,511,511 thresh=2.5 imgFile='dcam/UT130704/proc-d0002.fits'"

guide on

Turn on the guider.  The mode is either manual, boresight, or field, and the other paramters are over ridden as needed.  Tweaks can be done later.

  • guide on field gstar=286.27,115.45 cradius=6.0 exptime=40.0 bin=1 window=0,0,511,511 radMult=1.2 thresh=2.5 imgFile='dcam/UT130704/proc-d0028.fits'
  • guide on boresight exptime=15.0 bin=1 window=0,0,511,511 radMult=1.2 thresh=2.5 imgFile='dcam/UT130704/proc-d0134.fits'

guide off

Turn off the guider.  If an exposure is in progress, this does not wait for it to finish.

guide tweak

Change something with a tweak.  Some things that can change are gstar, binning, windowing, and star fit parameters.

  • guide tweak boresight exptime=15.0 window=0,0,511,511 imgFile='ecam/UT130704/proc-e1167.fits'
  • guide tweak field gstar=169.60,261.04 cradius=7.0 window=0,0,511,511 imgFile='ecam/UT130705/proc-e0063.fits'

help

Displays help for the commands.  Does not take any arguments.

replay

Replay a guider directory

  • replay UT131225
  • replay off     # turn off replay

status

returns many status keywords

setMask

setMask [filename], load a mask file. Reload existing mask if no file is specified

User Details

The guider has three guiding modes: boresight, field guide star, and manual. Some guiders are strictly field guide star and manual, such as the NA2 guider.  The guider uses a star tracking package.  Two other tracking packages are on the drawing table: quad cell and correlation.  Generally, the tracker takes a CCD x, y position to find a reference star, and then uses that star's position as the tracked position.  Offsets are applied to the telescope to keep the star centered on that position.  In boresight mode, the reference position is gotten by asking the tcc for the current value for each frame.

The guider is written as a machine that is in one of four states, Idle, Expose, Center Up, and Guide.  See Software Design for more details.  The guider is always Idle, unless it is executing a command and is in another state. When it is not Idle, and a command to use the guider is tried, it will fail.

Tweak commands adust the the guider while it is guiding.  The tweaks are cached in the guider, and applied at the start of the next exposure.

The guider  uses the telescope for computed and un-computed offsets. If a user slews or stops the telescope axes, the guider will stop. When the telescope is moving, the guider either waits for the motion to stop or defer (skip) the exposure.  When the move completes, the guider is notified, and if waiting for the move to complete, the machine will transition to the next state, which is usually to loop back and re-run the guide state.  The guider runs until the machine receives a guide off command.  The guide off command does not wait for the camera expose to complete, and the machine quickly transitions to Idle.  This is a bug and needs to solved.  Preferably, the exposure can be aborted as part of turning off the guide.

The guider tracks a guide star. A user can select a guide star, and it will guide until a reasonable centroid is no longer found. When a guide star is not found, the guide star missing sound is played. If the guide star is missing for 2 times in a row, the guider tries the best star in the field on the next loop.  The guider will keep trying for a reference star until a retry count, currently 5, is reached, and the guider goes to manual mode.

The user can switch back to guide mode by selecting the mode and clicking apply on TUI.

Star Tracker

Configuration Items

  • RETRIES - 2, missing guide star retries before searching for a new star
  • BEST - age > 2, missing = 0, skipped = 0
  • NTRIES - 2, star in list is missing, it is dropped
  • NSTARS - 10 stars returned to user
  • STAR_RAD_DIFF - star radius difference is within this error window, 10
  • SEEN_ONCE_AND_MISSING = 1 - if the star's age is 2 frames or older, if the skip count is age-1, then nuke the entry.  It was a hot pixel and disappeared.
  • BEST_SKIPPED = 0 - on best star choice, the number of skipped frames is checked against BEST_SKIPPED.  If you allow a top star in the list (brightest, oldest, least skipped) to be remembered, but disappeared,  then set BEST_SKIPPED to 1 or more frames to allow the diappearance.
The star tracker uses the PyGuide software to locate and fit stars.  It is built to accept images, keep a list of star entries, return the best entry, and lookup a star based on the CCD x, y position.

The list is used to remember stars from the previous frames.  If it is a hot pixel, the star does not appear in the next frame, and it starts falling off the list.  The best stars are the brightest, oldest, and zero images skipped.  The age for best star is a star with an age of > 1 frame.  If the star is skipped 2 times, it is removed from the list.  If the new star field does not match at all any stars in the list, then the list is deleted and the new stars added to an empty list.  No common stars is an indication that the field has changed.

Software Design

User talks to guider in hub protocol, which then calls the guider that has a guide machine.  The guide machine is a camera and a tracker, for now a star tracker, and the telescope to calculate and update the pointing offsets.

The guide machine is a hierarchical finite state machine, which is great for describing a precise complicated sequence.  The 3.5m guide machine is the following.  On the top level, there is Idle, Expose, CenterOn, and Guide.  The machine has objects representing the tcc, an exposure, a tracker, and it has callbacks generating new events.  For example, a move is started by the guider, which goes through the tcc, and the tcc is calling back on all move changes.  When an offset is made, I can clear a flag, make the move, and wait for the callback that the move is done set the flag.  There are a number of examples where code is cooperating to set events as the machine goes through its sequence.                                                                                                                                   
MAX_RETRIES = 5         # number of times to retry acquiring a guide                                                               
MAX_MOVE_FAILS = 5      # FIX - put in configuration file      



A daemon is created that listens for events published to a queue, and when an event arrives, it passes the event to the state machine.  There are three input sources: a user, telescope motion, and a camera. The input sources send events to the machine.  The event data structure actually is an event type and a context object which is name=value dictionary.

Top Level States

Idle

Expose

The expose state is a generic expose sequence that uses callbacks to customize the exposure.

CenterOn

The CenterOn state is used to center the guide star on the boresight.  When CenterOn runs, it sets the guide mode to boresight.

The CenterOn state is entered from the Idle state on a "centerup" event.  It uses much of the machinery the guide loop uses, but, it runs only once.

The sequence of events are:
1) analyse previous frame and find the star to center up on the boresight.
2) offset the telescope
3) wait for telescope move to complete
4) take an exposure and run findstars
5) done - go back to Idle


Guide

The guide loop is entered from the Idle state on a 'guide on' event.  It will execute the do_guide_on() method during the transition.  When the guide loop is entered, the setupLoop() method is run..  The initial state transitions to the Expose state automatically  All the paths after the Expose state lead to the final state, which loops around and back into the guide state.  'guide off' can interrupt the machine and transition to the Idle state after calling the do_guide_off().