Goby3  3.1.5a
2024.05.23
depth.h
Go to the documentation of this file.
1 // Copyright 2013-2021:
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 // Community contributors (see AUTHORS file)
5 // File authors:
6 // Toby Schneider <toby@gobysoft.org>
7 //
8 //
9 // This file is part of the Goby Underwater Autonomy Project Libraries
10 // ("The Goby Libraries").
11 //
12 // The Goby Libraries are free software: you can redistribute them and/or modify
13 // them under the terms of the GNU Lesser General Public License as published by
14 // the Free Software Foundation, either version 2.1 of the License, or
15 // (at your option) any later version.
16 //
17 // The Goby Libraries are distributed in the hope that they will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public License
23 // along with Goby. If not, see <http://www.gnu.org/licenses/>.
24 
25 // modified for C++ by s. petillo spetillo@mit.edu
26 // ocean engineering graduate student - mit / whoi joint program
27 // massachusetts institute of technology (mit)
28 // laboratory for autonomous marine sensing systems (lamss)
29 
30 #ifndef GOBY_UTIL_SEAWATER_DEPTH_H
31 #define GOBY_UTIL_SEAWATER_DEPTH_H
32 
33 #include <cmath>
34 
35 #include <boost/units/quantity.hpp>
36 #include <boost/units/systems/angle/degrees.hpp>
37 #include <boost/units/systems/si.hpp>
39 
40 #include "units.h"
41 
42 namespace goby
43 {
44 namespace util
45 {
46 namespace seawater
47 {
54 template <typename PressureUnit = decltype(boost::units::si::deci* bar),
55  typename LatitudeUnit = boost::units::degree::plane_angle>
56 boost::units::quantity<boost::units::si::length>
57 depth(boost::units::quantity<PressureUnit> pressure, boost::units::quantity<LatitudeUnit> latitude)
58 {
59  using namespace boost::units;
60 
61  double P = quantity<decltype(si::deci * bar)>(pressure).value();
62  double LAT = quantity<degree::plane_angle>(latitude).value();
63 
64  double X = std::sin(LAT / 57.29578);
65  X = X * X;
66  // GR= GRAVITY VARIATION WITH LATITUDE: ANON (1970) BULLETIN GEODESIQUE
67  double GR = 9.780318 * (1.0 + (5.2788E-3 + 2.36E-5 * X) * X) + 1.092E-6 * P;
68  double DEPTH = (((-1.82E-15 * P + 2.279E-10) * P - 2.2512E-5) * P + 9.72659) * P;
69  DEPTH = DEPTH / GR;
70 
71  return DEPTH * si::meters;
72 }
73 } // namespace seawater
74 } // namespace util
75 } // namespace goby
76 
77 #endif
goby
The global namespace for the Goby project.
Definition: acomms_constants.h:33
goby::util::gps::LAT
@ LAT
Definition: gps_sentence.h:49
prefixes.hpp
goby::util::seawater::bar
static const boost::units::metric::bar_base_unit::unit_type bar
Definition: units.h:36
units.h
goby::util::seawater::pressure
boost::units::quantity< decltype(boost::units::si::deci *bar)> pressure(boost::units::quantity< DepthUnit > depth, boost::units::quantity< LatitudeUnit > latitude)
Calculates pressure from depth and latitude.
Definition: pressure.h:55
boost::units
Definition: time.hpp:18
goby::util::seawater::depth
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...
Definition: depth.h:57