mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 18:43:24 +00:00
Exclude surface intervals from sac rate calculation
We assume every sample with a depth of less than 10cm to be on the surface. This does not impact our interpolated pressures (one could assume that the diver is not breathing from the regulator when on the surface - but without air integration that's just an assumption). It also doesn't change our tank pressure coloring by sac rate as that always uses the momentary sac rate. Technically speaking this might impact the actual colors printed (as those are relative to the total sac on the dive which may go up due to this change). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
0d1f8f9a5d
commit
b577484998
1 changed files with 18 additions and 1 deletions
19
divelist.c
19
divelist.c
|
@ -320,6 +320,7 @@ static double calculate_airuse(struct dive *dive)
|
|||
static int calculate_sac(struct dive *dive)
|
||||
{
|
||||
double airuse, pressure, sac;
|
||||
int duration, i;
|
||||
|
||||
airuse = calculate_airuse(dive);
|
||||
if (!airuse)
|
||||
|
@ -327,9 +328,25 @@ static int calculate_sac(struct dive *dive)
|
|||
if (!dive->duration.seconds)
|
||||
return 0;
|
||||
|
||||
/* find and eliminate long surface intervals */
|
||||
duration = dive->duration.seconds;
|
||||
for (i = 0; i < dive->samples; i++) {
|
||||
if (dive->sample[i].depth.mm < 100) { /* less than 10cm */
|
||||
int end = i + 1;
|
||||
while (end < dive->samples && dive->sample[end].depth.mm < 100)
|
||||
end++;
|
||||
/* we only want the actual surface time during a dive */
|
||||
if (end < dive->samples) {
|
||||
end--;
|
||||
duration -= dive->sample[end].time.seconds -
|
||||
dive->sample[i].time.seconds;
|
||||
i = end + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Mean pressure in atm: 1 atm per 10m */
|
||||
pressure = 1 + (dive->meandepth.mm / 10000.0);
|
||||
sac = airuse / pressure * 60 / dive->duration.seconds;
|
||||
sac = airuse / pressure * 60 / duration;
|
||||
|
||||
/* milliliters per minute.. */
|
||||
return sac * 1000;
|
||||
|
|
Loading…
Add table
Reference in a new issue