layout: default title: convert3D_TSZ_to_SV parent: Grid Tools nav_order: 13 —
convert3D_TSZ_to_SV
Description
convert3D_TSZ_to_SV is a specialized command-line utility for converting 3D gridded Salinity (S), Temperature (T), and Depth (Z) data into Sound Velocity (SV) profiles. It’s designed to process output from oceanographic models (specifically mentioned SalishSeaCast NetCDF files, which are converted to JHC .r4 grids for S, T, and Z at various layers). For each grid cell and depth layer, it reads S and T values, uses the corresponding Z from a .zvals file, calculates pressure, and then computes sound velocity using the Chen-Millero equation. The output is a new set of JHC .r4 grid files for sound velocity for each depth layer, along with copied .zvals and .time files.
Usage
convert3D_TSZ_to_SV -prefix <SectionPath/SectionPrefix> [OPTIONS]
Arguments
| Option | Description | Default / Example |
|---|---|---|
-prefix <SectionPath/SectionPrefix> | Required. Specifies the base path and prefix for the input S, T, and Z data files. The tool expects files named <prefix>.salinity.r4, <prefix>.temperature.r4, and <prefix>.salinity.zvals. The output sound velocity file will be named <prefix>.soundSpeed.r4. | -prefix SalishSea_Data/Converted/2024-10-26/salishsea.2024_jd299_12-00-00_Oct-26 |
-testTSZtoSv | Enables an interactive test mode where the user can manually input Salinity, Temperature, and Depth values to see the calculated Sound Velocity. | |
-v | Enable verbose output during processing. |
How It Works
- File Opening: Opens the input
.r4grids for salinity (.salinity.r4), temperature (.temperature.r4), and the.zvalsfile. Creates a new.r4grid for sound velocity (.soundSpeed.r4). - Header Reading: Reads the
JHC_headerfrom the input.r4files, ensuring dimensions match. - Data Processing: Iterates through each grid cell and each depth layer:
- Reads
salinityandtemperaturevalues from the respective grids. - Reads
depthfrom the.zvalsfile. - Calculates
pressurefromdepth. - Computes
sound_velocityusing the Chen-Millero equation (an empirical formula for calculating sound speed from salinity, temperature, and pressure). - Writes the calculated
sound_velocityto the output.soundSpeed.r4grid.
- Reads
- Auxiliary File Copying: Copies the input
.zvalsand.timefiles to new output files with the<prefix>and appropriate extensions.
Output Files
<prefix>.soundSpeed.r4: A JHC-format 32-bit floating-point grid file containing sound velocity for each grid cell and depth layer.<prefix>.zvals: Copied.zvalsfile.<prefix>.time: Copied.timefile.
Dependencies
array.h: ForJHC_headerstructure and related functions.support.h: For general utility functions and error handling.- Internal functions for Chen-Millero equation (
vchemilli).
Notes
This tool is specifically designed for processing SalishSeaCast model output, but the underlying principle of converting TSZ to SV using empirical equations is broadly applicable in oceanography. The accuracy of the calculated sound velocity depends on the quality of the input S, T, and Z data and the chosen empirical equation. The -testTSZtoSv option is useful for quick verification of the sound velocity calculation.