Commit graph

3 commits

Author SHA1 Message Date
Linus Torvalds
b62e63650a Fix SAC calculations for dives without any samples
We computed a made-up average depth based on the maximum depth, and used
that.  That's questionable even if we didn't have any explicit average
depth to begin with, but it's particularly wrong if we did have an
explicit average depth to use.

Now, admittedly we have no way to actually create fake dives like this
with a particular average depth, so this really doesn't make any
difference in real life.  But we should do this right.

Also, make the XML be in the format that subsurface actually saves
things in (mainly things like cylinder sizes having an extra decimal
place, but also ordering of XML elements).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-24 11:25:44 -08:00
Linus Torvalds
6d548d2028 Correctly calculate SAC rate in the presense of surface events
This assumes that you are not breathing your cylinders while at the
surface, which may or may not be correct, but is usually the right
thing.  Regardless, we're better off giving a conservative (higher) SAC
rate estimate for a diver that breathes his cylinder at the surface too
than giving an artificially low one because the diver ended up using his
snorkel and we didn't take that into account.

NOTE! This basically calculates a better duration and average depth than
the ones we end up showing in the dive list.  Maybe we should actually
show this "no-surface-time" duration and average depth instead of the
ones we do show?

That's a separate question, though.

Added a test-case for the surface case to the sac-test.xml dives.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-24 11:09:52 -08:00
Linus Torvalds
f4bf16d5db Fix up SAC calculations for ATM/bar confusion
We even documented that we did SAC in bar*l/min, but the "S" in SAC
stands for "Surface".  So we should normalize SAC rate to surface
pressure, not one bar.

It's a tiny 1% difference, and doesn't actually matter in practice, but
it's noticeable when you want to explicitly test for SAC-rate by
creating a test-dive that averages exactly 10m.  Suddenly you don't get
the round numbers you expect.

[ Side note: 10m is not _exactly_ one extra atmosphere according to our
  calculations, but it's darn close in sea water: the standard salinity
  of 1.03 kg/l together with the standard acceleration of 9.81m/s^2
  gives an additional pressure of 1.01 bar, which is within a fraction
  of a percent of one ATM.

  Of course, divers have likely chosen that value exactly for the math
  to come out that way, since the true average salinity of seawater is
  actually slightly lower ]

So here's a few test-dives, along with the SAC rate fixup to make them
look right.

(There's also a one-liner to dive.c that makes the duration come out
right if the last sample has a non-zero depth, and the previous sample
did not: one of my original test-dives did the "average 10m depth" by
starting at 0 and ending at 20m, and dive.c got a tiny bit confused
about that ;)

[ The rationale for me testing our SAC rate calculations in the first
  place was that on snorkkeli.net user "Poltsi" reported that our SAC rate
  calculations differ from the ones that Suunto DM4 reports. So I wanted
  to verify that we did things right.

  Note that Poltsi reported differences larger than the difference of
  BAR/ATM, so this is not the cause. I'll continue to look at this. ]

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-02-24 10:49:26 -08:00