[PATCH] Interpolate depth for samples that have no depth
Linus Torvalds
torvalds at linux-foundation.org
Sat Oct 24 20:37:11 PDT 2015
On Sun, 25 Oct 2015, Linus Torvalds wrote:
>
> Rather than initialize these samples to have the same depth as the
> previous one (and then perhaps getting a very sudden jump when the
> *real* depth event comes in a second later), initialize the depth
> samples to -1, and if that sample doesn't get a real depth, we'll create
> an interpolated depth.
Just as an example of the kind of change this causes, here's an extract of
diff of the git save format for the same dive from the EON Steel before
and after this change:
@@ -110,7 +110,7 @@
13:54 19.13m 180.1bar ndl=78:00
14:04 19.18m 179.57bar
14:14 19.96m 178.9bar ndl=70:00
- 14:15 19.96m
+ 14:15 19.937m
14:24 19.73m 178.37bar ndl=71:00
14:34 19.4m 177.9bar ndl=74:00
14:44 20.09m 177.29bar ndl=68:00
@@ -257,14 +257,14 @@
38:15 13.18m 120.07bar
38:25 13.5m 119.48bar
38:35 12.26m 119.64bar
- 38:39 12.26m
+ 38:39 12.044m
38:45 11.72m 28.1°C 118.89bar
38:55 11.47m 118.75bar
39:05 11.38m 118.07bar
39:15 11.1m 118.29bar
39:25 11.54m 117.78bar
39:35 12.27m 28.2°C 117.89bar
- 39:39 12.27m
+ 39:39 12.006m
39:45 11.61m 28.1°C 117.31bar
39:55 11.69m 116.65bar
40:05 11.76m 28.2°C 116.15bar
you can see how the depth for a few of the samples used to be the same as
the previous one - but those samples were actually associated with things
like a deepstop event:
event 38:39 type=14 value=1 name="deepstop"
event 39:39 type=14 value=2 name="deepstop"
and had no depth information associated with that particular sample time.
We _could_ have tried to just filter the time-only sample away entirely,
but that would have involved a fair amount of churn in the libdivecomputer
downloader, and even then we might have needed to interpolate the depth
anyway (imagine a sample that comes in with no depth, but with a sensor
pressure reading).
So changing those empty events to just do a linear interpolation seems to
be the minimal approach.
Note how this changes how the profile looks: instead of having a small
flat segment (due to the two consecutive samples with the same depth)
followed by a potentially very steep segment (due to the next depth sample
being different, and potentially very soon after the non-depth sample), we
still have the same number of samples, but now the interpolated depth
means that we get a straight line in between the two *real* depth
samples, and the middle one doesn't create a staircase effect.
Linus
More information about the subsurface
mailing list