How do I transform a coordinate system manually?

Introduction to coordinate systems

Raw velocity measurements are given in beam coordinates, which is a vector in the direction along each of the beams. Depending on the objective of the measurements, coordinate transformation may be beneficial. Beam coordinates can be converted to a Cartesian coordinate system (XYZ) or earth normal coordinates (ENU: East, North and Up). The orientation of the beams/transducers, which is defined in the instrument specific transformation matrix, is used to convert from beam coordinates to XYZ. By additionally knowing the orientation in space, such as tilt and compass heading, ENU coordinates can be determined.

During transformation to ENU only the slanted beams are used in the transformation. The data represented in ENU originates only from these beams, and the center beam (if collecting current data) is given individually and always in beam coordinates.

If the instrument is configured to measure data in XYZ or ENU, this coordinate transformation is automatically performed by the firmware and the output data will be in the selected coordinate system. The transformation can also be done in post-processing software or manually, if desired. How the manual transformation from BEAM coordinates through XYZ to ENU is done is described below.

FAQ-coord2.png

Figure 1: The three relevant coordinate systems. The figure shows an AWAC, but this applies to the other instruments as well.

 

 

Necessary data files

1. Raw data

The starting point is a binary-to-ASCII conversion of the raw data file so that you have access to the three velocity files,*.v1, *.v2 and *.v3, the transformation matrix in the *.hdr file, and the *.sen file. Heading, pitch and roll are presented in the *.sen file (ref. the *.hdr file), and these angles are output in degrees. The velocity data in .*.v1, *.v2 and *.v3 are measured in of the the 3 coordinate systems described above - Beam, XYZ or ENU. The coordinate system selected during the deployment planning is indicated in the *.hdr file.

 

2. Transformation matrix T

Each instrument has its own unique transformation matrix T, based on the transducer geometry. It is used to transform raw data collected in BEAM coordinates to XYZ coordinates. It  can be found in the *.hdr file generated when performing a binary data conversion in the software. Each row of the matrix represents a component in the instrument’s XYZ coordinate system, starting with X at the top row. Each column represents a beam. 

(Some instruments, particularly if older then 2009, report the matrix in unscaled integer values (i.e. have a value of several thousand). In this case, T will have to be divided by 4096 to use for coordinate transformation. )

 

Beam -> XYZ

The transformation between beam and XYZ coordinates is done using the original T matrix. In matrix form (using MATLAB notation, so [ X; Y; Z ] is a column vector), the math is:

\begin{equation}
T \times [B1;B2;B3;] = [X;Y;Z]
\end{equation}
(1)

And to convert from XYZ to Beam:

\begin{equation}
T^{-1} \times [X;Y;Z;] = [B1;B2;B3;]
\end{equation}
(2)

 

Beam / XYZ -> ENU

When transforming to ENU, the transformation matrix T needs to be adjusted depending on the orientation of the instrument. If instrument is pointing down (bit 0 in status equal to 1) rows 2 and 3 must change sign! You can check the orientation of the instrument in the*.sen file (status bit, bit 0; 0 = up-looking, 1 = down-looking).

Next the recorded heading, pitch and roll needs to be taken into account. These are used to create a second matrix R that corrects for the instruments position on earth. Whereas the first matrix is constant throughout the deployment, this one needs to be recalculated for each timestep.

Equation (3) and (4) illustrate how to obtain a matrix for heading, pitch and roll.

\begin{equation} hdg = hdg - 90 \end{equation}

\begin{equation}R_z = \begin{bmatrix}
\cos(hdg) & - \sin(hdg) & 0 \\
\sin(hdg) & \cos(hdg) & 0 \\
0 & 0 & 1
\end{bmatrix}
\end{equation}

(3)

NB (equation 3): It is necessary to subtract 90° from the recorded heading to account for the instruments x-orientation (Heading of 0° = x pointing North in raw data)

\begin{equation}
R_y = \begin{bmatrix}
\cos(\text{pch}) & 0 & \sin(\text{pch}) \\
0 & 1 & 0 \\
- \sin(\text{pch}) & 0 & \cos(\text{pch})
\end{bmatrix}
\end{equation}
(4)

 

\begin{equation}
R_x = \begin{bmatrix}
1 & 0 & 0 \\
0 & \cos(\text{rll}) &- \sin(\text{rll}) \\
0& \sin(\text{rll}) & \cos(\text{rll})
\end{bmatrix}
\end{equation}
(5)

 

\begin{equation}
R = R_Z \times R_Y\times R_X 
\end{equation}
(6)
  1. Find the instrument specific transformation matrix T.
  2. Make a new transformation matrix (R), including heading, pitch and roll. 
  3. The coordinate system transformations can then be carried out using R and T as shown in (7).
  4. When using the inverse of  RT the transformation can carried out in the opposite direction.

\begin{equation} [ E; N; U ] = R \times T \times[ B1; B2; B3 ] \end{equation}

\begin{equation} [ B1; B2; B3 ] = T^{-1} \times  R^{-1}  \times[ E; N; U ] \end{equation}

\begin{equation} [ E; N; U ] = R  \times [ X; Y; Z ] \end{equation}

\begin{equation} [ X; Y; Z ] =  R^{-1} \times [ E; N; U ] \end{equation}

(7)

 

Attached below this page are Python and Matlab scripts that can be used to carry out the above described transformations for a 3-beam system.

Updated