25#ifndef GOBY_UTIL_SEAWATER_SOUNDSPEED_H
26#define GOBY_UTIL_SEAWATER_SOUNDSPEED_H
30#include <boost/units/quantity.hpp>
31#include <boost/units/systems/si.hpp>
32#include <boost/units/systems/temperature/celsius.hpp>
48template <
typename TemperatureUnit = boost::units::celsius::temperature,
49 typename DimensionlessUnit = boost::units::si::dimensionless,
50 typename LengthUnit = boost::units::si::length>
51boost::units::quantity<boost::units::si::velocity>
53 boost::units::quantity<DimensionlessUnit>
salinity,
54 boost::units::quantity<LengthUnit>
depth,
bool ignore_bounds =
false)
58 double T = quantity<absolute<celsius::temperature> >(temperature).value();
59 double S = quantity<si::dimensionless>(
salinity).value();
60 double D = quantity<si::length>(
depth).value();
73 if (T < min_T || T > max_T)
74 throw std::out_of_range(
"Temperature not in valid range [-2, 30] deg C");
75 if (S < min_S || S > max_S)
76 throw std::out_of_range(
"Salinity not in valid range [25, 40]");
77 if (D < min_D || D > max_D)
78 throw std::out_of_range(
"Depth not in valid range [0, 8000] meters");
81 return (1448.96 + 4.591 * T - 5.304e-2 * T * T + 2.374e-4 * T * T * T + 1.340 * (S - 35) +
82 1.630e-2 * D + 1.675e-7 * D * D - 1.025e-2 * T * (S - 35) - 7.139e-13 * T * D * D * D) *
83 si::meters_per_second;
94template <
typename TemperatureUnit = boost::units::celsius::temperature,
95 typename LengthUnit = boost::units::si::length>
96boost::units::quantity<boost::units::si::velocity>
99 bool ignore_bounds =
false)
102 boost::units::quantity<boost::units::si::dimensionless>(
salinity),
103 depth, ignore_bounds);
boost::units::quantity< boost::units::si::velocity > mackenzie_soundspeed(boost::units::quantity< boost::units::absolute< TemperatureUnit > > temperature, boost::units::quantity< DimensionlessUnit > salinity, boost::units::quantity< LengthUnit > depth, bool ignore_bounds=false)
boost::units::quantity< boost::units::si::length > depth(boost::units::quantity< PressureUnit > pressure, boost::units::quantity< LatitudeUnit > latitude)
Calculates depth from pressure and latitude Adapted from "Algorithms for computation of fundamental p...
boost::units::quantity< boost::units::si::dimensionless > salinity(boost::units::quantity< ConductivityUnit > conductivity, boost::units::quantity< boost::units::absolute< TemperatureUnit > > temperature, boost::units::quantity< PressureUnit > pressure)
Calculates salinity from conductivity, temperature, and pressure Adapted from "Algorithms for computa...
The global namespace for the Goby project.