aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2016-02-26 15:16:36 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-02-27 22:31:43 +0100
commitb1c923cd5995b4826b75e9aaef83dbcff70d49f2 (patch)
tree57085d21f6a1338440485f072eb76fab1093fafc
parent563ff6bdc45832f9e3b22aaa88b7ae8f265b32c4 (diff)
downloadsubsurface-b1c923cd5995b4826b75e9aaef83dbcff70d49f2.tar.gz
If salinity is not density, add density of fresh water
There was a reported case of an import of a dive that gave a salinity of 35g/l. This is an actual salinity (an amount of salt in the water) but for subsurface the salinity is actually the density of the water. So for too small values of the salinity add the density of fresh water. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--dive.c2
-rw-r--r--dive.h2
2 files changed, 4 insertions, 0 deletions
diff --git a/dive.c b/dive.c
index bb35f4454..83ec161c6 100644
--- a/dive.c
+++ b/dive.c
@@ -1116,6 +1116,8 @@ static void fixup_water_salinity(struct dive *dive)
for_each_dc (dive, dc) {
if (dc->salinity) {
+ if (dc->salinity < 500)
+ dc->salinity += FRESHWATER_SALINITY;
sum += dc->salinity;
nr++;
}
diff --git a/dive.h b/dive.h
index ccb12e9be..cf9b19f82 100644
--- a/dive.h
+++ b/dive.h
@@ -409,6 +409,8 @@ static inline int calculate_depth_to_mbar(int depth, pressure_t surface_pressure
mbar = SURFACE_PRESSURE;
if (!salinity)
salinity = SEAWATER_SALINITY;
+ if (salinity < 500)
+ salinity += FRESHWATER_SALINITY;
specific_weight = salinity / 10000.0 * 0.981;
mbar += rint(depth / 10.0 * specific_weight);
return mbar;