Codes

Transformation

Retrieve transformation matrix to transform beam signals into velocities with Cartesian coordinates

transformation.apply_transformation(df, transformation_matrix, relevant_point_ids=(0, 1, 2))

Apply a transformation matrix to a pandas DataFrame containing Vectrino II ASCII data.

Parameters:
  • df (pd.DataFrame) – This DataFrame must have the following column headers with lists of floats: Velocity Beam 1 (m/s), Velocity Beam 2 (m/s), Velocity Beam 3 (m/s), Velocity Beam 4 (m/s); The DataFrame can be created with get_ascii_data.read_ascii_file(file_name).

  • transformation_matrix (np.array(4x4)) – Provide the transformation matrix calculated with the get_transformation_matrix(file_name) function.

  • relevant_point_ids (tuple) – Specify a tuple of relevant point IDs from each measurement time step. The default is (0,1,2) and forces the function to use point IDs 0, 1, and 2. Note that counting starts at 0 and using more IDs or IDs beyond the number of measured points will cause an error that will stop the script.

Return pd.DataFrame:

Returns the input DataFrame with 3d u, v, and w flow velocity components appended.

transformation.get_transformation_matrix(ntk_file_name, scaling_factor=4096)

Read the transformation matrix as numpy array from the

Parameters:
  • ntk_file_name (str) – Path and name of a Vectrino II ntk file. For example ‘data/VectrinoProfiler.00001’ when the header file is ‘VectrinoProfiler.00001.ntk.hdr’ (see ‘sample-data/’ directory).

  • scaling_factor (int) – This number can be found in the hdr file on line 186 (or so) and is typically device specific.

Return np.array M:

The transformation matrix.

Get ASCII data

Read flow velocity data from Nortek Vectrino II output (.ntk) files

get_ascii_data.read_ascii_file(file_name)
Read the contents of a Vectrino II ASCII .dat file. Currently, only the velocity beams 1 to 4 and their SNR is

parsed. Other parameters like Correlation can be easily added.

Parameters:

file_name (str) – Path and name of the NTK ASCII files. For example use ‘sample-data/VectrinoProfiler.00001’ to read ‘VectrinoProfiler.00001.ntk.dat’ in the sample-data sub-folder.

Return pd.DataFrame:

DataFrame containing the beam velocities and SNR of the four beams

Prostprocessing Head (Example)

This is a code template for loading and analyzing multiple files stored in a directory within the code repository.

To run this, make sure that the folder contains .ntk.dat and .ntk.hdr files, defining a complete Vectrino ASCII output dataset.

The code implements the following workflow: * Check for coherent file patterns in the defined data_directory * For each pair of .ntk.dat and .ntk.hdr files:

  1. Retrieve the data contents from .ntk.dat

  2. Get the transformation matrix from .ntk.hdr

  3. Transform the beam velocities to Cartesian coordinate-based velocities

  4. Store the resulting pandas.DataFrame in the data_directory as .CSV file with the same name as the ASCII files