summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-08 21:14:00 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-08 21:23:45 -0800
commit07b74007f1731b6557ec05300d5734970fb9d29c (patch)
treedf94944ac8adfb679b8f88fa2e2937854db3fff3 /profile.c
parent02844c3a10f3e7785aa81080e1c91b64c4d5dfd8 (diff)
downloadsubsurface-07b74007f1731b6557ec05300d5734970fb9d29c.tar.gz
Correct partial pressure calculations
Regardless what the dive computer tells us, don't believe that pO2 was higher than the ambient pressure. This gives much more realistic values. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/profile.c b/profile.c
index e56a1459d..290638d6a 100644
--- a/profile.c
+++ b/profile.c
@@ -1879,9 +1879,11 @@ static struct plot_info *create_plot_info(struct dive *dive, struct divecomputer
/* we have an O2 partial pressure in the sample - so this
* is likely a CC dive... use that instead of the value
* from the cylinder info */
+ double po2 = entry->po2 > amb_pressure ? amb_pressure : entry->po2;
double ratio = (double)fhe / (1000.0 - fo2);
- entry->phe = (amb_pressure - entry->po2) * ratio;
- entry->pn2 = amb_pressure - entry->po2 - entry->phe;
+ entry->phe = (amb_pressure - po2) * ratio;
+ entry->pn2 = amb_pressure - po2 - entry->phe;
+ entry->po2 = po2;
} else {
entry->po2 = fo2 / 1000.0 * amb_pressure;
entry->phe = fhe / 1000.0 * amb_pressure;