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

To carry out a coordinate transformation, it is first necessary to convert the raw *.aqd file to *.mat or *.csv using the File Conversion tool Nortek Deployment. Within this file the three velocity components can be found in the coordinate system selected during the deployment. Additionally one is able to retrieve the heading, pitch and roll time series as well as the transformation matrix. 

 

2. Transformation matrix T

The unique transformation matrix T, which is used to transform collected velocities from the BEAM to XYZ coordinate system can be acquired in multiple ways from a Gen2 Aquadopp:

  • If you have converted your raw data, then the transformation matrix can be found under Config.Average_Beam2xyz / Config.Burst_Beam2xyz in the *.mat
  • Alternatively, you can open a raw file and navigate to the line that starts with GETFXBURST / GETFXAVG . The individual values represent the elements of the 3x3 matrix as shown in (1). These are commands that can equally be send to the instrument using the terminal which will return the same information.
\begin{equation}
M_{3beam} = \begin{bmatrix}
M_{11} & M_{12} & M_{13}\\
M_{21} & M_{22} & M_{23}\\
M_{31} & M_{32} & M_{33} \\ \end{bmatrix}
\end{equation}
(1)
    

💡 NOTE: For an Aquadopp profiler equipped with a Z-cell, a separate transformation needs to be carried out for the velocities recorded in the first cell vs. the rest of the profile. The unique transformation matrix for the Z-cell can be fund under: GETXFAVGZCELL )

 

Beam -> XYZ

Each instrument has its own unique transformation matrix T, based on the transducer geometry. 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. 

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}
(2)
    

And to convert from XYZ to Beam:

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

 

Beam / XYZ -> ENU

To convert to ENU, 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) - (6) illustrate how to obtain a matrix from the raw heading, pitch and roll parameters.

\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}
(3)
\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} 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}

(5)

💡 NOTE: 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 = R_Z \times R_Y\times R_X 
\end{equation}
(6)
    

 💡 NOTE: The instruments orientation needs to be taken into account for each deployment, when transforming to ENU coordinates. If the instrument is pointing down, rows 2 and 3 of the matrix must change sign! The default orientation is upward looking!

 

In summary the total coordinate system transformation from BEAM to ENU coordinates can then be carried out using the following steps:

  1. Find the instrument specific transformation matrix T.
  2. Make a pitch & roll matrix.
  3. Make a heading matrix. 
  4. Make a new transformation matrix (R), including heading, pitch and roll. 
  5. The coordinate system transformations can then be carried out using R and T as shown in (4) - (6).
  6. 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}(8)
\begin{equation} [ B1; B2; B3 ] = T^{-1} \times  R^{-1}  \times[ E; N; U ] \end{equation}(9)
\begin{equation} [ E; N; U ] = R  \times [ X; Y; Z ] \end{equation}(10)
\begin{equation} [ X; Y; Z ] =  R^{-1} \times [ E; N; U ] \end{equation}(11)

Attached below this page are Python and Matlab scripts that can be used to carry out the above described transformations for raw Aquadopp data.

 

Updated