World Ocean Simulation System (WOSS) library
ssp-definitions.h
Go to the documentation of this file.
1/* WOSS - World Ocean Simulation System -
2 *
3 * Copyright (C) 2009 Federico Guerra
4 * and regents of the SIGNET lab, University of Padova
5 *
6 * Author: Federico Guerra - federico@guerra-tlc.com
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation;
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22/*
23 * This software has been developed by Federico Guerra and SIGNET lab,
24 * University of Padova, in collaboration with the NATO Centre for
25 * Maritime Research and Experimentation (http://www.cmre.nato.int ;
26 * E-mail: pao@cmre.nato.int), whose support is gratefully acknowledged.
27 */
28
29
40#ifndef WOSS_SSP_DEFINITIONS_H
41#define WOSS_SSP_DEFINITIONS_H
42
43
44#include <cassert>
45#include <cstdlib>
46#include <map>
50#include "definitions-handler.h"
51
52
53namespace woss {
54
55
56 // UNESCO CHEN AND MILLERO EQUATIONS COEFFICIENTS
57 #define cf_C00 (1402.388)
58 #define cf_A02 (7.166e-5)
59 #define cf_C01 (5.03830)
60 #define cf_A03 (2.008e-6)
61 #define cf_C02 (-5.81090e-2)
62 #define cf_A04 (-3.21e-8)
63 #define cf_C03 (3.3432e-4)
64 #define cf_A10 (9.4742e-5)
65 #define cf_C04 (-1.47797e-6)
66 #define cf_A11 (-1.2583e-5)
67 #define cf_C05 (3.1419e-9)
68 #define cf_A12 (-6.4928e-8)
69 #define cf_C10 (0.153563)
70 #define cf_A13 (1.0515e-8)
71 #define cf_C11 (6.8999e-4)
72 #define cf_A14 (-2.0142e-10)
73 #define cf_C12 (-8.1829e-6)
74 #define cf_A20 (-3.9064e-7)
75 #define cf_C13 (1.3632e-7)
76 #define cf_A21 (9.1061e-9)
77 #define cf_C14 (-6.1260e-10)
78 #define cf_A22 (-1.6009e-10)
79 #define cf_C20 (3.1260e-5)
80 #define cf_A23 (7.994e-12)
81 #define cf_C21 (-1.7111e-6)
82 #define cf_A30 (1.100e-10)
83 #define cf_C22 (2.5986e-8)
84 #define cf_A31 (6.651e-12)
85 #define cf_C23 (-2.5353e-10)
86 #define cf_A32 (-3.391e-13)
87 #define cf_C24 (1.0415e-12)
88 #define cf_B00 (-1.922e-2)
89 #define cf_C30 (-9.7729e-9)
90 #define cf_B01 (-4.42e-5)
91 #define cf_C31 (3.8513e-10)
92 #define cf_B10 (7.3637e-5)
93 #define cf_C32 (-2.3654e-12)
94 #define cf_B11 (1.7950e-7)
95 #define cf_A00 (1.389)
96 #define cf_D00 (1.727e-3)
97 #define cf_A01 (-1.262e-2)
98 #define cf_D10 (-7.9836e-6)
99
100 // TEOS-10 constants
101 #define TEO_10_c000 -6.07991438090e-5
102 #define TEO_10_c001 1.99712338438e-5
103 #define TEO_10_c002 -3.39280843110e-6
104 #define TEO_10_c003 4.21246123200e-7
105 #define TEO_10_c004 -6.32363064300e-8
106 #define TEO_10_c005 1.17681023580e-8
107 #define TEO_10_c010 1.85057654290e-5
108 #define TEO_10_c011 -2.34727734620e-6
109 #define TEO_10_c012 -1.09581019659e-6
110 #define TEO_10_c013 1.25816399608e-6
111 #define TEO_10_c020 -1.17166068530e-5
112 #define TEO_10_c021 4.26100574800e-6
113 #define TEO_10_c022 8.60877154770e-7
114 #define TEO_10_c030 7.92796561730e-6
115 #define TEO_10_c031 -9.22650800740e-7
116 #define TEO_10_c040 -3.41021874820e-6
117 #define TEO_10_c041 -1.26705833028e-7
118 #define TEO_10_c050 5.07367668140e-7
119 #define TEO_10_c100 2.42624687470e-5
120 #define TEO_10_c101 -1.16968865968e-6
121 #define TEO_10_c102 1.08930565545e-6
122 #define TEO_10_c103 -4.45885016920e-7
123 #define TEO_10_c110 -9.56770881560e-6
124 #define TEO_10_c111 -1.11398309114e-5
125 #define TEO_10_c112 -8.18870887110e-7
126 #define TEO_10_c120 -2.36783083610e-7
127 #define TEO_10_c121 7.82747741600e-7
128 #define TEO_10_c130 -3.45587736550e-6
129 #define TEO_10_c131 1.55237776184e-8
130 #define TEO_10_c140 1.29567177830e-6
131 #define TEO_10_c200 -3.47924609740e-5
132 #define TEO_10_c201 -9.62445031940e-6
133 #define TEO_10_c202 5.02389113400e-8
134 #define TEO_10_c210 1.11008347650e-5
135 #define TEO_10_c211 1.09241497668e-5
136 #define TEO_10_c220 2.92833462950e-6
137 #define TEO_10_c221 -1.31462208134e-6
138 #define TEO_10_c230 3.16553060780e-7
139 #define TEO_10_c300 3.74707773050e-5
140 #define TEO_10_c301 9.85262139960e-6
141 #define TEO_10_c310 -9.84471178440e-6
142 #define TEO_10_c311 -2.70883712540e-6
143 #define TEO_10_c320 -4.88261392000e-7
144 #define TEO_10_c400 -1.73222186120e-5
145 #define TEO_10_c401 -3.56239494540e-6
146 #define TEO_10_c410 2.59092252600e-6
147 #define TEO_10_c500 3.09274272530e-6
148 #define TEO_10_v000 1.0769995862e-3
149 #define TEO_10_v001 -6.0799143809e-5
150 #define TEO_10_v002 9.9856169219e-6
151 #define TEO_10_v003 -1.1309361437e-6
152 #define TEO_10_v004 1.0531153080e-7
153 #define TEO_10_v005 -1.2647261286e-8
154 #define TEO_10_v006 1.9613503930e-9
155 #define TEO_10_v010 -3.1038981976e-4
156 #define TEO_10_v011 2.4262468747e-5
157 #define TEO_10_v012 -5.8484432984e-7
158 #define TEO_10_v013 3.6310188515e-7
159 #define TEO_10_v014 -1.1147125423e-7
160 #define TEO_10_v020 6.6928067038e-4
161 #define TEO_10_v021 -3.4792460974e-5
162 #define TEO_10_v022 -4.8122251597e-6
163 #define TEO_10_v023 1.6746303780e-8
164 #define TEO_10_v030 -8.5047933937e-4
165 #define TEO_10_v031 3.7470777305e-5
166 #define TEO_10_v032 4.9263106998e-6
167 #define TEO_10_v040 5.8086069943e-4
168 #define TEO_10_v041 -1.7322218612e-5
169 #define TEO_10_v042 -1.7811974727e-6
170 #define TEO_10_v050 -2.1092370507e-4
171 #define TEO_10_v051 3.0927427253e-6
172 #define TEO_10_v060 3.1932457305e-5
173 #define TEO_10_v100 -1.5649734675e-5
174 #define TEO_10_v101 1.8505765429e-5
175 #define TEO_10_v102 -1.1736386731e-6
176 #define TEO_10_v103 -3.6527006553e-7
177 #define TEO_10_v104 3.1454099902e-7
178 #define TEO_10_v110 3.5009599764e-5
179 #define TEO_10_v111 -9.5677088156e-6
180 #define TEO_10_v112 -5.5699154557e-6
181 #define TEO_10_v113 -2.7295696237e-7
182 #define TEO_10_v120 -4.3592678561e-5
183 #define TEO_10_v121 1.1100834765e-5
184 #define TEO_10_v122 5.4620748834e-6
185 #define TEO_10_v130 3.4532461828e-5
186 #define TEO_10_v131 -9.8447117844e-6
187 #define TEO_10_v132 -1.3544185627e-6
188 #define TEO_10_v140 -1.1959409788e-5
189 #define TEO_10_v141 2.5909225260e-6
190 #define TEO_10_v150 1.3864594581e-6
191 #define TEO_10_v200 2.7762106484e-5
192 #define TEO_10_v201 -1.1716606853e-5
193 #define TEO_10_v202 2.1305028740e-6
194 #define TEO_10_v203 2.8695905159e-7
195 #define TEO_10_v210 -3.7435842344e-5
196 #define TEO_10_v211 -2.3678308361e-7
197 #define TEO_10_v212 3.9137387080e-7
198 #define TEO_10_v220 3.5907822760e-5
199 #define TEO_10_v221 2.9283346295e-6
200 #define TEO_10_v222 -6.5731104067e-7
201 #define TEO_10_v230 -1.8698584187e-5
202 #define TEO_10_v231 -4.8826139200e-7
203 #define TEO_10_v240 3.8595339244e-6
204 #define TEO_10_v300 -1.6521159259e-5
205 #define TEO_10_v301 7.9279656173e-6
206 #define TEO_10_v302 -4.6132540037e-7
207 #define TEO_10_v310 2.4141479483e-5
208 #define TEO_10_v311 -3.4558773655e-6
209 #define TEO_10_v312 7.7618888092e-9
210 #define TEO_10_v320 -1.4353633048e-5
211 #define TEO_10_v321 3.1655306078e-7
212 #define TEO_10_v330 2.2863324556e-6
213 #define TEO_10_v400 6.9111322702e-6
214 #define TEO_10_v401 -3.4102187482e-6
215 #define TEO_10_v402 -6.3352916514e-8
216 #define TEO_10_v410 -8.7595873154e-6
217 #define TEO_10_v411 1.2956717783e-6
218 #define TEO_10_v420 4.3703680598e-6
219 #define TEO_10_v500 -8.0539615540e-7
220 #define TEO_10_v501 5.0736766814e-7
221 #define TEO_10_v510 -3.3052758900e-7
222 #define TEO_10_v600 2.0543094268e-7
223
224 #define TEO_10_gsw_sfac (0.0248826675584615)
225 #define TEO_10_offset (5.971840214030754e-1)
226
231 typedef ::std::map< PDouble, double > DepthMap;
232 typedef DepthMap::const_iterator DConstIter;
233 typedef DepthMap::iterator DIter;
234 typedef DepthMap::reverse_iterator DRIter;
235 typedef DepthMap::const_reverse_iterator DConstRIter;
236
237
242 #define SSP_CUSTOM_DEPTH_PRECISION (1.0e-6)
243
248 #define SSP_CUSTOM_DEPTH_STEPS (20.0)
249
250
258 class SSP {
259
260
261 public:
262
272
277 SSP( long double depth_precision = SSP_CUSTOM_DEPTH_PRECISION );
278
287 SSP( DepthMap& ssp_map, DepthMap& temp_map, DepthMap& sal_map, DepthMap& press_map, long double depth_precision = SSP_CUSTOM_DEPTH_PRECISION );
288
294 SSP( DepthMap& ssp_map, long double depth_precision = SSP_CUSTOM_DEPTH_PRECISION );
295
300 SSP( const SSP& copy );
301
302 virtual ~SSP() { }
303
304
310 virtual SSP* create( long double depth_precision = SSP_CUSTOM_DEPTH_PRECISION ) const { return new SSP(depth_precision); }
311
321 virtual SSP* create( DepthMap& ssp_map, DepthMap& temp_map, DepthMap& sal_map, DepthMap& press_map, long double depth_precision = SSP_CUSTOM_DEPTH_PRECISION ) const {
322 return new SSP( ssp_map, temp_map, sal_map, press_map, depth_precision); }
323
330 virtual SSP* create( DepthMap& ssp_map, long double depth_precision = SSP_CUSTOM_DEPTH_PRECISION ) const {
331 return new SSP( ssp_map, depth_precision); }
332
338 virtual SSP* create( const SSP& copy ) const { return new SSP( copy ); }
339
344 virtual SSP* clone() const { return new SSP(*this); }
345
346
351 int size() const { return( ssp_map.size() ); }
352
353
358 bool empty() const { return ssp_map.empty(); }
359
360
364 void clear() { ssp_map.clear(); temperature_map.clear(); pressure_map.clear(); salinity_map.clear(); }
365
366
371 DConstIter begin() const { return( ssp_map.begin() ); }
372
377 DConstIter end() const { return( ssp_map.end() ); }
378
383 DConstRIter rbegin() const { return( ssp_map.rbegin() ); }
384
389 DConstRIter rend() const { return( ssp_map.rend() ); }
390
391
397 DConstIter lower_bound( const PDouble& depth ) const { return( ssp_map.lower_bound(depth) ); }
398
404 DConstIter upper_bound( const PDouble& depth ) const { return( ssp_map.upper_bound(depth) ); }
405
411 DConstIter at( const int i ) const ;
412
413
418 DConstIter pressure_begin() const { return( pressure_map.begin() ); }
419
424 DConstIter pressure_end() const { return( pressure_map.end() ); }
425
430 DConstRIter pressure_rbegin() const { return( pressure_map.rbegin() ); }
431
436 DConstRIter pressure_rend() const { return( pressure_map.rend() ); }
437
438
444 DConstIter pressure_lower_bound( const PDouble& depth ) const { return( pressure_map.lower_bound(depth) ); }
445
451 DConstIter pressure_upper_bound( const PDouble& depth ) const { return( pressure_map.upper_bound(depth) ); }
452
458 DConstIter pressure_find( const PDouble& depth ) const { return( pressure_map.find(depth) ); }
459
460
465 DConstIter temperature_begin() const { return( temperature_map.begin() ); }
466
471 DConstIter temperature_end() const { return( temperature_map.end() ); }
472
477 DConstRIter temperature_rbegin() const { return( temperature_map.rbegin() ); }
478
483 DConstRIter temperature_rend() const { return( temperature_map.rend() ); }
484
485
491 DConstIter temperature_lower_bound( const PDouble& depth ) const { return( temperature_map.lower_bound(depth) ); }
492
498 DConstIter temperature_upper_bound( const PDouble& depth ) const { return( temperature_map.upper_bound(depth) ); }
499
505 DConstIter temperature_find( const PDouble& depth ) const { return( temperature_map.find(depth) ); }
506
507
512 DConstIter salinity_begin() const { return( salinity_map.begin() ); }
513
518 DConstIter salinity_end() const { return( salinity_map.end() ); }
519
524 DConstRIter salinity_rbegin() const { return( salinity_map.rbegin() ); }
525
530 DConstRIter salinity_rend() const { return( salinity_map.rend() ); }
531
532
538 DConstIter salinity_lower_bound( const PDouble& depth ) const { return( salinity_map.lower_bound(depth) ); }
539
545 DConstIter salinity_upper_bound( const PDouble& depth ) const { return( salinity_map.upper_bound(depth) ); }
546
552 DConstIter salinity_find( const PDouble& depth ) const { return( salinity_map.find(depth) ); }
553
554
559 virtual bool isValid() const { return( !ssp_map.empty() ); }
560
565 virtual bool isTransformable() const { return( isValid() /*&& !temperature_map.empty() && !pressure_map.empty() && !salinity_map.empty() */ ); }
566
571 virtual bool isRandomizable() const { return( isValid() && !temperature_map.empty() && !pressure_map.empty() && !salinity_map.empty() ); }
572
573
585 virtual SSP* transform( const Coord& coordinates, double new_min_depth = -HUGE_VAL, double new_max_depth = HUGE_VAL, int total_depth_steps = SSP_CUSTOM_DEPTH_STEPS ) const;
586
593 virtual SSP* truncate( double max_depth ) const;
594
601 virtual SSP* fullRandomize( double ratio_incr_value ) const;
602
608 virtual SSP* randomize( double ratio_incr_value ) const;
609
610
616 virtual bool import( ::std::istream& stream_in );
617
623 virtual bool write( ::std::ostream& stream_out ) const;
624
625
632 SSP& insertValue( double depth, double ssp_value );
633
643 SSP& insertValue( double depth, double temperature, double salinity, const ::std::complex<double>& pressure, double ssp_value );
644
653 SSP& insertValue( double temperature, double salinity, const ::std::complex<double>& pressure, const Coord& coordinates = Coord( 0.0, 0.0) );
654
663 SSP& insertValue( double depth, double temperature, double salinity, const Coord& coordinates = Coord(0.0, 0.0) );
664
665
671 DConstIter findValue( const double& depth ) const { return( ssp_map.find(depth) ); }
672
673
679 SSP& eraseValue( const double& depth ) { ssp_map.erase(depth); return *this; }
680
681
686 double getMaxDepthValue() const { if ( ssp_map.rbegin() != ssp_map.rend() ) return ssp_map.rbegin()->first;
687 else return 0.0; }
688
693 double getMinDepthValue() const { if ( ssp_map.begin() != ssp_map.end() ) return ssp_map.begin()->first;
694 else return 0.0; }
695
696
701 double getMaxSSPValue() const { return( max_ssp_value ); }
702
707 double getMinSSPValue() const { return( min_ssp_value ); }
708
709
715 virtual void setDepthPrecision( long double prec );
716
721 long double getDepthPrecision() const { return depth_precision; }
722
728 SSP& setSSPEqType(SSPEqType eq_type) { ssp_eq_type = eq_type; return *this; }
729
735
741 SSP& operator=( const SSP& x ) ;
742
743
750 friend bool operator==( const SSP& left, const SSP& right );
751
758 friend bool operator!=( const SSP& left, const SSP& right );
759
760
767 friend const SSP operator+( const SSP& left, const SSP& right );
768
775 friend const SSP operator-( const SSP& left, const SSP& right );
776
783 friend const SSP operator*( const SSP& left, const SSP& right );
784
791 friend const SSP operator/( const SSP& left, const SSP& right );
792
793
800 friend const SSP operator+( const SSP& left, const double right );
801
808 friend const SSP operator-( const SSP& left, const double right );
809
816 friend const SSP operator/( const SSP& left, const double right );
817
824 friend const SSP operator*( const SSP& left, const double right );
825
826
833 friend const SSP operator+( const double left, const SSP& right );
834
841 friend const SSP operator-( const double left, const SSP& right );
842
849 friend const SSP operator/( const double left, const SSP& right );
850
857 friend const SSP operator*( const double left, const SSP& right );
858
859
866 friend SSP& operator+=( SSP& left, const SSP& right );
867
874 friend SSP& operator-=( SSP& left, const SSP& right );
875
882 friend SSP& operator*=( SSP& left, const SSP& right );
883
890 friend SSP& operator/=( SSP& left, const SSP& right );
891
892
899 friend SSP& operator+=( SSP& left, const double right );
900
907 friend SSP& operator-=( SSP& left, const double right );
908
915 friend SSP& operator/=( SSP& left, const double right );
916
923 friend SSP& operator*=( SSP& left, const double right );
924
925
932 friend ::std::ostream& operator<<( ::std::ostream& os, const SSP& instance );
933
940 friend ::std::ostream& operator>>( ::std::istream& is, const SSP& instance );
941
942
947 static void setDebug( bool flag ) { debug = flag; }
948
949
950 protected:
951
956
961
966
970 long double depth_precision;
971
972
976 static bool debug;
977
978
983
988
993
998
999
1007 virtual double calculateSSP( double temperature, double salinity, double pressure ) const;
1008
1009
1010 private:
1011
1012
1018 bool isCanonOcean( const Coord& coordinates ) const { return( coordinates.getLatitude() >= -40.0 && coordinates.getLatitude() <= 60.0 ); }
1019
1025 bool isNEAtlanticOcean( const Coord& coordinates ) const { return( coordinates.getLatitude() >= 30.0 && coordinates.getLatitude() <= 60.0
1026 && coordinates.getLongitude() >= -43.0 && coordinates.getLongitude() <= -5.0 ); }
1027
1033 bool isAntarcticOcean( const Coord& coordinates ) const { return( coordinates.getLatitude() <= -55.0 ); }
1034
1040 bool isMediterraneanSea( const Coord& coordinates ) const { return( coordinates.getLatitude() >= 30.1 && coordinates.getLatitude() <= 46.0
1041 && coordinates.getLongitude() >= -4.0 && coordinates.getLongitude() <= 37.0 ); }
1042
1048 bool isRedSea( const Coord& coordinates ) const { return( coordinates.getLatitude() >= 12.0 && coordinates.getLatitude() <= 30.0
1049 && coordinates.getLongitude() >= 32.0 && coordinates.getLongitude() <= 44.0 ); }
1050
1056 bool isArcticOcean( const Coord& coordinates ) const { return( coordinates.getLatitude() >= 65.0 ); }
1057
1063 bool isJapanSea( const Coord& coordinates ) const { return( coordinates.getLatitude() >= 33.0 && coordinates.getLatitude() <= 52.0
1064 && coordinates.getLongitude() >= 127.0 && coordinates.getLongitude() <= 142.0 ); }
1065
1071 bool isSuluSea( const Coord& coordinates ) const { return( coordinates.getLatitude() >= 5.0 && coordinates.getLatitude() <= 13.0
1072 && coordinates.getLongitude() >= 117.0 && coordinates.getLongitude() <= 123.0 ); }
1073
1079 bool isHalmaheraSea( const Coord& coordinates ) const { return( coordinates.getLatitude() >= -2.0 && coordinates.getLatitude() <= 1.0
1080 && coordinates.getLongitude() >= 127.0 && coordinates.getLongitude() <= 130.0 ); }
1081
1087 bool isCelebesSea( const Coord& coordinates ) const { return( coordinates.getLatitude() >= 0.0 && coordinates.getLatitude() <= 7.0
1088 && coordinates.getLongitude() >= 115.0 && coordinates.getLongitude() <= 125.0 ); }
1089
1095 bool isBlackSea( const Coord& coordinates ) const { return( coordinates.getLatitude() >= 41.0 && coordinates.getLatitude() <= 48.0
1096 && coordinates.getLongitude() >= 28.0 && coordinates.getLongitude() <= 42.0 ); }
1097
1103 bool isBalticSea( const Coord& coordinates ) const { return( coordinates.getLatitude() >= 53.0 && coordinates.getLatitude() <= 66.0
1104 && coordinates.getLongitude() >= 20.0 && coordinates.getLongitude() <= 26.0 ); }
1105
1110 double thyh( double z ) const ;
1111
1116 double g( double lat ) const ;
1117
1123 double k( double z, double lat ) const ;
1124
1129 double hq( double z ) const ;
1130
1136 double h( double z, double lat ) const ;
1137
1143 double getPressureCorreptions( const Coord& coordinates, double depth ) const ;
1144
1151 double getPressureFromDepth( const Coord& coordinates, double depth ) const ;
1152
1153
1158 double g_z( double lat ) const ;
1159
1165 double getDepthCorreptions( const Coord& coordinates, double pressure ) const ;
1166
1173 double getDepthfromPressure( const Coord& coordinates, double pressure ) const ;
1174
1175
1181 double d( double t, double p ) const ;
1182
1188 double b( double t, double p ) const ;
1189
1195 double a( double t, double p ) const ;
1196
1202 double cw( double t, double p ) const ;
1203
1213 double gibbs(int ns, int nt, int np, double sa, double t, double p) const ;
1214
1215 };
1216
1217 //non-inline operator declarations
1219
1220 SSP& operator+=( SSP& left, const SSP& right );
1221
1222 SSP& operator-=( SSP& left, const SSP& right );
1223
1224 SSP& operator*=( SSP& left, const SSP& right );
1225
1226 SSP& operator/=( SSP& left, const SSP& right );
1227
1228
1229 SSP& operator+=( SSP& left, const double right );
1230
1231 SSP& operator-=( SSP& left, const double right );
1232
1233 SSP& operator/=( SSP& left, const double right );
1234
1235 SSP& operator*=( SSP& left, const double right );
1236
1237
1238 //inline functions
1240 inline bool operator==( const SSP& left, const SSP& right ) {
1241 if ( &left == &right ) return true;
1242 return( left.ssp_map == right.ssp_map && left.temperature_map == right.temperature_map && left.pressure_map == right.pressure_map
1243 && left.salinity_map == right.salinity_map );
1244 }
1245
1246
1247 inline bool operator!=( const SSP& left, const SSP& right ) {
1248 if ( &left == &right ) return false;
1249 return( left.ssp_map != right.ssp_map || left.temperature_map != right.temperature_map || left.pressure_map != right.pressure_map
1250 || left.salinity_map == right.salinity_map ); }
1251
1252
1253 inline const SSP operator+( const SSP& left, const SSP& right ) {
1254 SSP ret_val ( left );
1255 ret_val += right;
1256 return ret_val;
1257 }
1258
1259
1260 inline const SSP operator-( const SSP& left, const SSP& right ) {
1261 SSP ret_val ( left );
1262 ret_val -= right;
1263 return ret_val;
1264 }
1265
1266
1267 inline const SSP operator*( const SSP& left, const SSP& right ) {
1268 SSP ret_val ( left );
1269 ret_val *= right;
1270
1271 return ret_val;
1272 }
1273
1274
1275 inline const SSP operator/( const SSP& left, const SSP& right ) {
1276 SSP ret_val ( left );
1277 ret_val /= right;
1278 return ret_val;
1279 }
1280
1281
1282 inline const SSP operator+( const SSP& left, const double right ) {
1283 SSP ret_val ( left );
1284 ret_val += right;
1285 return ret_val;
1286 }
1287
1288
1289 inline const SSP operator-( const SSP& left, const double right ) {
1290 SSP ret_val ( left );
1291 ret_val -= right;
1292 return ret_val;
1293 }
1294
1295
1296 inline const SSP operator/( const SSP& left, const double right ) {
1297 SSP ret_val ( left );
1298 ret_val /= right;
1299 return ret_val;
1300 }
1301
1302
1303 inline const SSP operator*( const SSP& left, const double right ) {
1304 SSP ret_val ( left );
1305 ret_val *= right;
1306 return ret_val;
1307 }
1308
1309
1310 inline const SSP operator+( const double left, const SSP& right ) {
1311 SSP ret_val ( right );
1312 ret_val += left;
1313 return ret_val;
1314 }
1315
1316
1317 inline const SSP operator-( const double left, const SSP& right ) {
1318 SSP ret_val ( right );
1319 ret_val -= left;
1320 return ret_val;
1321 }
1322
1323
1324 inline const SSP operator/( const double left, const SSP& right ) {
1325 SSP ret_val ( right );
1326 ret_val /= left;
1327 return ret_val;
1328 }
1329
1330
1331 inline const SSP operator*( const double left, const SSP& right ) {
1332 SSP ret_val ( right );
1333 ret_val *= left;
1334 return ret_val;
1335 }
1336
1337
1338 inline ::std::ostream& operator<<( ::std::ostream& os, const SSP& instance ) {
1339 if ( !instance.write( os ) ) os.setstate( ::std::ios_base::failbit );
1340 return os;
1341 }
1342
1343
1344 inline ::std::istream& operator>>( ::std::istream& is, SSP& instance ) {
1345 if ( !instance.import( is ) ) is.setstate( ::std::ios_base::failbit );
1346 return is;
1347 }
1348
1349
1350 inline double SSP::thyh( double z ) const {
1351 return (1.0e-2 * z/(z+100) + 6.2e-6 * z);
1352 }
1353
1354
1355 inline double SSP::g( double lat ) const {
1356 return( 9.7803*(1.0 + 5.3e-3 * pow(sin(lat),2.0)) );
1357 }
1358
1359
1360 inline double SSP::k( double z, double lat ) const {
1361 return( (g(lat) - 2e-5 * z) / (9.80612 - 2e-5 * z) );
1362 }
1363
1364
1365 inline double SSP::hq( double z ) const {
1366 return( 1.00818e-2 * z + 2.465e-8 * pow(z,2.0) - 1.25e-13 * pow(z,3.0) + 2.8e-19 * pow(z,4.0) );
1367 }
1368
1369
1370 inline double SSP::h( double z, double lat ) const {
1371 return( hq(z) * k(z,lat) );
1372 }
1373
1374
1375 inline double SSP::getPressureFromDepth( const Coord& coordinates, double depth ) const {
1376 // conversion in bar from MPa
1377 return( 10.0 * ( h(depth,coordinates.getLatitude()) - thyh(depth) - getPressureCorreptions(coordinates, depth) ) );
1378 }
1379
1380
1381 inline double SSP::g_z( double lat ) const {
1382 return( 9.780318 * ( 1.0 + 5.2788 * 10e-3 * pow(sin(lat), 2.0) + 2.36 * 10e-5 * pow(sin(lat),4.0) ) );
1383 }
1384
1385
1386 inline double SSP::getDepthfromPressure( const Coord& coordinates, double pressure ) const {
1387 // conversion from bar to MPa
1388 pressure /= 10.0;
1389 return( ( (9.72659e2 * pressure - 2.2512e-1 * pow(pressure, 2.0) + 2.279e-4 * pow(pressure, 3.0) - 1.82e-7 * pow(pressure, 4.0) )
1390 / ( g_z(coordinates.getLatitude()) + 1.092e-4 * pressure ) ) + getDepthCorreptions(coordinates, pressure) );
1391 }
1392
1393
1394
1395 inline double SSP::calculateSSP(double temperature, double salinity, double pressure) const {
1397 {
1398 return( cw(temperature, pressure) + a(temperature, pressure)*salinity
1399 + b(temperature, pressure) * ::std::sqrt(salinity*salinity*salinity)
1400 + d(temperature, pressure) * (salinity*salinity) );
1401 }
1402 else if (ssp_eq_type == SSP_EQ_TEOS_10)
1403 {
1404 double v, v_p, xs, ys, z;
1405
1406 pressure *= 10; // formula requires dbar instead of bar
1407
1408 xs = ::std::sqrt(TEO_10_gsw_sfac*salinity + TEO_10_offset);
1409 ys = temperature*0.025;
1410 z = pressure*1e-4;
1411
1412 v = TEO_10_v000
1413 + xs*(TEO_10_v010 + xs*(TEO_10_v020 + xs*(TEO_10_v030 + xs*(TEO_10_v040 + xs*(TEO_10_v050
1414 + TEO_10_v060*xs))))) + ys*(TEO_10_v100 + xs*(TEO_10_v110 + xs*(TEO_10_v120 + xs*(TEO_10_v130 + xs*(TEO_10_v140
1415 + TEO_10_v150*xs)))) + ys*(TEO_10_v200 + xs*(TEO_10_v210 + xs*(TEO_10_v220 + xs*(TEO_10_v230 + TEO_10_v240*xs)))
1416 + ys*(TEO_10_v300 + xs*(TEO_10_v310 + xs*(TEO_10_v320 + TEO_10_v330*xs)) + ys*(TEO_10_v400 + xs*(TEO_10_v410
1417 + TEO_10_v420*xs) + ys*(TEO_10_v500 + TEO_10_v510*xs + TEO_10_v600*ys))))) + z*(TEO_10_v001 + xs*(TEO_10_v011
1418 + xs*(TEO_10_v021 + xs*(TEO_10_v031 + xs*(TEO_10_v041 + TEO_10_v051*xs)))) + ys*(TEO_10_v101 + xs*(TEO_10_v111
1419 + xs*(TEO_10_v121 + xs*(TEO_10_v131 + TEO_10_v141*xs))) + ys*(TEO_10_v201 + xs*(TEO_10_v211 + xs*(TEO_10_v221
1420 + TEO_10_v231*xs)) + ys*(TEO_10_v301 + xs*(TEO_10_v311 + TEO_10_v321*xs) + ys*(TEO_10_v401 + TEO_10_v411*xs
1421 + TEO_10_v501*ys)))) + z*(TEO_10_v002 + xs*(TEO_10_v012 + xs*(TEO_10_v022 + xs*(TEO_10_v032 + TEO_10_v042*xs)))
1422 + ys*(TEO_10_v102 + xs*(TEO_10_v112 + xs*(TEO_10_v122 + TEO_10_v132*xs)) + ys*(TEO_10_v202 + xs*(TEO_10_v212
1423 + TEO_10_v222*xs) + ys*(TEO_10_v302 + TEO_10_v312*xs + TEO_10_v402*ys))) + z*(TEO_10_v003 + xs*(TEO_10_v013
1424 + TEO_10_v023*xs) + ys*(TEO_10_v103 + TEO_10_v113*xs + TEO_10_v203*ys) + z*(TEO_10_v004 + TEO_10_v014*xs + TEO_10_v104*ys
1425 + z*(TEO_10_v005 + TEO_10_v006*z)))));
1426
1427 v_p = TEO_10_c000
1428 + xs*(TEO_10_c100 + xs*(TEO_10_c200 + xs*(TEO_10_c300 + xs*(TEO_10_c400 + TEO_10_c500*xs))))
1429 + ys*(TEO_10_c010 + xs*(TEO_10_c110 + xs*(TEO_10_c210 + xs*(TEO_10_c310 + TEO_10_c410*xs))) + ys*(TEO_10_c020
1430 + xs*(TEO_10_c120 + xs*(TEO_10_c220 + TEO_10_c320*xs)) + ys*(TEO_10_c030 + xs*(TEO_10_c130 + TEO_10_c230*xs)
1431 + ys*(TEO_10_c040 + TEO_10_c140*xs + TEO_10_c050*ys)))) + z*(TEO_10_c001 + xs*(TEO_10_c101 + xs*(TEO_10_c201
1432 + xs*(TEO_10_c301 + TEO_10_c401*xs))) + ys*(TEO_10_c011 + xs*(TEO_10_c111 + xs*(TEO_10_c211 + TEO_10_c311*xs))
1433 + ys*(TEO_10_c021 + xs*(TEO_10_c121 + TEO_10_c221*xs) + ys*(TEO_10_c031 + TEO_10_c131*xs + TEO_10_c041*ys)))
1434 + z*( TEO_10_c002 + xs*(TEO_10_c102 + TEO_10_c202*xs) + ys*(TEO_10_c012 + TEO_10_c112*xs + TEO_10_c022*ys)
1435 + z*(TEO_10_c003 + TEO_10_c103*xs + TEO_10_c013*ys + z*(TEO_10_c004 + TEO_10_c005*z))));
1436
1437 return (10000.0*::std::sqrt(-v*v/v_p));
1438 }
1440 {
1441 int n0=0, n1=1, n2=2;
1442 double g_tt, g_tp;
1443
1444 pressure *= 10; // formulas require dbar instead of bar
1445
1446 g_tt = gibbs(n0, n2, n0, salinity, temperature, pressure);
1447 g_tp = gibbs(n0, n1, n1, salinity, temperature, pressure);
1448
1449 return (gibbs(n0, n0, n1, salinity, temperature, pressure) * ::std::sqrt(g_tt/(g_tp*g_tp - g_tt*gibbs(n0, n0, n2, salinity, temperature, pressure))));
1450 }
1451 else return -HUGE_VAL;
1452 }
1453
1454 inline double SSP::gibbs(int ns, int nt, int np, double sa, double t, double p) const
1455 {
1456 double x2, x, y, z, g03, g08, return_value = 0.0;
1457
1458 x2 = TEO_10_gsw_sfac*sa;
1459 x = sqrt(x2);
1460 y = t*0.025;
1461 z = p*1e-4;
1462
1463 if (ns == 0 && nt == 0 && np == 0) {
1464 g03 = 101.342743139674 + z*(100015.695367145 +
1465 z*(-2544.5765420363 + z*(284.517778446287 +
1466 z*(-33.3146754253611 + (4.20263108803084 -
1467 0.546428511471039*z)*z)))) +
1468 y*(5.90578347909402 + z*(-270.983805184062 +
1469 z*(776.153611613101 + z*(-196.51255088122 +
1470 (28.9796526294175 - 2.13290083518327*z)*z))) +
1471 y*(-12357.785933039 + z*(1455.0364540468 +
1472 z*(-756.558385769359 + z*(273.479662323528 +
1473 z*(-55.5604063817218 + 4.34420671917197*z)))) +
1474 y*(736.741204151612 + z*(-672.50778314507 +
1475 z*(499.360390819152 + z*(-239.545330654412 +
1476 (48.8012518593872 - 1.66307106208905*z)*z))) +
1477 y*(-148.185936433658 + z*(397.968445406972 +
1478 z*(-301.815380621876 + (152.196371733841 -
1479 26.3748377232802*z)*z)) +
1480 y*(58.0259125842571 + z*(-194.618310617595 +
1481 z*(120.520654902025 + z*(-55.2723052340152 +
1482 6.48190668077221*z))) +
1483 y*(-18.9843846514172 + y*(3.05081646487967 -
1484 9.63108119393062*z) +
1485 z*(63.5113936641785 + z*(-22.2897317140459 +
1486 8.17060541818112*z))))))));
1487
1488 g08 = x2*(1416.27648484197 + z*(-3310.49154044839 +
1489 z*(384.794152978599 + z*(-96.5324320107458 +
1490 (15.8408172766824 - 2.62480156590992*z)*z))) +
1491 x*(-2432.14662381794 + x*(2025.80115603697 +
1492 y*(543.835333000098 + y*(-68.5572509204491 +
1493 y*(49.3667694856254 + y*(-17.1397577419788 +
1494 2.49697009569508*y))) - 22.6683558512829*z) +
1495 x*(-1091.66841042967 - 196.028306689776*y +
1496 x*(374.60123787784 - 48.5891069025409*x +
1497 36.7571622995805*y) + 36.0284195611086*z) +
1498 z*(-54.7919133532887 + (-4.08193978912261 -
1499 30.1755111971161*z)*z)) +
1500 z*(199.459603073901 + z*(-52.2940909281335 +
1501 (68.0444942726459 - 3.41251932441282*z)*z)) +
1502 y*(-493.407510141682 + z*(-175.292041186547 +
1503 (83.1923927801819 - 29.483064349429*z)*z) +
1504 y*(-43.0664675978042 + z*(383.058066002476 +
1505 z*(-54.1917262517112 + 25.6398487389914*z)) +
1506 y*(-10.0227370861875 - 460.319931801257*z +
1507 y*(0.875600661808945 + 234.565187611355*z))))) +
1508 y*(168.072408311545 + z*(729.116529735046 +
1509 z*(-343.956902961561 + z*(124.687671116248 +
1510 z*(-31.656964386073 + 7.04658803315449*z)))) +
1511 y*(880.031352997204 + y*(-225.267649263401 +
1512 y*(91.4260447751259 + y*(-21.6603240875311 +
1513 2.13016970847183*y) +
1514 z*(-297.728741987187 + (74.726141138756 -
1515 36.4872919001588*z)*z)) +
1516 z*(694.244814133268 + z*(-204.889641964903 +
1517 (113.561697840594 - 11.1282734326413*z)*z))) +
1518 z*(-860.764303783977 + z*(337.409530269367 +
1519 z*(-178.314556207638 + (44.2040358308 -
1520 7.92001547211682*z)*z))))));
1521
1522 if (sa > 0.0)
1523 g08 = g08 + x2*(5812.81456626732 +
1524 851.226734946706*y)*log(x);
1525
1526 return_value = g03 + g08;
1527 }
1528 else if (ns == 1 && nt == 0 && np == 0) {
1529 g08 = 8645.36753595126 + z*(-6620.98308089678 +
1530 z*(769.588305957198 + z*(-193.0648640214916 +
1531 (31.6816345533648 - 5.24960313181984*z)*z))) +
1532 x*(-7296.43987145382 + x*(8103.20462414788 +
1533 y*(2175.341332000392 + y*(-274.2290036817964 +
1534 y*(197.4670779425016 + y*(-68.5590309679152 +
1535 9.98788038278032*y))) - 90.6734234051316*z) +
1536 x*(-5458.34205214835 - 980.14153344888*y +
1537 x*(2247.60742726704 - 340.1237483177863*x +
1538 220.542973797483*y) + 180.142097805543*z) +
1539 z*(-219.1676534131548 + (-16.32775915649044 -
1540 120.7020447884644*z)*z)) +
1541 z*(598.378809221703 + z*(-156.8822727844005 +
1542 (204.1334828179377 - 10.23755797323846*z)*z)) +
1543 y*(-1480.222530425046 + z*(-525.876123559641 +
1544 (249.57717834054571 - 88.449193048287*z)*z) +
1545 y*(-129.1994027934126 + z*(1149.174198007428 +
1546 z*(-162.5751787551336 + 76.9195462169742*z)) +
1547 y*(-30.0682112585625 - 1380.9597954037708*z +
1548 y*(2.626801985426835 + 703.695562834065*z))))) +
1549 y*(1187.3715515697959 + z*(1458.233059470092 +
1550 z*(-687.913805923122 + z*(249.375342232496 +
1551 z*(-63.313928772146 + 14.09317606630898*z)))) +
1552 y*(1760.062705994408 + y*(-450.535298526802 +
1553 y*(182.8520895502518 + y*(-43.3206481750622 +
1554 4.26033941694366*y) +
1555 z*(-595.457483974374 + (149.452282277512 -
1556 72.9745838003176*z)*z)) +
1557 z*(1388.489628266536 + z*(-409.779283929806 +
1558 (227.123395681188 - 22.2565468652826*z)*z))) +
1559 z*(-1721.528607567954 + z*(674.819060538734 +
1560 z*(-356.629112415276 + (88.4080716616 -
1561 15.84003094423364*z)*z)))));
1562
1563 if (sa > 0.0)
1564 g08 = g08 + (11625.62913253464 + 1702.453469893412*y)*log(x);
1565 else
1566 g08 = 0.0;
1567
1568 return_value = 0.5*TEO_10_gsw_sfac*g08;
1569 }
1570 else if (ns == 0 && nt == 1 && np == 0) {
1571 g03 = 5.90578347909402 + z*(-270.983805184062 +
1572 z*(776.153611613101 + z*(-196.51255088122 +
1573 (28.9796526294175 - 2.13290083518327*z)*z))) +
1574 y*(-24715.571866078 + z*(2910.0729080936 +
1575 z*(-1513.116771538718 + z*(546.959324647056 +
1576 z*(-111.1208127634436 + 8.68841343834394*z)))) +
1577 y*(2210.2236124548363 + z*(-2017.52334943521 +
1578 z*(1498.081172457456 + z*(-718.6359919632359 +
1579 (146.4037555781616 - 4.9892131862671505*z)*z))) +
1580 y*(-592.743745734632 + z*(1591.873781627888 +
1581 z*(-1207.261522487504 + (608.785486935364 -
1582 105.4993508931208*z)*z)) +
1583 y*(290.12956292128547 + z*(-973.091553087975 +
1584 z*(602.603274510125 + z*(-276.361526170076 +
1585 32.40953340386105*z))) +
1586 y*(-113.90630790850321 + y*(21.35571525415769 -
1587 67.41756835751434*z) +
1588 z*(381.06836198507096 + z*(-133.7383902842754 +
1589 49.023632509086724*z)))))));
1590
1591 g08 = x2*(168.072408311545 + z*(729.116529735046 +
1592 z*(-343.956902961561 + z*(124.687671116248 +
1593 z*(-31.656964386073 + 7.04658803315449*z)))) +
1594 x*(-493.407510141682 + x*(543.835333000098 +
1595 x*(-196.028306689776 + 36.7571622995805*x) +
1596 y*(-137.1145018408982 + y*(148.10030845687618 +
1597 y*(-68.5590309679152 + 12.4848504784754*y))) -
1598 22.6683558512829*z) + z*(-175.292041186547 +
1599 (83.1923927801819 - 29.483064349429*z)*z) +
1600 y*(-86.1329351956084 + z*(766.116132004952 +
1601 z*(-108.3834525034224 + 51.2796974779828*z)) +
1602 y*(-30.0682112585625 - 1380.9597954037708*z +
1603 y*(3.50240264723578 + 938.26075044542*z)))) +
1604 y*(1760.062705994408 + y*(-675.802947790203 +
1605 y*(365.7041791005036 + y*(-108.30162043765552 +
1606 12.78101825083098*y) +
1607 z*(-1190.914967948748 + (298.904564555024 -
1608 145.9491676006352*z)*z)) +
1609 z*(2082.7344423998043 + z*(-614.668925894709 +
1610 (340.685093521782 - 33.3848202979239*z)*z))) +
1611 z*(-1721.528607567954 + z*(674.819060538734 +
1612 z*(-356.629112415276 + (88.4080716616 -
1613 15.84003094423364*z)*z)))));
1614
1615 if (sa > 0.0)
1616 g08 = g08 + 851.226734946706*x2*log(x);
1617
1618 return_value = (g03 + g08)*0.025;
1619 }
1620 else if (ns == 0 && nt == 0 && np == 1) {
1621 g03 = 100015.695367145 + z*(-5089.1530840726 +
1622 z*(853.5533353388611 + z*(-133.2587017014444 +
1623 (21.0131554401542 - 3.278571068826234*z)*z))) +
1624 y*(-270.983805184062 + z*(1552.307223226202 +
1625 z*(-589.53765264366 + (115.91861051767 -
1626 10.664504175916349*z)*z)) +
1627 y*(1455.0364540468 + z*(-1513.116771538718 +
1628 z*(820.438986970584 + z*(-222.2416255268872 +
1629 21.72103359585985*z))) +
1630 y*(-672.50778314507 + z*(998.720781638304 +
1631 z*(-718.6359919632359 + (195.2050074375488 -
1632 8.31535531044525*z)*z)) +
1633 y*(397.968445406972 + z*(-603.630761243752 +
1634 (456.589115201523 - 105.4993508931208*z)*z) +
1635 y*(-194.618310617595 + y*(63.5113936641785 -
1636 9.63108119393062*y +
1637 z*(-44.5794634280918 + 24.511816254543362*z)) +
1638 z*(241.04130980405 + z*(-165.8169157020456 +
1639 25.92762672308884*z)))))));
1640
1641 g08 = x2*(-3310.49154044839 + z*(769.588305957198 +
1642 z*(-289.5972960322374 + (63.3632691067296 -
1643 13.1240078295496*z)*z)) +
1644 x*(199.459603073901 + x*(-54.7919133532887 +
1645 36.0284195611086*x - 22.6683558512829*y +
1646 (-8.16387957824522 - 90.52653359134831*z)*z) +
1647 z*(-104.588181856267 + (204.1334828179377 -
1648 13.65007729765128*z)*z) +
1649 y*(-175.292041186547 + (166.3847855603638 -
1650 88.449193048287*z)*z +
1651 y*(383.058066002476 + y*(-460.319931801257 +
1652 234.565187611355*y) +
1653 z*(-108.3834525034224 + 76.9195462169742*z)))) +
1654 y*(729.116529735046 + z*(-687.913805923122 +
1655 z*(374.063013348744 + z*(-126.627857544292 +
1656 35.23294016577245*z))) +
1657 y*(-860.764303783977 + y*(694.244814133268 +
1658 y*(-297.728741987187 + (149.452282277512 -
1659 109.46187570047641*z)*z) +
1660 z*(-409.779283929806 + (340.685093521782 -
1661 44.5130937305652*z)*z)) +
1662 z*(674.819060538734 + z*(-534.943668622914 +
1663 (176.8161433232 - 39.600077360584095*z)*z)))));
1664
1665 return_value = (g03 + g08)*1.0e-8;
1666 }
1667 else if (ns == 0 && nt == 2 && np == 0) {
1668 g03 = -24715.571866078 + z*(2910.0729080936 + z*
1669 (-1513.116771538718 + z*(546.959324647056 +
1670 z*(-111.1208127634436 + 8.68841343834394*z)))) +
1671 y*(4420.4472249096725 + z*(-4035.04669887042 +
1672 z*(2996.162344914912 + z*(-1437.2719839264719 +
1673 (292.8075111563232 - 9.978426372534301*z)*z))) +
1674 y*(-1778.231237203896 + z*(4775.621344883664 +
1675 z*(-3621.784567462512 + (1826.356460806092 -
1676 316.49805267936244*z)*z)) +
1677 y*(1160.5182516851419 + z*(-3892.3662123519 +
1678 z*(2410.4130980405 + z*(-1105.446104680304 +
1679 129.6381336154442*z))) +
1680 y*(-569.531539542516 + y*(128.13429152494615 -
1681 404.50541014508605*z) +
1682 z*(1905.341809925355 + z*(-668.691951421377 +
1683 245.11816254543362*z))))));
1684
1685 g08 = x2*(1760.062705994408 + x*(-86.1329351956084 +
1686 x*(-137.1145018408982 + y*(296.20061691375236 +
1687 y*(-205.67709290374563 + 49.9394019139016*y))) +
1688 z*(766.116132004952 + z*(-108.3834525034224 +
1689 51.2796974779828*z)) +
1690 y*(-60.136422517125 - 2761.9195908075417*z +
1691 y*(10.50720794170734 + 2814.78225133626*z))) +
1692 y*(-1351.605895580406 + y*(1097.1125373015109 +
1693 y*(-433.20648175062206 + 63.905091254154904*y) +
1694 z*(-3572.7449038462437 + (896.713693665072 -
1695 437.84750280190565*z)*z)) +
1696 z*(4165.4688847996085 + z*(-1229.337851789418 +
1697 (681.370187043564 - 66.7696405958478*z)*z))) +
1698 z*(-1721.528607567954 + z*(674.819060538734 +
1699 z*(-356.629112415276 + (88.4080716616 -
1700 15.84003094423364*z)*z))));
1701
1702 return_value = (g03 + g08)*0.000625;
1703 }
1704 else if (ns == 1 && nt == 0 && np == 1) {
1705 g08 = -6620.98308089678 + z*(1539.176611914396 +
1706 z*(-579.1945920644748 + (126.7265382134592 -
1707 26.2480156590992*z)*z)) +
1708 x*(598.378809221703 + x*(-219.1676534131548 +
1709 180.142097805543*x - 90.6734234051316*y +
1710 (-32.65551831298088 - 362.10613436539325*z)*z) +
1711 z*(-313.764545568801 + (612.4004484538132 -
1712 40.95023189295384*z)*z) +
1713 y*(-525.876123559641 + (499.15435668109143 -
1714 265.347579144861*z)*z +
1715 y*(1149.174198007428 + y*(-1380.9597954037708 +
1716 703.695562834065*y) +
1717 z*(-325.1503575102672 + 230.7586386509226*z)))) +
1718 y*(1458.233059470092 + z*(-1375.827611846244 +
1719 z*(748.126026697488 + z*(-253.255715088584 +
1720 70.4658803315449*z))) +
1721 y*(-1721.528607567954 + y*(1388.489628266536 +
1722 y*(-595.457483974374 + (298.904564555024 -
1723 218.92375140095282*z)*z) +
1724 z*(-819.558567859612 + (681.370187043564 -
1725 89.0261874611304*z)*z)) +
1726 z*(1349.638121077468 + z*(-1069.887337245828 +
1727 (353.6322866464 - 79.20015472116819*z)*z))));
1728
1729 return_value = g08*TEO_10_gsw_sfac*0.5e-8;
1730 }
1731 else if (ns == 0 && nt == 1 && np == 1) {
1732 g03 = -270.983805184062 + z*(1552.307223226202 +
1733 z*(-589.53765264366 + (115.91861051767 -
1734 10.664504175916349*z)*z)) +
1735 y*(2910.0729080936 + z*(-3026.233543077436 +
1736 z*(1640.877973941168 + z*(-444.4832510537744 +
1737 43.4420671917197*z))) +
1738 y*(-2017.52334943521 + z*(2996.162344914912 +
1739 z*(-2155.907975889708 + (585.6150223126464 -
1740 24.946065931335752*z)*z)) +
1741 y*(1591.873781627888 + z*(-2414.523044975008 +
1742 (1826.356460806092 - 421.9974035724832*z)*z) +
1743 y*(-973.091553087975 + z*(1205.20654902025 +
1744 z*(-829.084578510228 + 129.6381336154442*z)) +
1745 y*(381.06836198507096 - 67.41756835751434*y +
1746 z*(-267.4767805685508 + 147.07089752726017*z))))));
1747
1748 g08 = x2*(729.116529735046 + z*(-687.913805923122 +
1749 z*(374.063013348744 + z*(-126.627857544292 +
1750 35.23294016577245*z))) +
1751 x*(-175.292041186547 - 22.6683558512829*x +
1752 (166.3847855603638 - 88.449193048287*z)*z +
1753 y*(766.116132004952 + y*(-1380.9597954037708 +
1754 938.26075044542*y) +
1755 z*(-216.7669050068448 + 153.8390924339484*z))) +
1756 y*(-1721.528607567954 + y*(2082.7344423998043 +
1757 y*(-1190.914967948748 + (597.809129110048 -
1758 437.84750280190565*z)*z) +
1759 z*(-1229.337851789418 + (1022.055280565346 -
1760 133.5392811916956*z)*z)) +
1761 z*(1349.638121077468 + z*(-1069.887337245828 +
1762 (353.6322866464 - 79.20015472116819*z)*z))));
1763
1764 return_value = (g03 + g08)*2.5e-10;
1765 }
1766 else if (ns == 1 && nt == 1 && np == 0) {
1767 g08 = 1187.3715515697959 + z*(1458.233059470092 +
1768 z*(-687.913805923122 + z*(249.375342232496 +
1769 z*(-63.313928772146 + 14.09317606630898*z)))) +
1770 x*(-1480.222530425046 + x*(2175.341332000392 +
1771 x*(-980.14153344888 + 220.542973797483*x) +
1772 y*(-548.4580073635929 + y*(592.4012338275047 +
1773 y*(-274.2361238716608 + 49.9394019139016*y))) -
1774 90.6734234051316*z) +
1775 z*(-525.876123559641 + (249.57717834054571 -
1776 88.449193048287*z)*z) +
1777 y*(-258.3988055868252 + z*(2298.348396014856 +
1778 z*(-325.1503575102672 + 153.8390924339484*z)) +
1779 y*(-90.2046337756875 - 4142.8793862113125*z +
1780 y*(10.50720794170734 + 2814.78225133626*z)))) +
1781 y*(3520.125411988816 + y*(-1351.605895580406 +
1782 y*(731.4083582010072 + y*(-216.60324087531103 +
1783 25.56203650166196*y) +
1784 z*(-2381.829935897496 + (597.809129110048 -
1785 291.8983352012704*z)*z)) +
1786 z*(4165.4688847996085 + z*(-1229.337851789418 +
1787 (681.370187043564 - 66.7696405958478*z)*z))) +
1788 z*(-3443.057215135908 + z*(1349.638121077468 +
1789 z*(-713.258224830552 + (176.8161433232 -
1790 31.68006188846728*z)*z))));
1791
1792 if (sa > 0.0)
1793 g08 = g08 + 1702.453469893412*log(x);
1794
1795 return_value = 0.5*TEO_10_gsw_sfac*0.025*g08;
1796 }
1797 else if (ns == 2 && nt == 0 && np == 0) {
1798 g08 = 2.0*(8103.20462414788 +
1799 y*(2175.341332000392 + y*(-274.2290036817964 +
1800 y*(197.4670779425016 + y*(-68.5590309679152 +
1801 9.98788038278032*y))) - 90.6734234051316*z) +
1802 1.5*x*(-5458.34205214835 - 980.14153344888*y +
1803 (4.0/3.0)*x*(2247.60742726704 - 340.1237483177863*1.25*x +
1804 220.542973797483*y) + 180.142097805543*z) +
1805 z*(-219.1676534131548 + (-16.32775915649044 -
1806 120.7020447884644*z)*z));
1807
1808 if (x > 0.0) {
1809 g08 += (-7296.43987145382 + z*(598.378809221703 +
1810 z*(-156.8822727844005 + (204.1334828179377 -
1811 10.23755797323846*z)*z)) +
1812 y*(-1480.222530425046 + z*(-525.876123559641 +
1813 (249.57717834054571 - 88.449193048287*z)*z) +
1814 y*(-129.1994027934126 + z*(1149.174198007428 +
1815 z*(-162.5751787551336 + 76.9195462169742*z)) +
1816 y*(-30.0682112585625 - 1380.9597954037708*z +
1817 y*(2.626801985426835 + 703.695562834065*z)))))/x +
1818 (11625.62913253464 + 1702.453469893412*y)/x2;
1819 } else
1820 g08 = 0.0;
1821
1822 return_value = 0.25*TEO_10_gsw_sfac*TEO_10_gsw_sfac*g08;
1823 }
1824 else if (ns == 0 && nt == 0 && np == 2) {
1825 g03 = -5089.1530840726 + z*(1707.1066706777221 +
1826 z*(-399.7761051043332 + (84.0526217606168 -
1827 16.39285534413117*z)*z)) +
1828 y*(1552.307223226202 + z*(-1179.07530528732 +
1829 (347.75583155301 - 42.658016703665396*z)*z) +
1830 y*(-1513.116771538718 + z*(1640.877973941168 +
1831 z*(-666.7248765806615 + 86.8841343834394*z)) +
1832 y*(998.720781638304 + z*(-1437.2719839264719 +
1833 (585.6150223126464 - 33.261421241781*z)*z) +
1834 y*(-603.630761243752 + (913.178230403046 -
1835 316.49805267936244*z)*z +
1836 y*(241.04130980405 + y*(-44.5794634280918 +
1837 49.023632509086724*z) +
1838 z*(-331.6338314040912 + 77.78288016926652*z))))));
1839
1840 g08 = x2*(769.588305957198 + z*(-579.1945920644748 +
1841 (190.08980732018878 - 52.4960313181984*z)*z) +
1842 x*(-104.588181856267 + x*(-8.16387957824522 -
1843 181.05306718269662*z) +
1844 (408.2669656358754 - 40.95023189295384*z)*z +
1845 y*(166.3847855603638 - 176.898386096574*z +
1846 y*(-108.3834525034224 + 153.8390924339484*z))) +
1847 y*(-687.913805923122 + z*(748.126026697488 +
1848 z*(-379.883572632876 + 140.9317606630898*z)) +
1849 y*(674.819060538734 + z*(-1069.887337245828 +
1850 (530.4484299696 - 158.40030944233638*z)*z) +
1851 y*(-409.779283929806 + y*(149.452282277512 -
1852 218.92375140095282*z) +
1853 (681.370187043564 - 133.5392811916956*z)*z))));
1854
1855 return_value = (g03 + g08)*1e-16 ;
1856 }
1857 else
1858 return_value = -HUGE_VAL;
1859
1860 return (return_value);
1861 }
1862
1863 inline double SSP::d(double t, double p) const {
1864 return( cf_D00 + cf_D10*p );
1865 }
1866
1867
1868 inline double SSP::b( double t, double p) const {
1869 return( cf_B00 + cf_B01*t + (cf_B10 + cf_B11*t)*p );
1870 }
1871
1872
1873 inline double SSP::a(double t, double p) const {
1874 return( (cf_A00 + cf_A01*t + cf_A02*pow(t,2.0) + cf_A03*pow(t,3.0) + cf_A04*pow(t,4.0))
1875 + (cf_A10 + cf_A11*t + cf_A12*pow(t,2.0) + cf_A13*pow(t,3.0) + cf_A14*pow(t,4.0))*p
1876 + (cf_A20 + cf_A21*t + cf_A22*pow(t,2.0) + cf_A23*pow(t,3.0))*pow(p,2.0)
1877 + (cf_A30 + cf_A31*t + cf_A32*pow(t,2.0))*pow(p,3.0) );
1878 }
1879
1880
1881 inline double SSP::cw( double t, double p) const {
1882 return( (cf_C00 + cf_C01*t + cf_C02*pow(t,2.0) + cf_C03*pow(t,3.0) + cf_C04*pow(t,4.0) + cf_C05*pow(t,5.0))
1883 + (cf_C10 + cf_C11*t + cf_C12*pow(t,2.0) + cf_C13*pow(t,3.0) + cf_C14*pow(t,4.0))*p
1884 + (cf_C20 + cf_C21*t + cf_C22*pow(t,2.0) + cf_C23*pow(t,3.0) + cf_C24*pow(t,4.0))*pow(p,2.0)
1885 + (cf_C30 + cf_C31*t + cf_C32*pow(t,2.0))*pow(p,3.0) );
1886 }
1887
1888}
1889
1890
1891#endif /* WOSS_SSP_DEFINITIONS_H */
1892
1893
bool operator!=(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.h:846
std::ostream & operator<<(std::ostream &os, const Altimetry &instance)
Definition altimetry-definitions.h:826
const Altimetry operator/(const Altimetry &left, const double right)
Definition altimetry-definitions.cpp:285
bool operator==(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.h:840
const Altimetry operator+(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.cpp:257
const Altimetry operator*(const Altimetry &left, const double right)
Definition altimetry-definitions.cpp:292
const Altimetry operator-(const Altimetry &left, const Altimetry &right)
Definition altimetry-definitions.cpp:264
Coordinates (lat, long) class definitions and functions library.
Definition coordinates-definitions.h:107
double getLatitude() const
Definition coordinates-definitions.h:175
double getLongitude() const
Definition coordinates-definitions.h:181
Custom precision long double class.
Definition custom-precision-double.h:67
SSP class offers multiple creation and manipulation capabilities for sound speed profile.
Definition ssp-definitions.h:258
virtual double calculateSSP(double temperature, double salinity, double pressure) const
Definition ssp-definitions.h:1395
double b(double t, double p) const
Definition ssp-definitions.h:1868
bool isRedSea(const Coord &coordinates) const
Definition ssp-definitions.h:1048
static void setDebug(bool flag)
Definition ssp-definitions.h:947
friend SSP & operator-=(SSP &left, const SSP &right)
bool isSuluSea(const Coord &coordinates) const
Definition ssp-definitions.h:1071
DConstIter pressure_upper_bound(const PDouble &depth) const
Definition ssp-definitions.h:451
DConstIter upper_bound(const PDouble &depth) const
Definition ssp-definitions.h:404
DConstIter salinity_begin() const
Definition ssp-definitions.h:512
DepthMap pressure_map
Definition ssp-definitions.h:987
virtual SSP * truncate(double max_depth) const
Definition ssp-definitions.cpp:713
double d(double t, double p) const
Definition ssp-definitions.h:1863
SSPEqType getSSPEqType() const
Definition ssp-definitions.h:734
virtual bool isRandomizable() const
Definition ssp-definitions.h:571
SSP & insertValue(double depth, double temperature, double salinity, const ::std::complex< double > &pressure, double ssp_value)
double getMinDepthValue() const
Definition ssp-definitions.h:693
double getMinSSPValue() const
Definition ssp-definitions.h:707
SSP & eraseValue(const double &depth)
Definition ssp-definitions.h:679
long double depth_precision
Definition ssp-definitions.h:970
virtual SSP * fullRandomize(double ratio_incr_value) const
Definition ssp-definitions.cpp:776
DConstIter lower_bound(const PDouble &depth) const
Definition ssp-definitions.h:397
DConstRIter pressure_rend() const
Definition ssp-definitions.h:436
virtual bool isValid() const
Definition ssp-definitions.h:559
DConstIter findValue(const double &depth) const
Definition ssp-definitions.h:671
virtual SSP * create(DepthMap &ssp_map, DepthMap &temp_map, DepthMap &sal_map, DepthMap &press_map, long double depth_precision=SSP_CUSTOM_DEPTH_PRECISION) const
Definition ssp-definitions.h:321
friend const SSP operator-(const SSP &left, const SSP &right)
Definition ssp-definitions.h:1260
SSPEqType
Definition ssp-definitions.h:266
@ SSP_EQ_CHEN_MILLERO
UNESCO Chen & Miller, Wong Zu Eq.
Definition ssp-definitions.h:267
@ SSP_EQ_TEOS_10_EXACT
TEOS-10 Exact Eq (.
Definition ssp-definitions.h:269
@ SSP_EQ_TEOS_10
TEOS-10 Eq (.
Definition ssp-definitions.h:268
@ SSP_EQ_INVALID
Must always be the last.
Definition ssp-definitions.h:270
DConstIter salinity_end() const
Definition ssp-definitions.h:518
DConstRIter rend() const
Definition ssp-definitions.h:389
friend SSP & operator*=(SSP &left, const SSP &right)
static bool debug
Definition ssp-definitions.h:976
void clear()
Definition ssp-definitions.h:364
virtual SSP * create(long double depth_precision=SSP_CUSTOM_DEPTH_PRECISION) const
Definition ssp-definitions.h:310
friend SSP & operator+=(SSP &left, const double right)
double h(double z, double lat) const
Definition ssp-definitions.h:1370
DepthMap ssp_map
Definition ssp-definitions.h:982
virtual void setDepthPrecision(long double prec)
Definition ssp-definitions.cpp:548
DConstIter end() const
Definition ssp-definitions.h:377
DConstRIter rbegin() const
Definition ssp-definitions.h:383
friend::std::ostream & operator<<(::std::ostream &os, const SSP &instance)
SSP & setSSPEqType(SSPEqType eq_type)
Definition ssp-definitions.h:728
DConstRIter temperature_rend() const
Definition ssp-definitions.h:483
bool isBalticSea(const Coord &coordinates) const
Definition ssp-definitions.h:1103
DepthMap salinity_map
Definition ssp-definitions.h:992
bool isBlackSea(const Coord &coordinates) const
Definition ssp-definitions.h:1095
DConstIter pressure_begin() const
Definition ssp-definitions.h:418
double a(double t, double p) const
Definition ssp-definitions.h:1873
DConstRIter salinity_rbegin() const
Definition ssp-definitions.h:524
DConstIter begin() const
Definition ssp-definitions.h:371
friend const SSP operator+(const SSP &left, const SSP &right)
Definition ssp-definitions.h:1253
double k(double z, double lat) const
Definition ssp-definitions.h:1360
bool isCanonOcean(const Coord &coordinates) const
Definition ssp-definitions.h:1018
virtual SSP * clone() const
Definition ssp-definitions.h:344
virtual SSP * transform(const Coord &coordinates, double new_min_depth=-HUGE_VAL, double new_max_depth=HUGE_VAL, int total_depth_steps=SSP_CUSTOM_DEPTH_STEPS) const
Definition ssp-definitions.cpp:578
double getMaxSSPValue() const
Definition ssp-definitions.h:701
SSP & insertValue(double temperature, double salinity, const ::std::complex< double > &pressure, const Coord &coordinates=Coord(0.0, 0.0))
friend::std::ostream & operator>>(::std::istream &is, const SSP &instance)
int size() const
Definition ssp-definitions.h:351
DConstIter pressure_find(const PDouble &depth) const
Definition ssp-definitions.h:458
DConstIter salinity_find(const PDouble &depth) const
Definition ssp-definitions.h:552
DConstIter pressure_lower_bound(const PDouble &depth) const
Definition ssp-definitions.h:444
bool isCelebesSea(const Coord &coordinates) const
Definition ssp-definitions.h:1087
DConstRIter salinity_rend() const
Definition ssp-definitions.h:530
DConstIter temperature_lower_bound(const PDouble &depth) const
Definition ssp-definitions.h:491
DConstIter salinity_lower_bound(const PDouble &depth) const
Definition ssp-definitions.h:538
DConstRIter pressure_rbegin() const
Definition ssp-definitions.h:430
DConstIter temperature_find(const PDouble &depth) const
Definition ssp-definitions.h:505
bool isHalmaheraSea(const Coord &coordinates) const
Definition ssp-definitions.h:1079
friend SSP & operator*=(SSP &left, const double right)
double min_ssp_value
Definition ssp-definitions.h:960
virtual bool write(::std::ostream &stream_out) const
Definition ssp-definitions.cpp:504
DConstIter temperature_end() const
Definition ssp-definitions.h:471
double g(double lat) const
Definition ssp-definitions.h:1355
double gibbs(int ns, int nt, int np, double sa, double t, double p) const
Definition ssp-definitions.h:1454
friend const SSP operator*(const SSP &left, const SSP &right)
Definition ssp-definitions.h:1267
double hq(double z) const
Definition ssp-definitions.h:1365
SSPEqType ssp_eq_type
Definition ssp-definitions.h:955
double thyh(double z) const
Definition ssp-definitions.h:1350
DepthMap temperature_map
Definition ssp-definitions.h:997
virtual bool isTransformable() const
Definition ssp-definitions.h:565
DConstIter temperature_upper_bound(const PDouble &depth) const
Definition ssp-definitions.h:498
virtual SSP * create(DepthMap &ssp_map, long double depth_precision=SSP_CUSTOM_DEPTH_PRECISION) const
Definition ssp-definitions.h:330
friend SSP & operator/=(SSP &left, const double right)
friend SSP & operator/=(SSP &left, const SSP &right)
friend SSP & operator+=(SSP &left, const SSP &right)
DConstIter salinity_upper_bound(const PDouble &depth) const
Definition ssp-definitions.h:545
long double getDepthPrecision() const
Definition ssp-definitions.h:721
double g_z(double lat) const
Definition ssp-definitions.h:1381
double cw(double t, double p) const
Definition ssp-definitions.h:1881
virtual SSP * randomize(double ratio_incr_value) const
Definition ssp-definitions.cpp:814
virtual SSP * create(const SSP &copy) const
Definition ssp-definitions.h:338
DConstRIter temperature_rbegin() const
Definition ssp-definitions.h:477
bool isNEAtlanticOcean(const Coord &coordinates) const
Definition ssp-definitions.h:1025
SSP & insertValue(double depth, double ssp_value)
Definition ssp-definitions.cpp:119
double getPressureFromDepth(const Coord &coordinates, double depth) const
Definition ssp-definitions.h:1375
bool isMediterraneanSea(const Coord &coordinates) const
Definition ssp-definitions.h:1040
double max_ssp_value
Definition ssp-definitions.h:965
SSP & operator=(const SSP &x)
Definition ssp-definitions.cpp:194
friend bool operator==(const SSP &left, const SSP &right)
Definition ssp-definitions.h:1240
double getPressureCorreptions(const Coord &coordinates, double depth) const
Definition ssp-definitions.cpp:836
friend const SSP operator/(const SSP &left, const SSP &right)
Definition ssp-definitions.h:1275
double getDepthfromPressure(const Coord &coordinates, double pressure) const
Definition ssp-definitions.h:1386
friend bool operator!=(const SSP &left, const SSP &right)
Definition ssp-definitions.h:1247
double getMaxDepthValue() const
Definition ssp-definitions.h:686
bool isJapanSea(const Coord &coordinates) const
Definition ssp-definitions.h:1063
friend SSP & operator-=(SSP &left, const double right)
DConstIter pressure_end() const
Definition ssp-definitions.h:424
DConstIter at(const int i) const
Definition ssp-definitions.cpp:109
bool isAntarcticOcean(const Coord &coordinates) const
Definition ssp-definitions.h:1033
DConstIter temperature_begin() const
Definition ssp-definitions.h:465
double getDepthCorreptions(const Coord &coordinates, double pressure) const
Definition ssp-definitions.cpp:881
bool isArcticOcean(const Coord &coordinates) const
Definition ssp-definitions.h:1056
bool empty() const
Definition ssp-definitions.h:358
Provides the interface for the woss::Coord and woss::CoordZ classes.
Provides the interface for the woss::PDouble class.
Provides the interface for woss::DefHandler class.
Definitions and library for woss::Pressure class.
::std::map< PDouble, double > DepthMap
Definition ssp-definitions.h:231