DominikPatrickNommensen / MB-System-Best-WOA18-SVP

MB-System tool to find the best World Ocean Atlas 2018 sound velocity profiles for sound speed correction.
1 stars 0 forks source link

MB-System-Best-WOA18-SVP

MB-System tool to download World Ocean Atlas 2018 (WOA18) temperature and salinity files, calculate the sound velocity using the UNESCO formula with corrective terms as well as the recalculated coefficients by Wong and Zhu and the Leroy formula over all standard depths, applying them on a flat seafloor swathfile and find the best World Ocean Atlas 2018 sound velocity profiles for sound speed correction of a survey.

General idea

Sound velocity profiles (SVP) are important for sound speed correction, however sometimes conditions at sea and time constraints lead to insufficient or no SVPS at all. The idea of this tool is to somewhat compensate for that by utilizing the World Ocean Atlas 2018 temperature and salinity data that are based on real in-situ measurements interpolated over several decades for different times, spatial resolutions and standard depths. Under the assumption of a rather flat seafloor, the detected depths of the beams of a multibeam ping should lay on a straight line if the applied SVP is a good/perfect one. If not, the calculated bathymetry will bend either upwards or downwards, especially on the outer beams as shown in the two images below.

residuals

In order to evaluate the accuracy of SVPs and to compare them against one another the residuals of the individual pings per beam can be calculated. These residuals are the difference between a linear fit of a ping and the actual value for all the beams within that ping. In order to objectively analyze the flattening of the averaged residuals some metrics like the mean error (ME), the mean absolute error (MAE) and the root mean square error (RMSE) were used. All three of the metrics give information on the error between an actual value and a predicted value. The averaged residuals calculated from each SVP applied are the actual values and a value of 0 for each beam number represents the predicted value. Continuous residual values of 0 over all beams of the swath represent a perfectly linear and ideal ping. The closer the calculated residuals are to this perfect line the better they smooth the calculated bathymetry during ray tracing, resulting in better bathymetry maps under the assumption of a flat seafloor.

linear_regression

This tool applies a number of WOA18-derived and additional (if present) SVPs that fit the temporal and spatial parameters of the provided swathfile over a flat area and returns a ranking of these. Since there are more than one equation to for sound velocity calculation two formulas are currently supported and treated as individual profiles leading up to 26 WOA18 SVPs per swathfile. This flat seafloor (part of a larger survey) evaluated SVP could than be used to correct the whole survey and improve bathymetry maps.

Programs of this tool

Program Description
mbdownloadwoa18 Extracts WOA18 temperature and salinity for a specified area, calculates the UNESCO and Leroy sound velocites for each grid cell and standard depth and stores them as netcdf files together with an overview map of the specified area extracted.
mbbestsvp Calculates/extracts several SVP files based on the date and extent of a swathfile (flat seafloor), by either using the mean of 4 surrounding profiles or by using the closest grid point. All SVPs are applied and their capability of flattening the seafloor is evaluated and ranked against one another, including the SVPs stored in the swathfile itself.

mbdownloadwoa18 (mbdownloadwoa23 should work the same way; periods not updated yet)

The mbdownloadwoa18 can be used directly from the command line and takes the following arguments:

The user will end up with a set of netcdf files corersponding to the specified parameters mentioned above and an image showing the map extent. These files are required for the evaluation of the best SVP when using mbbestsvp (see below).

mbbestsvp

The mbbestsvp can be used directly from the command line and takes the following arguments:

The user will end up with a subfolder containing all the SVP profiles for the swathfile from the WOA18, a subfolder (svppngs) with images illustrating the flattening effect together with some metrics and a ranking of all files based on the root mean squared error (RMSE) in the terminal where the lowest RMSE represents the 'best' SVP.

Example (Black Sea)

This seciton should serve as a quick example of how to use this tool and the two programs in general:

  1. Following your MB-System workflow including flagging of outlier etc.
  2. Decide which area from the WOA18 you are interested in. In this example below we are only interested in the finer grid resolution, an area around the Black Sea, we use the Black Sea corrective term and store it in the output folder named test. Since we omitted the time and period flags we will get all times and both periods. We end up with our specified and cropped sound velocity netcdf files as well as an image showing our specified area that we are interested in.
python mbdownloadwoa18.py -O F:\test -R 04 -A 27 43 40 49 -C BLACK

Cropped area

  1. If that ran through we can get our sound velocity profiles, apply them and obtain the best SVP. In the code example below we provide the svpfolder where we just stored out netcdf sound velocity files from step 2, an optional profiles folder called myprofiles and our flat seafloor swathfile.
python mbbestsvp.py -S F:\test -O ./myprofiles -I swathfile.mb59 
  1. Afterward, if the program finished we end up with a ranking of all the SVPs and the best one (based on the RMSE) is automatically applied onto the swathfile. We could now use that SVP on a whole survey consisting of several swathfiles and see if it improves our overall map.

An example of the flattening done by the best SVP for this example is given below.

best_svp

To illustrate potential improvements of this best SVP over the SVP that came with the swathfile the residuals of that 'internal' SVP are also shown below. A slight improvement can be seen.

worst_svp

Requirements

MB-System

Since this tool utilizes MB-System and is meant to work in conjuction with other MB-System programs one should download and install MB-System. Please see also dwcaress/MB-System from which also the below information was copied from:

The primary source of information about MB-System is the project website at https://www.mbari.org/products/research-software/mb-system/, which includes sections on:

Python modules

Some of these modules below need to be installed, some of them might already be installed and/or are part of core python:

For xarray and its dependencies this command should suffice:

pip install xarray netcdf4 scipy pydap h5netcdf

Conda environment to run mbdownload18 and mbdownload23 (only tested on author's mac):

The name svptool can be altered to whatever you prefer

  1. conda create —name svptool (python=3.10)
  2. conda activate [envname]
  3. conda install numpy
  4. conda install pandas
  5. conda install matplotlib
  6. conda install pip
  7. conda install -c conda-forge xarray dask netCDF4 bottleneck
  8. pip install cartopy

After creating the environment and installing the packages you can just execute the download script with your activated envrionment (python or python3)

Todos