NAME:
  occproc
 PURPOSE:   (one line only)
  Simple aperture photometry of occultation data
 DESCRIPTION:

  This tool is for an initial aperture photometry extraction of a single
    source from a set of FITS images, usually from a stellar occultation
    observation.  It is currently designed for use on data taken with
    the QHY174M-GPS camera.  However, the only thing specific to this camera
    is the use of BACKSUB.PRO that removes a row-by-row level from the
    image to eliminate the detector bias striping.  The philosophy
    here is to build a tool that makes it fast and easy to process good
    quality data that are collected in the recommended fashion.  It is NOT
    intended to help you through the possibly agonizing process of dealing
    with challenging data whether due to dodgy weather conditions or
    errant observing procedures.

  This GUI is designed to work from a master root directory under which
    all different occultation campaign results are stored.  In this
    directory there must be a helper program, getddir.pro, that will
    return a valid location for data given a relative directory.  This
    is designed to allow off-site and on-site reductions as well as not
    requiring all data to be co-located.  The calling sequence for this
    routine is:
       getddir,rdir,ddir
    where rdir is the relative directory that will be provided by the user
    through the GUI.  ddir is then the name of the top level directory
    where that rdir can be found.

  In the local directory the top level has directories that are named
    for each project.  Inside each project directory the output files
    that are generated for that project are stored here.  There is a
    master configuration file (config.dat) that applies to all data
    for the event.  This contains the name of the event and the UT date.
    Each site has its own configuration file (ending in .dat).  There is
    one file for each time/site combination that has per-site configuration.
    The included information is an estimate of image quality, the aperture
    used for photometry, and the position of the target star in the first
    frame.  The files ending in .lc are the actual lightcurve files.
    The columns:
      1 - index number
      2 - JD of image mid-time
      3 - normalized flux
      4 - X position
      5 - Y position
      6 - FWHM in pixels
    The precision of the timing stored in the file is good to about
      0.1 msec.

  There are two levels for the nomenclature of datasets to process:
    Project: This refers to a string that will identify the event.
             There can be many datasets within one project.  Examples
             are something like 'LE20181114' or 'RECON79'.  However,
             this string is just a string and not parsed for content.
             This string must not contain spaces and really shouldn't
             contain anything other than letters and numbers.
    Dataset: This refers to the data collected at a single site.  The
             typical case here will be the name of a camera or a system
             but could be a site or team name as well.  This depends
             entirely on the project.  Again, this is just a string
             with the same restrictions and suggests as for the project
             string.

  If there is only one site it is automatically selected.  Otherwise, you
    have to select your site (look until the File menu).  Similarly, if
    there is only one dataset (time), that is automatically loaded.  More
    than one you have to select.

  The first 20 frames are used to determine a baseline for the target star
    signal.  After that is done, there is a threshold set of 10% of the
    baseline.  If the star drops below this threshold, it's position is not
    updated based on the previous exposure.  This lets it step over a short
    occultation signal without losing positional lock on the target star.
    Otherwise, the program will track the star as is moves slightly from
    frame to frame.  If it moves too much between frames it will lose lock.
    Data like this falls into the category of "difficult" and isn't (yet)
    supported.  Likewise, if the occultation is very long and the field
    drifts too much while the star is missing, it will lose lock.

 CATEGORY:
  Photometry
 CALLING SEQUENCE:
  occproc
 INPUTS:
 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:
 OUTPUTS:
 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
 MODIFICATION HISTORY:
  Written by Marc W. Buie, Southwest Research Institute, 2020/01/13