NAME:
  des_sum
 PURPOSE:
  Create a summary listing of KBOs in all directories of DES data
 DESCRIPTION:
 CATEGORY:
  Astronomy
 CALLING SEQUENCE:
  des_sum, rootid
 INPUTS:
  rootid - input date for output file name, YYMMDD
 OPTIONAL INPUT PARAMETERS:
 KEYWORD INPUT PARAMETERS:
  ASTPATH - path to astrometry data, '/net/frakir/raid/buie/astrometry' 
  REDPATH - path to reduced data, default is '/net/frakir/raid/reduced'
  RAWPATH - path to image data, default is a vector:
             ['/net/frakir/data1/buie/rawfits',
              '/gw/data7/buie/rawfits', '/gw/data3/buie/rawfits']
  KBOPATH - location of bernstein files,
             default is '/net/frakir/raid/buie/kbo/Bernstein'
  OUTPATH - location for output file, current default is 
             '/net/frakir/raid/reduced/Summary/Current/'
 OUTPUTS: 
  outfile - output file for kbo list, default name is 'osYYMMDD.0.txt'
            'os' stands for "object summary (file)" and '0' is version number
 KEYWORD OUTPUT PARAMETERS:
 COMMON BLOCKS:
 SIDE EFFECTS:
 RESTRICTIONS:
 PROCEDURE:
    The goal with this file is to have a list of all the kbos that belong to
    DES as original discoveries. The orbital elements in this file are for the
    day of file generation and can be updated for the given set of targets at
    any time in the future using des_update. 
    Outline of code:
       (1) Get list of DES kbos (designated and undesignated): from desig.dat
              and oblist.dat
       (2) Get a list of the survey directories on frakir to be used later.
       (3) Split up the object list into five options: MPC designation, MPC
              name, preliminary designation, local code (MB) or temporary
              code (looker)
       (4) Generate a list of local codes and cross-references using newobj.dat
       (5) Get looker ids by reading lpast.xrft files
       (6) Read .info files to get magnitudes from discovery file 
       (7) Read .ast files to get discovery date, time, RA and DEC
       (8) Get current orbital element information using ephem
       (9) Get survey field ID and filter information, truncate filter
              information
       (10) Calculate Hmag and Hmagerr for discovery filter
              error based on orbit not photometry 
       (11) Get quality of observation information -- needs to be added,
              dummy variable for now
       (12) Stuff information into output array
       (13) Write output to file 'osYYMMDD.0.txt'
 MODIFICATION HISTORY:
 01/01/04, Written by Susan Kern
 01/04/06, DBT - Fixed bug in sort, Fixed bug in KBOName, cleand up code
 02/06/10, SDK - took out original sort, revised and cleaned up code.
 02/07/02, SDK - changed method of getting orbits to ephem from reading
                    bernstein files.  
 02/07/03, SDK - modified output statement, added error to log for missing 
                    for filter information
 02/07/09, SDK - fixed header problems, added back getinfo to get H,G.
 02/08/03, SDK - fixed matching problem for linked objs, fixed search dir list
 03/01/21, MWB - fixed loop counter on scanning Mosaic reduction directories
 03/02/04, MWB - added a trap on reading lplast.xrft files to catch when those
                   files don't exist or are empty.
 04/01/19, SDK - modified magnitude input to come from .ast file rather than 
                   .info file, values in all locations now for the most part  
 04/02/18, SDK - added new data path, update KBOPATH, ASTPATH
  2004/9/21, MWB, removed obsolete call to Findfile
  2010/09/01, MWB, changed default rawpath.
  2012/04/19, SDB, changed aerr field to include another digit, matching a (semi).