.if n .ds Q \&"
.if t .ds Q ``
.if n .ds U \&"
.if t .ds U ''
.TH con2con 1 "CODAS Utilities" "GFI"
.tr \&
.nr bi 0
.nr ll 0
.nr el 0
.de DS
..
.de DE
..
.de Pp
.ie \\n(ll>0 \{\
.ie \\n(bi=1 \{\
.nr bi 0
.if \\n(t\\n(ll=0 \{.IP \\(bu\}
.if \\n(t\\n(ll=1 \{.IP \\n+(e\\n(el.\}
.\}
.el .sp
.\}
.el \{\
.ie \\nh=1 \{\
.LP
.nr h 0
.\}
.el .PP
.\}
..
.SH NAME

.Pp
\fBcon2con\fP - Convert the format of contour files

.SH USAGE

.Pp
\fBcon2con\fP [options] [file file ... ]

.SH DESCRIPTION

.Pp
This utility converts contour files into more generalized contour
files and vice versa. Contour files have usually the same format as
those created by the \fBcontour\fP product with \fBadcpsect\fP
or \fBxtract\fP(1). They have typically the following columns:

.nr ll +1
.nr el +1
.nr t\n(ll 1
.nr e\n(el 0 1
.af e\n(el \*(f\n(el
.if \n(ll>1 .RS
.nr bi 1
.Pp
Data for X axis
.nr bi 1
.Pp
Data for Y axis
.nr bi 1
.Pp
Data for Z axis
.if \n(ll>1 .RE
.nr el -1
.nr ll -1


.Pp
where data for the different Y grid points at the same X location
appear successively. If the file has been created with
\fBxtract\fP(1), more than one column of data for the Z axis can
be present. A more generalized contour file will contain additional
X position information. This is used for example with
\fBcon2db\fP(1), where both \fBTIME\fP and \fBPOSITION\fP
are required to locate a profile. In this case, the file has the
following columns:

.nr ll +1
.nr el +1
.nr t\n(ll 1
.nr e\n(el 0 1
.af e\n(el \*(f\n(el
.if \n(ll>1 .RS
.nr bi 1
.Pp
Time
.nr bi 1
.Pp
Longitude
.nr bi 1
.Pp
Latitude
.nr bi 1
.Pp
Bin depth
.nr bi 1
.Pp
Bin data
.if \n(ll>1 .RE
.nr el -1
.nr ll -1


.Pp
where several columns with different bin data can appear. This
utility can be used to transform files from one format to the other.
.Pp
In order to generate a more generalized contour file, one has to
specify a position file with the \fB-f\fP option. If this option
is not specified, a transformation to a usual contour file is
assumed. In the former case, data from both both input files have to
synchronized. This is done by specifying which columns contain data
of the same variable in both files. Values from the position file
are interpolated to those in the contour file, so that grid points
do not need to match. This allows to use a contour file from
\fBadcpsect\fP together with the output from \fBgetnav\fP.
.Pp
If no contour files are specified on the command line, standard
input is assumed. Output is directed by default to standard output,
unless an output file is specified with option \fB-o\fP. Input
data must be separated by white spaces. Output data are written with
format \fB%15.6f\fP and separated by a space. This utility
can handle bad data which are defined with value \fB1.0E38\fP.
.Pp
Although this utility was created to manipulate files with contour
data, it is supplied with many options and can in fact be used to
perform other operations on file, such as filter out columns,
changing the order of columns or inserting columns from another
file.

.SH OPTIONS

.Pp
The following options are implemented:

.nr ll +1
.nr t\n(ll 2
.if \n(ll>1 .RS
.IP "\fB-c\fP \fIcolumn_list\fP"
.nr bi 1
.Pp
List of columns to read from the file specified with option
\fB-f\fP. Data from these columns will be inserted in the
same order as they appear in the list. See \fBcolumns\fP(5)
for information on how to specify these columns. The default is
\fB2,3\fP which corresponds to files generated by
\fBgetnav\fP.

.IP "\fB-f\fP \fIfile\fP"
.nr bi 1
.Pp
Specify the file containing additional position data. No
default is supplied for this option. If not specified, a
conversion to a usual and more simpler contour format will be
carried out.

.IP "\fB-i\fP \fIn\fP"
.nr bi 1
.Pp
Specify where in the input contour file data from the external
file should be inserted. The value of \fIn\fP must
correspond to a column number. All specified columns with option
\fB-c\fP will be inserted, starting from this column number.
Column numbering starts from one. Default is 2.

.IP "\fB-o\fP \fIfile\fP"
.nr bi 1
.Pp
Specify the file for new contour data. If not specified,
standard output is assumed.

.IP "\fB-x\fP \fIn\fP"
.nr bi 1
.Pp
Specify the column for synchronization of data. This the number
of the column in the external file that contains data which
appears also in the input contour file (see option \fB-X\fP).
Column numbering starts from one. Default is \fB1\fP.

.IP "\fB-C\fP \fIcolumn_list\fP"
.nr bi 1
.Pp
List of columns to read from the input control file.
Data from these columns will be written in the
same order as they appear in the list. See \fBcolumns\fP(5)
for information on how to specify these columns. If a more
generalized contour file is to be created, the default is
\fB1,2,3\fP. This allows to have input files with the
following columns:

.nr ll +1
.nr el +1
.nr t\n(ll 1
.nr e\n(el 0 1
.af e\n(el \*(f\n(el
.if \n(ll>1 .RS
.nr bi 1
.Pp
Time in decimal days
.nr bi 1
.Pp
Bin depth
.nr bi 1
.Pp
Bin data
.if \n(ll>1 .RE
.nr el -1
.nr ll -1

If conversion to the usual contour format is required, the
default is \fB1,4,5\fP, which can be used for a file
containing the following columns:

.nr ll +1
.nr el +1
.nr t\n(ll 1
.nr e\n(el 0 1
.af e\n(el \*(f\n(el
.if \n(ll>1 .RS
.nr bi 1
.Pp
Time in decimal days
.nr bi 1
.Pp
Longitude in decimal degrees
.nr bi 1
.Pp
Latitude in decimal degrees
.nr bi 1
.Pp
Bin depth
.nr bi 1
.Pp
Bin data
.if \n(ll>1 .RE
.nr el -1
.nr ll -1


.IP "\fB-X\fP \fIn\fP"
.nr bi 1
.Pp
Specify the column for synchronization of data. This the number
of the column in the input contour file that contains data which
appears also in the external file (see option \fB-x\fP).
Column numbering starts from one. Default is \fB1\fP

.if \n(ll>1 .RE
.nr ll -1


.SH DEFAULT OPTIONS

.Pp
If an external position file is specified, the default options
allow a conversion to a more generalized contour format, where

.nr ll +1
.nr t\n(ll 0
.if \n(ll>1 .RS
.nr bi 1
.Pp
The input contour file has the following columns:

.nr ll +1
.nr el +1
.nr t\n(ll 1
.nr e\n(el 0 1
.af e\n(el \*(f\n(el
.if \n(ll>1 .RS
.nr bi 1
.Pp
Time
.nr bi 1
.Pp
Bin depth
.nr bi 1
.Pp
Bin data
.if \n(ll>1 .RE
.nr el -1
.nr ll -1

Such a file can be generated with \fBxtract\fP(1).

.nr bi 1
.Pp
The external file with additional position information
correspond to the output of \fBgetnav\fP.

.nr bi 1
.Pp
The output file has values of longitude and latitude inserted
between time and bin depth data.

.nr bi 1
.Pp
Synchronization and interpolation of data is carried out on time
data.

.if \n(ll>1 .RE
.nr ll -1


.SH OUTPUT FILES

.Pp
The file specified by the \fB-o\fP option.

.SH EXAMPLES

.Pp
Assuming \fIgetnav.nav\fP is the file generated by
\fBgetnav\fP and \fIadcpsect.con\fP is the file generated by
\fBadcpsect\fP, with the \fBlongitude\fP as the x-axis for
contours (found in the first column) and both \fBU\fP and \fBV\fP as
bin data (found in the third and fourth columns, the second column
containing bin depths). Then,

.DS
.sp
.ft RR
.nf
con2con -f getnav.nav \\
-c '1,3' -x 2 -i 2    \\
-C '1,2,3,4' -X 1 adcpsect.con

.DE
.fi
.ec
.ft P
.sp
.Pp
will generate a more generalized contour file, inserting values of
\fBtime\fP and \fBlatitude\fP (option \fB-c\fP) in the second aand
third columns (option \fB-i\fP). All input columns from the contour
file are kept (option \fB-C\fP). Synchronization of both files and
interpolation of data from \fIgetnav.nav\fP on the grid defined in
\fIadcpsect.con\fP is carried out along longitude (options \fB-x\fP
and \fB-X\fP.
.Pp
In the example above, output is written to standard output. Piping
it into a second call to \fBcon2con\fP, such as

.DS
.sp
.ft RR
.nf
con2con -C '2,1,3-6' -o output.con

.DE
.fi
.ec
.ft P
.sp
.Pp
will generate file \fIoutput.con\fP with columns containing
\fBlongitude\fP and \fBtime\fP data swapped.

.SH SEE ALSO

.Pp
\fBadcpsect\fP,
\fBcolumns\fP(5),
\fBcon2db\fP(1),
\fBxtract\fP(1),

.SH NOTES

.Pp
This is a Perl script, and could probably be more faster and handle
numbers in a better way if coded in C.

.SH AUTHOR

.Pp
Pierre Jaccard, Geophysical Institute, University of Bergen, 1999
