/*----------------------------------------------------------------------

  1.  NAME

  nav_hdg - Generates heading correction from navigation files

  2.  USAGE

  nav_hdg control_file

  3.  DESCRIPTION

  This utility scans the NMEA navigation files and an ADCP CODAS
  database to generate an ASCII output file with the following columns:

  1. ADCP profile time in decimal days

  2. Database heading - Navigation mean heading

  3. Database heading

  4. Navigation mean heading

  5. Standard deviation of navigation heading

  6. Number of points used to calculate the navigation heading

  This file is for input in parameter ANGLE_FILE for the rotate utility
  which corrects heading values stored in a CODAS database. This utility
  was written for a dataset collected during a cruise where GPS heading
  from a Seapath 200 (HDT string) was logged at a high sampling rate
  separately together with all other navigation NMEA messages, while
  heading logged together with ADCP data was from a gyro compass.

  4.  PARAMETERS

  The control file must define the following parameters:

     dbname: name
        Name of database (with path) containing heading data to be
        corrected.

     nav_list: file
        Name of file (with path) containing list of all navigation files
        to parse sequentially for heading data. Comments following the
        C-syntax are allowed in this file.

     out_file: file
        Name of output file, with path.

     first_time YYYY/MM/DD hh:mm:ss
        This parameter is required because some NMEA messages containing
        time information, such as the GGA message, do not provide the
        full date. The given year is taken as the year base for
        conversion of time into decimal days. Furthermore, it is assumed
        that database profile times are given for the end of profiles.
        Hence, full first time information is required to perform
        heading statistics for the first ensemble.  as

     db_hdg_from: keyword
        " Heading information can be stored in different variables
        within a CODAS database. This parameter specifies which variable
        to read for heading corrections. The following keywords are
        implemented:

        mean_heading
           Read heading data from element mn_heading in the ANCILLARY_1
           structure.

        last_heading
           Read heading data from element last_heading in the
           ANCILLARY_2 structure.

  5.  OPTIONS

  In addition to the parameters listed above, the following options are
  available:

     OPTIONS:
        This key word can be used to improve the clarity of the control
        file and specify the beginning of options. It has no effect.

     nav_messages:
        Select which navigation messages to parse. One should mention at
        least one message containing time and another one with heading
        information. All other messages are not necessary.  Unselected
        messages will be considered as bad navigation lines.  Possible
        keywords are:

        TRANSECT

        ZDA

        GGA

        HDT

        PRDID

        VTG

        end
           This keyword is mandatory and closes the selected list of
           NMEA messages to parse.

        In addition, the keyword ALL will select all the keywords
        appearing in the above list. To deselect some specific
        parameters, prefix the undesired keyword with character !.

        WARNING:

          Avoid specifying more than one message containing time
          information, because these do sometime differ slightly.
          In the case of ZDA and GGA messages, if the latter has a
          slightly earlier time, the whole date will be set to the
          next day.

     skip_nav_lines: n
        Number of navigation lines to skip when a bad input navigation
        line is encountered. This is mainly for situations where the
        navigation device hangs up and needs a reset: time and position
        information is usually wrong during a couple of seconds
        (typically 30 to 60 seconds). Hence, the number of line to skip
        in such a situation will depend on the navigation sampling
        frequency.

     end
        This keyword is mandatory and terminates the list of selected
        options.

  6.  TIME RANGES

  Finally, the control file is terminated by a list of time ranges.  See
  time_rng(5) for the syntax of these.

  7.  OUTPUT FILES

  The file specified in parameter out_file.

  8.  AUTHOR

  Pierre Jaccard, Geophysical Institute, University of Bergen, 1999



----------------------------------------------------------------------*/