[RFC PATCH] Make fake profile average depth come out right

Willem Ferguson willemferguson at zoology.up.ac.za
Sun Nov 3 22:51:34 UTC 2013


I hope I understand the discussion. Please forgive me if the real 
problem is really something else.

Here you can find a generalised dive diagram:
https://www.dropbox.com/s/w6fdtxmtdd6weob/diveCalc.png

Each dive comprised two vectors, one with time info, the other with 
depth info. The information about the dive is best approximated by 
joining each time-depth pair with a straight line, since these are the 
real data that we have. Under ideal circumstances the time intervals are 
fixed, but for a generailised dive profile one should probably NOT 
assume this.

Conceptually, for each time segment in the diagram:
(I skip the first line segment here because it is a special case of the 
calculations below)
1) Find the shallowest depth of each line segment. For he second segment 
d1 is the shallowest and d2 deeper.
2) Using d1 from the step above calculate the surface area of the 
rectangle above the line segment (i.e. the rectangle defined by t2 and 
t1 d1 and r2 in the drawing, not assuming fixed time increments; i.e. 
t2-t1 != t3-t2)
3) Calculate the area of the triangle immediately below the rectangle 
from step 2 above.(in this case the triangle define by d1, d2 and r2).
4) Proceed stepwise for each additional depth measurement and add each 
surface to the existing total.
5) The mean depth is the rectangle that has the same time duration as 
the polygon in the dive profile. Divide the total surface of the dive 
profile by the total time duration.

As an aside, where we dive, the rate of descent is often estimated at 
around 15-20m/min, while the ascent rate is obviously around half of 
that. So assumptions about ascent and descent rates can lead to 
inaccuracies.

If, firstly, what I say is pertinent at all to your discussion and 
secondly, if you can show me where the hooks are (e.g. dive profile data 
structures from which calculations can be made), I can write something 
that you could test.

Kind regards,
willemf



On 04/11/2013 01:06, Linus Torvalds wrote:
> On Sun, Nov 3, 2013 at 2:44 PM, Anton Lundin <glance at acc.umu.se> wrote:
>>> +/*
>>> + * Good fake dive profiles are hard.
>>> + *
>>> + * "depthtime" is the integral of the dive depth over
>>> + * time ("area" of the dive profile). We want that
>>> + * area to match the average depth (avg_d*max_t).
>>> + *
>>> + * To do that, we generate a 6-point profile:
>>> + *
>>> + *  (0, 0)
>>> + *  (t0, max_d)
>>> + *  (t1, max_d)
>>> + *  (t2, d)
>>> + *  (t3, d)
>>> + *  (max_t, 0)
>> Hmm.. These ones should be t1 to t4, not t0 to t3?
> Yes.
>
>>> + * That six-point profile gives a total area of:
>>> + *
>>> + *   (max_d*max_t) - (max_d*t1) - (max_d-d)*(t4-t3)
>> Why do you care about the max_d*t1 part? Isn't that just the accent
>> slope? There should be more factors there if we should care about all
>> the accent slopes in that formula.
> Heh. Draw it out. Yes, you can make the formula much more complex like
> yours is, but by selecting the shapes right, you get the much simpler
> one.
>
> The max_t*t1 is twice the area of the triangle generated by the
> descent, yes. But because the ascent has the same shape, you can
> actually find the *same* triangle on the ascent path. And then the
> only remaining shape to subtract from the "big rectangle" is the time
> we spend at depth "d" (which is a rectangle of size
> "(t4-t3)*(max_d*d)").
>
>> Shouldn't the whole thing look something more like:
>> (max_d*max_t) - (max_d*t1*0.5) - (max_d-d)*(t3-t2)*0.5
>> - (max_d-d)*(t4-t3) - d*(max_t-t4)*0.5 - (max_d-d)*(max_t-t4)
> Simplify it. You should get to the exact same answer. In particular,
> the same slope part:
>
>>> + * And the "same ascent/descent rates" requirement
>>> + * gives us (time per depth must be same):
>>> + *
>>> + *   t1 / max_d = (t3-t2) / (max_d-d)
>>> + *   t1 / max_d = (max_t-t4) / d
> can be used to simplify your complex expression to my simple one.
> Except I didn't do it that way, it's easier to do by just partitioning
> the shape to begin with and noticing that the (two) triangles that
> happen at ascent (first from d_max to d, and then from d to 0) fit
> with the triangle at descent.
>
>> The rest looks sane based on those assumptions, but i can't really
>> figure out why you care about the (max_d*t1) part.
> Your equation had it too, look at it. You just had the first obvious
> triangle (the "(max_d*t1*0.5)" in your equation), it's just that your
> other terms end up adding up to another triangle, and the sum of those
> is my "max_d*t1".
>
> And no, I didn't actually do the simplification, and I didn't check
> that your more complex expression is correct.. But I'm pretty sure my
> simpler one *is* correct, though.
>
>                  Linus
> _______________________________________________
> subsurface mailing list
> subsurface at hohndel.org
> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
>



More information about the subsurface mailing list