summaryrefslogtreecommitdiffstats
path: root/core/divelist.h
diff options
context:
space:
mode:
authorGravatar willemferguson <willemferguson@zoology.up.ac.za>2018-11-10 13:49:52 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-11-16 16:56:42 -0800
commit1aef22116c0f0d4a6675225ab1b896715f3e9212 (patch)
tree8b68d91db1aaceb4813119952f8ae03357a48e7f /core/divelist.h
parent1b77255807b9c11b1a1f6d3d504ccf2ade1d1d52 (diff)
downloadsubsurface-1aef22116c0f0d4a6675225ab1b896715f3e9212.tar.gz
More accurate CNS calculations (following comments on github)
Update table of maximum oxygen exposure durations, used in CNS calulations. This table shows the official NOAA maximum O2 exposure limits (in seconds) for different PO2 values. It also gives slope values for linear interpolation for intermediate PO2 values between the tabulated PO2 values in the 1st column. Top & bottom rows are inserted that are not in the NOAA table: (1) For PO2 > 1.6 the same slope value as between 1.5 & 1.6 is used. This exptrapolation for PO2 > 1.6 likely gives an underestimate above 1.6 but is better than the value for PO2=1.6 (45 min). (2) The NOAA table only tabulates values for PO2 >= 0.6. Since O2-uptake occurs down to PO2=0.5, the same slope is used as for 0.7 > PO2 > 0.6. This gives a conservative estimate for 0.6 > PO2 > 0.5. To preserve the integer structure of the table, all slopes are given as slope*10: divide by 10 to get the valid slope. The columns below are: po2 (mbar), Maximum Single Exposure (seconds), single_slope, Maximum 24 hour Exposure (seconds), 24h_slope */ Then update Calculations of the CNS for a single dive - this only takes the first divecomputer into account. The previous version of the code did a table lookup and used the max O2 exposure for the next-higher PO2 category. This gave a shorter max O2 exposure time and a higher CNS contribution for a specific dive segment, resulting in a slightly conservative value of CNS, often some 2 - 3 % too high. This code does an interpolation for PO2 values inbetween PO2 entries in the lookup table and therefore results in a more accurate maximum O2 exposure time for that PO2. The maximum O2 exposure duration for each segment is also calculated based on the mean depth of the two samples (start & end) that define each segment. The CNS contribution of each segment is found by dividing the time duration of the segment by its maximum exposure duration. The contributions of all segments of the dive are summed to get the total CNS% value. This is a partial implementation of the proposals in Erik Baker's document "Oxygen Toxicity Calculations" */ Overall, this PR does not radically alter the existing CNS calculation, it only makes it more accurate and more consistent by doing interpolation and by using mean segment depth to find PO2. Signed-off-by: willemferguson <willemferguson@zoology.up.ac.za>
Diffstat (limited to 'core/divelist.h')
-rw-r--r--core/divelist.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/core/divelist.h b/core/divelist.h
index 0f944fe34..94774616e 100644
--- a/core/divelist.h
+++ b/core/divelist.h
@@ -60,6 +60,8 @@ int get_dive_id_closest_to(timestamp_t when);
void clear_dive_file_data();
void clear_table(struct dive_table *table);
+typedef enum {PO2VAL, SINGLE_EXP, SINGLE_SLOPE, DAILY_EXP, DAILY_SLOPE, NO_COLUMNS} cns_table_headers;
+
#ifdef DEBUG_TRIP
extern void dump_selection(void);
extern void dump_trip_list(void);