mkdetrend tools

dettool -define [options]
 * define a new detRun, specifying the constraints, and adding it to
 the run table.  if the detRun ID already exists, creates a new
 version.  the initial state is set to START.  the iteration is set to
 0. also creates a new master detrend frame entry
 (detID.version.iteration define this frame uniquely).
 
options : 
  -ID ID : a free-form string; if not specified, a unique string is constructed
  -type type : bias dark (mask?) flat fringe (other?)
  -camera camera 
  -filter filter
  -time start stop
  -exptime min max
  -airmass min max
  -expgroup groupID

  (-type and -camera are mandatory)
  (-filter is mandatory for 'light' types)
  (-exptime is mandatory for dark)

dettool -getinput
 * select the input matching a given detRun.  selects the input
 exposures and the input files.
 - this function could be merged with -define
 - an alternate implementation would define a detRun ID for a given
 stack of input exposures

dettool -select raw [-state state] [-outmode mode]
 * select the frames to be processed and extract the list of files 
 - output of this program is used by pantasks to schedule the ppImage
 run on each image

dettool -select stack [-state state] [-outmode mode]
 * select the files to be stacked for a given detRun
 - output of this program is used by ppMerge to build a master stack

dettool -select residual [-state state]
 * select the frames to be used to generate residuals
 - output of this program is used for another ppImage run 

detmerge 
 * for a given master detrend frame, compile the results from the
 stacks for each chip and renormalize the output files as needed.
 assemble the resulting master stats as available

detstats
 * for a given master detrend frame, compile the results from the
 residual images and assess the validity of the input images and of
 the complete stack.  if too many input images are rejected, the
 affect the master detrend frame state.  if input images are rejected
 and a new set of master stacks should be made, create a new master
 detrend image, incrementing the iteration by one.

** NOTE the sequence is: 

   process, stack, merge, residual, assess
              ^--------------------------<

   IF we have no relevant detrend image for comparison.  otherwise,
   the sequence should skip from process to residual on the first
   pass, with a lower rejection threshold for the first assess pass.
   the tools above allow either option; it is the choice of state
   after process that determines which happens next.

