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

  1.  NAME

  scan_nav - Scan NB ADCP navigation files

  2.  USAGE

  scan_nav control_file

  3.  DESCRIPTION

  This utility scans NB ADCP navigation files, and generates output
  files with log information, statistic on selected variables and a
  binary file with variables values, as well as a prepared navigation
  data file for each ping. See below for the syntax of the control file.

  The aim of running scan_nav is to control the integrity of the
  navigation files, and generate the binary file. The latter can be used
  later within Matlab with script scan_bin.m. In addition, if data were
  logged using TRANSECT, prepared navigation data for each ping are
  saved in a separate file for use during the averaging of ensembles
  with process.

  The log file contains debugging information about configuration GPS
  quality changes, as well as time with bad navigation. This can be used
  to edit and fix the navigation files if necessary.

  4.  PARAMETERS

  The control file must contain the following parameters:

     scan_nav_type: keyword
        Specify with a keyword the type of navigation files to process.
        This utility has been designed so that it can be extended for
        different type navigation files. Hence, the first parameter must
        determine the type in order to select the parameters and options
        associated to it. Currently implemented types are:

        TRANSECT
           This type is used to parse navigation files generated by
           TRANSECT. These contain all NMEA messages as they are output
           by the navigation device, with in addition TRANSECT lines
           corresponding to the time at which ADCP pings are saved on
           disk.

     first_day: YYYY/MM/DD
        Some NMEA messages do not contain the date. Hence, this
        parameter is required to synchronize time information with the
        correct day.

     file_list: file
        Name of a file containing the successive names of NB ADCP
        navigation files to scan. This file can contain C-syntax
        comments.

     out_file: file
        Root name for generated output files.
  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.

     data_stat_options:
        This option allows to select which statistics to calculate.
        Possible keywords are:

        time_between_ensemble

        time_between_nav_ping

        time_increment

        nav_travelled_distance

        nav_speed_from_pos

        nav_course_from_pos

        nav_heading

        nav_pitch

        nav_roll

        satellite_number

        satellite_hdop

        satellite_height

        nav_ship_course

        nav_ship_speed

        end
           This keyword is mandatory and terminates the list of selected
           statistics to perform.

        In addition, the keyword ALL will select all the keywords
        appearing in the above list. To deselect some specific parame-
        ters, prefix the undesired keyword with character ! (see
        scan_nbr(1) for an example using this feature).

        The values of nav_travelled_distance, nav_speed_from_pos and
        nav_course_from_pos can differ slightly from different
        architectures. Due to position errors and a high sampling rate
        of ADCP pings, the first of these parameters can be quite small.

     data_flag_options:
        Select which flag changes to report in the log file. Possible
        keywords are:

        gps

        dgps

        end
           This keyword is mandatory and terminates the list of selected
           flags to check.

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

     nav_messages:
        Select which navigation messages to parse. Possible keywords
        are:

        GGA

        GLL

        HDT

        PRDID

        RMC

        TRANSECT

        VTG

        ZDA

        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 parame-
        ters, 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.

     scan_nav_file: file
        This option is provided for the case several scans through
        navigation files is required. Parameter file can refer to a
        previous scan (out file) in order to synchronize data. This
        option was implemented for a situation where ship's attitude
        were saved in a separate file at a high sampling rate and needed
        to be synchronized to the ping times.  Currently, it is
        obsolete.

     skip_nav_lines:
        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.

     ascii_log
        If this option is specified, data saved in the binary file will
        be saved in addition in ASCII format into the log file. This
        allows a quick overview over some of the data found in the raw
        files and can also be used as a debugging information. However,
        generated files can be very large.

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

  6.  TIME RANGES

  To allow a finer tuning of which pings to scan, the control file must
  be terminated by a list of time ranges.  See time_rng(5) for the
  syntax of these.

  7.  OUTPUT FILES

  The following files are generated:

  file.log - log file

  file.sta - statistics

  file.bin - binary data

  file.out - pre-processed output navigation data

  where file correspond to the value of parameter out_file.

  8.  AUTHOR

  Pierre Jaccard, Geophysical Institute, University of Bergen, 1999



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