igc-xc-score icon indicating copy to clipboard operation
igc-xc-score copied to clipboard

Moving average / flight detection

Open vicb opened this issue 3 years ago • 4 comments

I think that the moving average could be implemented much more efficiently by only adding the new point and removing the old from a long running sum instead of recomputing the complete sum for every single point.

I think there is also a bug as the sums get divided by the number of samples instead of the time.

It would be great if the flight definitions are passed as an argument instead of using global variables.

Maybe it would be nice to move this code to a separate library ?

vicb avatar Mar 26 '21 04:03 vicb

All the points are valid :smile: But the launch/landing detection is not on the time critical path, this will be barely noticeable I think I will leave this for an eventual 1.7

mmomtchev avatar Mar 26 '21 16:03 mmomtchev

I stumbled across the flight detection:

const definitionFlight = {
    t: 60,
    x0: 1.5,
    xt: 5,
    z0: 0.05,
    zt: 0.9
};

What does xt and zt mean? It's not described in he comment of the file. t would imply time but in the code it's compared to hma & vma which would not make sense if it's a time value. What am I missing?

JEK58 avatar May 08 '22 18:05 JEK58

Launch detection requires that the horizontal and vertical moving averages raise above xt/zt and then stay above x0/z0 for at least t seconds - the launch is considered to have happened at the xt/zt.

It is probably t for threshold or maybe t for take-off - I don't remember anymore.

mmomtchev avatar May 09 '22 08:05 mmomtchev

Thanks for clearing things up!

JEK58 avatar May 12 '22 13:05 JEK58