-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c4200e
commit 54e4721
Showing
4 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
src/themachinethatgoesping/algorithms/rangecorrection/.docstrings/functions.doc.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//sourcehash: fe33432f6337ae8971ac01f79910fbd6f7a7cf3746aa10ae1a41ce8176476dc9 | ||
|
||
/* | ||
This file contains docstrings for use in the Python bindings. | ||
Do not edit! They were automatically extracted by pybind11_mkdoc. | ||
This is a modified version which allows for more than 8 arguments and includes def-guard | ||
*/ | ||
|
||
#pragma once | ||
|
||
#ifndef __DOCSTRINGS_HPP__ | ||
|
||
#define __EXPAND(x) x | ||
#define __COUNT(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, COUNT, ...) COUNT | ||
#define __VA_SIZE(...) __EXPAND(__COUNT(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)) | ||
#define __CAT1(a, b) a##b | ||
#define __CAT2(a, b) __CAT1(a, b) | ||
#define __DOC1(n1) __doc_##n1 | ||
#define __DOC2(n1, n2) __doc_##n1##_##n2 | ||
#define __DOC3(n1, n2, n3) __doc_##n1##_##n2##_##n3 | ||
#define __DOC4(n1, n2, n3, n4) __doc_##n1##_##n2##_##n3##_##n4 | ||
#define __DOC5(n1, n2, n3, n4, n5) __doc_##n1##_##n2##_##n3##_##n4##_##n5 | ||
#define __DOC6(n1, n2, n3, n4, n5, n6) __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6 | ||
#define __DOC7(n1, n2, n3, n4, n5, n6, n7) __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7 | ||
#define __DOC8(n1, n2, n3, n4, n5, n6, n7, n8) \ | ||
__doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7##_##n8 | ||
#define __DOC9(n1, n2, n3, n4, n5, n6, n7, n8, n9) \ | ||
__doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7##_##n8##_##n9 | ||
#define __DOC10(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) \ | ||
__doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7##_##n8##_##n9##_##n10 | ||
#define DOC(...) __EXPAND(__EXPAND(__CAT2(__DOC, __VA_SIZE(__VA_ARGS__)))(__VA_ARGS__)) | ||
|
||
#endif // NEW_DOC_HEADER_HPP | ||
#if defined(__GNUG__) | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wunused-variable" | ||
#endif | ||
|
||
|
||
#if defined(__GNUG__) | ||
#pragma GCC diagnostic pop | ||
#endif | ||
|
||
|
10 changes: 10 additions & 0 deletions
10
src/themachinethatgoesping/algorithms/rangecorrection/functions.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// Kiel SPDX-FileCopyrightText: 2024 Peter Urban, Ghent University | ||
// | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
#pragma once | ||
|
||
/* generated doc strings */ | ||
#include ".docstrings/functions.doc.hpp" | ||
|
||
#include " absorption.hpp" |
79 changes: 79 additions & 0 deletions
79
...hemachinethatgoesping/algorithms/rangecorrection/functions/.docstrings/absorption.doc.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
//sourcehash: f832ca529d511eb1355e2ffa7576b496727810220ef0c08ce75b8943910b56b5 | ||
|
||
/* | ||
This file contains docstrings for use in the Python bindings. | ||
Do not edit! They were automatically extracted by pybind11_mkdoc. | ||
This is a modified version which allows for more than 8 arguments and includes def-guard | ||
*/ | ||
|
||
#pragma once | ||
|
||
#ifndef __DOCSTRINGS_HPP__ | ||
|
||
#define __EXPAND(x) x | ||
#define __COUNT(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, COUNT, ...) COUNT | ||
#define __VA_SIZE(...) __EXPAND(__COUNT(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)) | ||
#define __CAT1(a, b) a##b | ||
#define __CAT2(a, b) __CAT1(a, b) | ||
#define __DOC1(n1) __doc_##n1 | ||
#define __DOC2(n1, n2) __doc_##n1##_##n2 | ||
#define __DOC3(n1, n2, n3) __doc_##n1##_##n2##_##n3 | ||
#define __DOC4(n1, n2, n3, n4) __doc_##n1##_##n2##_##n3##_##n4 | ||
#define __DOC5(n1, n2, n3, n4, n5) __doc_##n1##_##n2##_##n3##_##n4##_##n5 | ||
#define __DOC6(n1, n2, n3, n4, n5, n6) __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6 | ||
#define __DOC7(n1, n2, n3, n4, n5, n6, n7) __doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7 | ||
#define __DOC8(n1, n2, n3, n4, n5, n6, n7, n8) \ | ||
__doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7##_##n8 | ||
#define __DOC9(n1, n2, n3, n4, n5, n6, n7, n8, n9) \ | ||
__doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7##_##n8##_##n9 | ||
#define __DOC10(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10) \ | ||
__doc_##n1##_##n2##_##n3##_##n4##_##n5##_##n6##_##n7##_##n8##_##n9##_##n10 | ||
#define DOC(...) __EXPAND(__EXPAND(__CAT2(__DOC, __VA_SIZE(__VA_ARGS__)))(__VA_ARGS__)) | ||
|
||
#endif // NEW_DOC_HEADER_HPP | ||
#if defined(__GNUG__) | ||
#pragma GCC diagnostic push | ||
#pragma GCC diagnostic ignored "-Wunused-variable" | ||
#endif | ||
|
||
|
||
static const char *__doc_themachinethatgoesping_algorithms_rangecorrection_functions_calc_absorption_coefficient_db_m = | ||
R"doc(Compute the logarithmic absorption coefficient in dB/m based on | ||
Francois and Garrison (1982) [taken from Fisheries Acoustics Theory | ||
and Practice, 2nd Edition, Simmonds and MacLennan, 2005] | ||
Parameter ``frequency``: | ||
// Frequency in Hz | ||
Parameter ``depth``: | ||
// Depth in m | ||
Parameter ``speedOfSound``: | ||
// Speed of sound in m/s | ||
Parameter ``temperature``: | ||
// ITS-90 temperature in degrees Celsius | ||
Parameter ``salinity_psu``: | ||
// Salinity in PSU | ||
Parameter ``pH``: | ||
// pH | ||
Returns: | ||
double)doc"; | ||
|
||
static const char *__doc_themachinethatgoesping_algorithms_rangecorrection_functions_its90_to_its68 = | ||
R"doc(Convert temperature from ITS-68 to ITS-90 | ||
Parameter ``T90``: | ||
$Returns: | ||
double)doc"; | ||
|
||
#if defined(__GNUG__) | ||
#pragma GCC diagnostic pop | ||
#endif | ||
|
||
|
98 changes: 98 additions & 0 deletions
98
src/themachinethatgoesping/algorithms/rangecorrection/functions/absorption.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// SPDX-FileCopyrightText: 2024 Peter Urban, Ghent University | ||
// SPDX-FileCopyrightText: 2022 GEOMAR Helmholtz Centre for Ocean Research Kiel | ||
// | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
#pragma once | ||
|
||
/* generated doc strings */ | ||
#include ".docstrings/absorption.doc.hpp" | ||
|
||
#include <gswteos-10.h> | ||
#include <themachinethatgoesping/tools/helper.hpp> | ||
|
||
namespace themachinethatgoesping { | ||
namespace algorithms { | ||
namespace rangecorrection { | ||
namespace functions { | ||
|
||
// --- helper functions --- | ||
/** | ||
* @brief Convert temperature from ITS-68 to ITS-90 | ||
* | ||
* @param T90 | ||
* @return double | ||
*/ | ||
inline double its90_to_its68(double T90) | ||
{ | ||
// return (T90*T90)/gsw_t90_from_t68(T90); | ||
return T90 * 1.00024; | ||
} | ||
|
||
/** | ||
* @brief Compute the logarithmic absorption coefficient in dB/m based on Francois and Garrison | ||
* (1982) [taken from Fisheries Acoustics Theory and Practice, 2nd Edition, Simmonds and MacLennan, | ||
* 2005] | ||
* | ||
* @param frequency // Frequency in Hz | ||
* @param depth // Depth in m | ||
* @param speedOfSound // Speed of sound in m/s | ||
* @param temperature // ITS-90 temperature in degrees Celsius | ||
* @param salinity_psu // Salinity in PSU | ||
* @param pH // pH | ||
* @return double | ||
*/ | ||
double calc_absorption_coefficient_db_m(double frequency, | ||
double depth, | ||
double speedOfSound, | ||
double temperature, | ||
double salinity_psu, | ||
double pH = 8) | ||
{ | ||
// Convert frequency to kHz | ||
frequency = frequency / 1000.0; | ||
|
||
// Convert temperature from ITS-90 to ITS-68 | ||
temperature = its90_to_its68(temperature); | ||
|
||
// | ||
double temperature2 = temperature * temperature; | ||
double temperature3 = temperature2 * temperature; | ||
double depth2 = depth * depth; | ||
double frequency2 = frequency2 * frequency2; | ||
|
||
double A1 = 8.86 * std::pow(10., 0.78 * pH - 5.0) / speedOfSound; | ||
double A2 = 21.44 * salinity_psu * (1 + 0.025 * temperature) / speedOfSound; | ||
// Only for temperature | ||
double A3; | ||
if (temperature <= 20) | ||
A3 = 0.0004937 - 0.0000259 * temperature + 0.000000911 * temperature2 - | ||
0.000000015 * temperature3; | ||
else | ||
A3 = 0.0003964 - 0.00001146 * temperature + 0.000000145 * temperature2 - | ||
0.00000000065 * temperature3; | ||
|
||
double f1 = | ||
2.8 * std::sqrt(salinity_psu / 35.) * std::pow(10., 4. - (1245. / (temperature + 273.))); | ||
|
||
double f2 = 8.17 * std::pow(10., 8 - (1990. / (temperature + 273.))); | ||
f2 /= (1. + 0.0018 * (salinity_psu - 35.)); | ||
|
||
double P2 = 1 - 0.000137 * depth + 0.0000000062 * depth2; | ||
double P3 = 1 - 0.0000383 * depth + 0.00000000049 * depth2; | ||
|
||
double absorption = 0; | ||
|
||
absorption += A1 * f1 / (f1 * f1 + frequency2); | ||
absorption += A2 * P2 * f2 / (f2 * f2 + frequency2); | ||
absorption += A3 * P3; | ||
absorption *= frequency2; | ||
|
||
// Convert dB/km to dB/m | ||
return absorption / 1000.0; | ||
} | ||
|
||
} | ||
} | ||
} | ||
} |