Skip to content

fix(performance): fuel flow derived from aircraft_mass is no longer one point late - #79

Merged
ramondalmau merged 1 commit into
devfrom
fix/mass-derived-fuel-flow
Oct 22, 2026
Merged

ramondalmau merged 1 commit into
devfrom
fix/mass-derived-fuel-flow

Conversation

@ramondalmau

Copy link
Copy Markdown
Collaborator

Problem (audit D3)

When an operator sends the aircraft mass along the trajectory but no fuel flow, PyNEATS
derives the fuel flow from the mass decrease: fuel burned in a segment = mass at its start
minus mass at its end, divided by its duration.

The code subtracted the PREVIOUS mass instead of the NEXT one, so every value was one point
late. Example, flight EAF2143 (one point per minute):

Time Mass Correct fuel flow Before this fix
18:17 66,995 kg (66,995 - 66,893)/60 = 1.70 0 (no previous)
18:18 66,893 kg 1.68 1.70
18:19 66,793 kg 1.29 1.68

Consequences:

  • Total fuel and CO2 too low: the last segment's fuel was lost (-0.03 % to -0.67 % on the
    5 test flights).
  • Per-point values wrong: up to +107 % to +287 % at single points in the descent (top of
    descent, level changes). NOx, CO, HC, nvPM and the contrail model work point by point, so
    their results were affected too.

Only flights with an operator mass column and no fuel flow column are affected. Flights
computed from BADA alone, or with operator fuel flow, are unchanged.

Fix

fuel_flow[i] = (mass[i] - mass[i+1]) / duration of segment i. The total fuel burn now equals
exactly the mass lost during the flight.

Test data (golden outputs)

Only the 13 flight records that send mass without fuel flow are updated:
aircraft_mass_col (5 flights), mixed_columns (FDX5067), aggregated (tc_mass_* and
tc_perf_no_ff* cases). Every other record is byte-identical to before (checked by
regenerating all golden outputs on dev and on this branch: only these 13 differ).

Checks

  • 4 new tests (tests/test_mass_derived_fuel_flow.py); 3 fail on the old code.
  • Full test suite: 329 passed, 0 failed.
  • Independent review: no code defects.
  • Audit D3 closed with the measured effect.

Not in this PR: when the low-speed filter removes points, segment durations are not
recomputed (I9, part of the parked low-speed filter work).

…ne point late

The fuel burned over segment i (t[i] -> t[i+1]) is mass[i] - mass[i+1].
The code used mass[i-1] - mass[i] over the forward duration: every value
one point late, 0 at the first point, the last segment's fuel lost, and
the wrong duration when steps are uneven (audit D3). Only flights with an
AO aircraft_mass column and no fuel_flow are affected.

Measured on the 5 golden aircraft_mass_col flights (BADA4, 60 s grid):
total fuel was 0.03-0.67 % low; single points were off by up to 107-287 %
in the descent (top of descent, level changes), which reaches the per-point NOx/CO/HC/nvPM indices and
the CoCiP fuel per metre. Now the total burn equals mass[0] - mass[-1].

Golden outputs: only the 13 flight records with aircraft_mass and no
fuel_flow are replaced (aircraft_mass_col 5/5, mixed_columns FDX5067,
aggregated tc_mass_* and tc_perf_no_ff*); every other record is
unchanged. Regenerated with scripts/create_golden_outputs.py on this
branch; a run on dev showed the other records are unaffected.

Tests: alignment with uneven steps, total = mass drop, no negative flow,
provided fuel_flow kept. The first three fail on the previous code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ramondalmau
ramondalmau merged commit db7d6e1 into dev Oct 22, 2026
6 checks passed
@ramondalmau
ramondalmau deleted the fix/mass-derived-fuel-flow branch October 22, 2026 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant