# scan_sbe User Manual

## Table of Contents

1. USAGE
2. DESCRIPTION
3. OPTIONS
4. LEXICAL ANALYSER
5. EXAMPLES
6. OUTPUT FORMAT

# 1. USAGE

scan_sbe [options] <name1> <name2> ...

where <name> arguments must contain the path to SBE CTD header files and optionally the beginning of each file name.

# 2. DESCRIPTION

Parses all header files in specified directory and eventually beginning with the given name and generate for each of them a new standard header file. Parsing is carried out by a lexical scanner defined in file `scan_sbe.lex` which must be in the working directory. The new header files are generated in the working directory and have the same name as their sources. Hence, scan_sbe cannot be run in the directory where sources are located, or these would be overwritten. Field which may not be present in the source files can be inserted with a default value in the new header files.

# 3. OPTIONS

The following options are supported

-C SN
--conductivity-sensor=SN
Specify the serial number of the conductivity sensor.
-P SN
--pressure-sensor=SN
Specify the serial number of the pressure sensor.
-T SN
--temperature-sensor=SN
Specify the serial number of the temperature sensor.
-E
--east-longitude
-W
--west-longitude
-N
--north-latitude
-S
--south-latitude
Specify a default hemisphere for geographical positions.
-Z suffix
--header-suffix=suffix
Suffix of header files instead of default.
-a area
--area-name=area
Geographical area for data collection.
-c cruise
--cruise-name=cruise
Cruise name or identifier.
-s ship
--ship-name=ship
Name of ship.
-p project
--project-name=project
Name of project.
-y year
--year-base=year
Default year to use in dates.
-h
--help, --Help, --HELP
Display a help text and exit.
-v
--verbose, --Verbose, --VERBOSE
Display verbose information. This is usually helpful if some fields are not recognised and the lex file should be updated.

# 4. LEXICAL ANALYSER

Header fields and their elements are defined in the lex file `scan_sbe.lex`. This file specifies how each header line should be parsed. Once a header line as been parsed successfully, the next one is considered. Hence, the order in which definitions appear in the lex file is important.

Comments are allowed and begin with a # as the first non-blank character. The rest of the line is ignored. Each definition contains the regular expression that should match a specified header line, followed by a list of keywords defining the format for reading and extracting information from the line. Keywords must be enclosed between % not to confuse them with word in the header. Implemented keywords are

DLATI
Integer latitude degree.
DLATF
Decimal latitude degree.
MLATI
Integer latitude minute.
DLATF
Decimal latitude minute.
SLATI
Integer latitude second.
SLATF
Decimal latitude second.
HLATC
Character latitude hemisphere.
DLONI
Integer longitude degree.
DLONF
Decimal longitude degree.
MLONI
Integer longitude minute.
DLONF
Decimal longitude minute.
SLONI
Integer longitude second.
SLONF
Decimal longitude second.
HLONC
Character longitude hemisphere.
CSN
PSN
TSN
Serial number of conductivity, pressure and temperature sensors, respectively.
VERSION
Software version of processing software used.
IYEAR
IMONTH
IDAY
IHOUR
IMINUTE
ISECOND
Integer element of date and time.
CMONTH
Character month of measurements.
STATION
Station number.
BOTTOM
Ocean depth at station.
SHIP
CRUISE
AREA
PROJECT
Name of ship, cruise, area and project, respectively.

# 5. EXAMPLES

To read and extract the following header lines

      * Latitude = 64 N 25' 33"
      * Depth :    716m
      * Station Number = #4

the lex file should contain the following lines

      * Latitude = %DLATI% %HLATC% %MLATI%' %SLATI%"
      * Depth : %BOTTOM%m
      * Station Number = #%STATION%

Now, assuming some header files have the following syntax

      * LAT: 70 20.1
      * STA: 3
      * BTM: 234

the following definitions could be added to the lex file in order to extract information from both syntax in one single run.

      * LAT: %DLATI% %MLATF%
      * STA: %STATION%
      * BTM: %BOTTOM%

Note that for the latter case, scan_sbe must be called with option -N (or -S in order to specify a default hemisphere for latitudes.

# 6. OUTPUT FORMAT

The generated header file contains at least the same number of fields than its source file. Output format of some fields such as time and position are coded into the source code and cannot be changed without recompiling scan_sbe. This is intentional and helps keeping a standard syntax for header files.