Technical Articles

Analyzing and Visualizing Flows in Rivers and Lakes with MATLAB

By Paul Fricker, MathWorks

Hydrologists and other scientists use acoustic Doppler current profilers (ADCPs) to measure the volume rate of water flow, or discharge, in rivers and other waterways. Discharge measurements are used to predict flooding and low-water conditions. While such measurements are valuable, the data provided by ADCPs can also be used to create a much more detailed picture of the water velocity distribution in a river.

The Velocity Mapping Toolbox (VMT), built in MATLAB®, enables the U.S. Geological Survey (USGS) to rapidly process all the raw data recorded by ADCPs. The result is a better understanding of spatial flow distributions and temporal flow variations, making VMT a valuable tool for a variety of applications. Environmental scientists use it to examine flow distributions around structures near wildlife habitats. Energy companies use it to identify the best position for tidal turbines.

The USGS has used VMT on a variety of projects and studies. For example, they used it to help the U.S. Army Corps of Engineers assess flow distributions at the confluence of the Mississippi and Ohio Rivers so that barges could safely navigate the swollen rivers during the record flooding of 2011. USGS scientists use VMT to study meander bends in rivers and determine where shoreline protection might be needed to prevent erosion, visualize flow in nearshore and rivermouth regions of the Great Lakes to understand contaminant transport and aid beach health studies, and study the capability of Great Lakes tributaries for transport of Asian carp eggs to identify suitable spawning habitats for the invasive species.

VMT and ADCPs have increased the pace of studies that rely on flow data. Before the introduction of the ADCP, researchers used acoustic Doppler velocimeters or mechanical current meters, which sampled one point in the water column instead of the entire water column essentially simultaneously. Teams could spend days taking the flow measurements and months processing the data with spreadsheets. Today, VMT can complete the same analysis within minutes.

Gathering Data

Flow data is collected by transecting the river, the stream, or the lake in a boat equipped with an ADCP (Figure 1).

An ADCP in use in the field. (Photograph courtesy Paul Baker, USGS)
Figure 1. An ADCP in use in the field. (Photograph courtesy Paul Baker, USGS)

The ADCP transmits sound pulses into the water and processes echoes reflected back from particles moving in the fluid flow (Figure 2).

Figure 2. Diagram of a vessel making ADCP measurements as it transects a river.

By determining the Doppler frequency shift of emitted pulses returning to the ADCP, the velocity of the particles can be computed using a priori knowledge of the transducer geometry and trigonometric relationships. As the boat moves, the ADCP records its position using a GPS. Using pulse frequency measurements together with pitch, roll, heading, and positional data, the instrument calculates and records vectors of 3D velocity data for the water column below the instrument. Additionally, the ADCP records depth soundings, the water surface temperature, and acoustic backscatter (the amount of sound reflected by the particles in the water column). With proper calibration, acoustic backscatter can indicate the amount of sediment suspended in the water.

Data collection is an iterative process, with a vertical velocity profile being measured at least once per second, resulting in huge amounts of data. To obtain an accurate measurement of the flow across a body of water, USGS researchers complete multiple transects of the river, each consisting of hundreds to thousands of vertical samples. A vertical sample is represented by a set of vectors that may contain dozens of individual 3D velocity measurements. It is not unusual for a data set for a single large river cross section to contain more than 100,000 data points, and a complete study might require 10 to 30 cross sections.

Developing the Velocity Mapping Toolbox

VMT evolved from MATLAB code developed for past research projects. To allow researchers to process and visualize their own ADCP data, the code behind VMT was modified for general-purpose use. Modifications to the application included adding new features and enhanced functionality for data analysis and visualization. Novel algorithms for aggregating the results from multiple transects were developed using the robust built-in interpolation techniques in MATLAB. By employing Mapping Toolbox™ functionality, VMT is able to produce presentation-quality georeferenced visualizations of measured flow fields—a feature that enables researchers to set their analyses within the context of the physical surroundings where measurements are made.

The evolution of VMT included adding more visualization tools for ADCP data. For example, researchers can compare flow velocity data at different depths and strata, map primary and secondary circulation patterns, and plot depth-averaged velocities on aerial maps (Figure 3).

Diagram of a vessel making ADCP measurements as it transects a river
Figure 3. Depth-averaged velocities plotted using VMT on an aerial view of the confluence of the Wabash and Embarras Rivers (Illinois) with ADCP-derived bathymetry.

The development of a graphical interface for VMT makes it easy for researchers to import data from ASCII files or MAT-files generated by ADCPs (Figure 4). Researchers can use this interface to load and process data files, create easy-to-understand 2D and 3D MATLAB plots of velocity data (Figure 5), export processed data and figures for further analysis and visualization, or access VMT-related data processing utilities that make data available to other programs such as Geographic Information Systems (GIS) and Google Earth®. With MATLAB Compiler™, VMT’s developers created a standalone executable version of the application that researchers can use without installing MATLAB.

Figure 4. The VMT graphical interface.
Figure 5. MATLAB plot of primary (streamwise) and secondary (transverse) velocities in section 4 of Figure 3, generated with VMT.

Revolutionizing Velocity Mapping

In addition to VMT, USGS researchers use MATLAB to develop tools for analyzing time-series flow data, and tools that can be used to calibrate acoustic backscatter from an ADCP or similar Doppler-based instruments for continuous suspended sediment monitoring at existing USGS streamgages. The USGS has even supplied MATLAB code to ADCP manufacturers to help them improve their algorithms for calculating overall discharge. These tools, together with the VMT, are helping to change research and data analysis procedures for surface water hydrologists  worldwide.

The speed at which researchers analyze data with VMT has led to significant changes in the way studies are conducted. Today, researchers can run VMT on a laptop in the field and process ADCP data immediately in near real time. The results are used to guide further data collection in the area, if necessary. This approach was simply not possible in the past because the flow analysis could take months to complete and produced lower-resolution results.

Enabling Open Development

VMT is not merely a prototype, but a production application with an interface that makes it easy to use, even for scientists and researchers with no MATLAB experience. A key advantage of developing the application using MATLAB was that USGS scientists could apply their expertise as hydrologists to creating production software themselves, without relying on programmers. Throughout the development of the toolbox, VMT developers incorporated many ideas and scripts from the community of scientific MATLAB users.

The VMT developers from the USGS recently engaged MathWorks consultants to help improve the efficiency and performance of the MATLAB code and to enhance the interface layout. As part of this effort, the VMT code became more modular and that helped other users to improve and enhance it as part of an open-source development effort. The source code is available for download on Google Code.

About the Primary USGS VMT Developers

Dr. P. Ryan Jackson is a hydrologist and Dr. Frank L. Engel is a geographer at the U.S. Geological Survey. Both hold Ph.D.s from the University of Illinois at Urbana-Champaign, Dr. Jackson in civil engineering, and Dr. Engel in geography. Dr. Jackson specializes in environmental fluid mechanics and pairs an ADCP with water-quality instrumentation to study transport and mixing problems in rivers and lakes throughout the country. Dr. Engel specializes in fluvial geomorphology and studies of the interaction between flow evolution and sediment transport in meandering streams and rivers.

About the Author

Paul Fricker has more than 15 years’ experience in signal and image processing, modeling and simulation, and application development. He holds a B.Sc. in Chemistry from Dalhousie University, an M.Sc. in Physics from the University of Toronto, and a Ph.D. in Civil Engineering from Massachusetts Institute of Technology.

Published 2014 - 92205v00

View Articles for Related Industries