NAME:
    ccdphot
 PURPOSE: (one line)
    General purpose display and processing of CCD image (FITS) files.
 DESCRIPTION:
    A general purpose widget application which displays and processes CCD
 image files. This includes bias, dark, flat field, and fringe correction
 plus serves the photometry reduction (itool).
 CATEGORY:
    Widgets
 CALLING SEQUENCE:
    ccdphot[, keywords]
 INPUTS:

 OPTIONAL INPUT PARAMETERS:

 KEYWORD PARAMETERS:
    BLOCK         : If set, ccdphot will run in blocked mode.
    EXPERT        : Flag. Turns on certain "expert" modes of operation.
                    (1) Suppresses dialog during "Auto" mode, regarding
                        stop condition.
    CALIBFILE=    : Calibration startup file.  Default is CALIBPATH/files.cal

    CALIBPATH=    : Path for calibration files.  Default is PATH/calib

    KEYLIST=      : Name of a file containing a correspondence list. This list
                    associates a set of standard names with the actual keyword
                    names found in a FITS file header. If this keyword is
                    omitted, a default list is used, as if a file with the
                    following contents had been supplied:
                     AIRMASS   K  AIRMASS
                     DATE      K  DATE-OBS
                     DATETMPL  T  DD-MM-YYYY
                     EXPDELTA  V  0.0
                     EXPTIME   K  EXPTIME
                     FILTER    K  FILTERS
                     FILENAME  K  CCDFNAME
                     OBJECT    K  OBJECT
                     UT        K  UT 

                    The middle column is a flag. It may be K, for Keyword,
                    T, for Template, or V, for Value. If it is V, the contents
                    of the third field on that line should make sense for the
                    name in the first field.

    PATH=         : Optional path for image and calibration directory.
                    If not specified, the current directory is used.

    PATTERN       : Optional file-search pattern. Default is '*.*' .

    PHOTPARMFILE  : Optional photometry parameter file.  Passed to Itool.

    TMPLFILE      : Optional template file.  Passed to Itool.

    WZOOMFACT     : Forces the itool main draw window to have a specified
                    zoom factor (passed to itool).

  WXVISIBLE       : Creates work window with explicit x-size (passed to
                    itool).

  WYVISIBLE       : Creates work window with explicit y-size (passed to
                    itool).

 OUTPUTS:

 COMMON BLOCKS:

 SIDE EFFECTS:

 RESTRICTIONS:

 PROCEDURE:

 MODIFICATION HISTORY:
    Written by Doug Loucks, Lowell Observatory, December, 1993.
    Created by combining lccd.pro, loral.pro, and ccdphot_inst_init.pro.
    Added features include: Correspondence list for FITS header keywords
       and recognition of old format calibration environment files.
    1/26/94, DWL, Added header date-parsing code to ldimage procedure.
    3/2/94,  DWL, Added keylist item EXPDELTA.
    3/3/94,  DWL, Improved the template and header date-parsing process.
    3/10/94, DWL, Bug fixes.
    4/94,    DWL, Thorough validation of all environment parameters (overscan,
       cropping region, and bias/flat size compatibility).
    3/1/95,  MWB, Added support for a dark count calibrator (optional).
    6/8/95,  MWB, Changed defaults on calibration paths.  Also, if file
                  name begins with "+", CALIBPATH will replace the "+".
    10/31/95, MWB, Added CATCH error handler to trap bad image file reads
                  using READFITS.  This prevents a crash to the IDL prompt
                  when an invalid file is read.
    3/18/96, MWB, Minor change to code that reads UT from header.  Format
                  requires two colons in string (HH:MM:SS) but also now
                  allows SS to be a floating point number (ie., SS.sss).
    6/25/96, MWB, implemented AUTO(-photometry) button.
    1/22/97, MWB, fixed AUTO infinite loop if bad template positions found.
    2/5/97, MWB, added FWHM and Mag safety shutoff in AUTO
    6/13/97, MWB, extracted keylist to external general routines.
    99/06/08, MWB, massive rewrite.  Now using external (and general)
                   calibration read/write/edit routines.  This caused
                   big changes in the internal structure and data organization
                   of this tool.  There are probably lingering bugs at
                   this stage due to the extensive nature of the edits.
    99/07/22, MWB, added WXVISIBLE and WYVISIBLE keyword pass through.
    99/11/15, MWB, fixed bug when starting up a calibration environment
                   when no filters or previous environment existed.

    2004/04/15, DWL, Major overhaul. Replaced old event-handling code with
                  individual event handlers. Eliminated intrinsic pointers
                  (NO_COPY on WIDGET_CONTROL) and replaced with explicit
                  pointers. Fixed stash location of the state structure.
                  Previously, it was stored in the first child, which is
                  necessary in a compound widget, but not in a stand-alone
                  widget application. Modified to use the new object-
                  oriented version of itool.

    2006/03/15, DWL, Fixed problem when switching between raw and processed
                  mode. Applied minor modifications to reflect changes to the
                  itool GUI. Those changes involved the single argument to
                  the itool GUI. Previously, it was a pointer to a structure.
                  Now, it is an object reference of the 'itoolimage' class.
                  This new class eliminates the need for the procedure
                  itool_init. Instead, initialization and cleanup are
                  handled by the init and cleanup methods defined for
                  the 'itoolimage' object class.

    2006/08/07, MWB, fixed bug in handling the CALIBPATH keyword.
    2007/01/17, MWB, fixed bug in auto increment hitting end of file list.
    2007/06/27, MWB, change header on output FITS to set BSCALE=1,BZERO=0
    2011/07/05, MWB, fixed bug that prevented saving calibration information
                       if it had been edited