Metadata-Version: 2.5
Name: neuralfuel
Version: 0.1
Summary: Federated learning of neural aircraft fuel-flow models: train on local flight data with fuel records, share only the model
Project-URL: Repository, https://github.com/open-aviation/neuralfuel
Project-URL: Documentation, https://github.com/open-aviation/neuralfuel/blob/main/docs/index.md
Project-URL: Issues, https://github.com/open-aviation/neuralfuel/issues
Author-email: Junzi Sun <git@junzis.com>
License-Expression: GPL-3.0-only
License-File: LICENSE
Keywords: ADS-B,QAR,aircraft performance,federated learning,flight data,fuel flow
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.12
Requires-Dist: aerox>=0.8
Requires-Dist: numpy>=2.5.5
Requires-Dist: onnx>=1.23.2
Requires-Dist: onnxruntime>=1.32.0
Requires-Dist: pandas>=3.1.1
Requires-Dist: pyarrow>=26.0.1
Requires-Dist: scipy>=1.18.1
Requires-Dist: torch>=2.15.0
Description-Content-Type: text/markdown

# neuralfuel

neuralfuel provides open-source neural fuel models for more than 20 aircraft types. It also supports federated learning of these models.

Detailed flight data with fuel measurements, such as quick access recorder (QAR) data, can be difficult to share for privacy reasons. A small neural network trained on those data can often be shared.

The models estimate total fuel flow from Mach number, pressure altitude, aircraft mass, energy-rate variables and static air temperature. Training uses physical constraints. The [model guide](https://github.com/open-aviation/neuralfuel/blob/v0.1/docs/model.md) describes the inputs, networks and constraints.

## Install

The Python package includes the shared models in PyTorch and ONNX formats. Install it in a Python 3.12 or newer environment, then list the available models.

```sh
python -m pip install neuralfuel
neuralfuel models
```

## Estimate fuel flow

For an A320, `load("a320")` selects the CFM56-5B recorder model. This example estimates fuel flow in steady, level cruise at Mach 0.78, 37,000 ft, 62 tonnes and a static air temperature of 225 K.

```python
from neuralfuel.inference import fuel_flow
from neuralfuel.model import load

a320 = load("a320")
flow_kgh = fuel_flow(a320, mach=0.78, alt_ft=37000, mass_kg=62000, sat_k=225.0)
```

To select a model trained on public ACARS reports, use `tier="osint"`. For aircraft with an ACARS model and no recorder model, omitting the tier loads that model and emits an `OsintTierWarning` with its accuracy and phase coverage. [Model selection and inputs](https://github.com/open-aviation/neuralfuel/blob/v0.1/docs/use.md)

```python
distilled = load("a320", tier="acropole")
b738 = load("b738", tier="osint")
a20n = load("a20n", tier="osint")  # All engines
a20n_leap = load("a20n", tier="osint", engine="leap_1a")  # LEAP-1A only
```

## Models

The Python package includes **29 models for 21 aircraft types**. Choose a model by aircraft type and training source.

- **Recorder** (`recorder`). One A320 CFM56-5B model learns from fuel flow measured on board the aircraft. It supports clean climb, cruise and descent.
- **Direct ACARS** (`osint`). Twenty models learn from fuel burned between successive ACARS reports. Each model trains on climb and cruise together. A second stage fits descent while keeping the climb and cruise fit fixed. Climb and cruise are supported within the documented coverage. Descent is experimental. [Training method](https://github.com/open-aviation/neuralfuel/blob/v0.1/docs/training.md#direct-acars-interval-training)
- **Acropole distilled** (`acropole`). These experimental models learn from Acropole predictions for aircraft types represented in its quick access recorder (QAR) training data. The table lists the reference engine used for each fit. [Loading and evaluating the Acropole models](https://github.com/open-aviation/neuralfuel/blob/v0.1/docs/acropole.md)

The recorder network learns fuel flow directly. The ACARS network learns a correction to the fuel flow estimated from drag in steady flight. The model then adjusts fuel flow for climbing, descending or changing speed. [Network architecture and physical constraints](https://github.com/open-aviation/neuralfuel/blob/v0.1/docs/model.md)

![A. Five flight inputs feed the recorder network, with a separate temperature correction and five training penalties. B. A small ACARS network corrects steady-flight fuel flow before the model applies the climb or descent response.](https://raw.githubusercontent.com/open-aviation/neuralfuel/v0.1/docs/img/model.png)

### Supported aircraft types

In the **Direct ACARS fits** column, “All engines” means one model trained across the engine families present in the data for that aircraft type. Each named family has a separate fit. Aircraft model cards report errors against measured fuel burn on held-out aircraft. [ACARS results by aircraft and engine](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/README.md)

| ICAO | Aircraft | Recorder fit | Direct ACARS fits | Acropole distilled |
|---|---|---|---|---|
| [A319](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/a319/README.md) | Airbus A319 | — | CFM56-5B | — |
| [A320](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/a320/README.md) | Airbus A320 | CFM56-5B | All engines, CFM56-5B, V2500 | [CFM56-5B4/P](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/a320/README.md#acropole-distilled) |
| [A321](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/a321/README.md) | Airbus A321 | — | All engines | — |
| [A20N](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/a20n/README.md) | Airbus A320neo | — | All engines, LEAP-1A, PW1100G | — |
| [A21N](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/a21n/README.md) | Airbus A321neo | — | PW1100G | — |
| [A332](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/a332/README.md) | Airbus A330-200 | — | All engines | [Trent 772](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/a332/README.md#acropole-distilled) |
| [A333](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/a333/README.md) | Airbus A330-300 | — | All engines | — |
| [A359](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/a359/README.md) | Airbus A350-900 | — | Trent XWB | — |
| [AT76](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/at76/README.md) | ATR 72-600 | — | — | [PW127M-HS568F](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/at76/README.md) |
| [B737](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/b737/README.md) | Boeing 737-700 | — | CFM56-7B | — |
| [B738](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/b738/README.md) | Boeing 737-800 | — | CFM56-7B | [CFM56-7B26E](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/b738/README.md#acropole-distilled) |
| [B739](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/b739/README.md) | Boeing 737-900 | — | CFM56-7B | — |
| [B744](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/b744/README.md) | Boeing 747-400 | — | All engines | — |
| [B772](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/b772/README.md) | Boeing 777-200 / 200ER | — | All engines | — |
| [B77W](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/b77w/README.md) | Boeing 777-300ER | — | GE90-115B | — |
| [B789](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/b789/README.md) | Boeing 787-9 | — | All engines | — |
| [B78X](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/b78x/README.md) | Boeing 787-10 | — | All engines | — |
| [CRJ7](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/crj7/README.md) | Bombardier CRJ700 | — | — | [CF34-8C5B1](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/crj7/README.md) |
| [CRJX](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/crjx/README.md) | Bombardier CRJ1000 | — | — | [CF34-8C5A1](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/crjx/README.md) |
| [E170](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/e170/README.md) | Embraer E170 | — | — | [CF34-8E5](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/e170/README.md) |
| [E190](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/e190/README.md) | Embraer E190 | — | — | [CF34-10E5](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/e190/README.md) |

## Accuracy and coverage

On 110 A320 CFM56-5B test flights, the recorder model’s mean absolute percentage error was **2.42%** across all 10-second blocks and **1.76%** in cruise. Summed over a flight, the median absolute fuel error was **0.37%**. [A320 recorder validation](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/a320/README.md#accuracy-on-the-test-split)

![Predicted versus measured fuel flow on A320 recorder test blocks, alongside the distribution of fuel errors per flight.](https://raw.githubusercontent.com/open-aviation/neuralfuel/v0.1/docs/img/accuracy.png)

For recorder and ACARS models, use `predict(model, x, coverage=True)` to check a prediction. It labels each input as `data` (within training-data coverage), `model` (within the model envelope only), or `outside`. [Coverage definitions](https://github.com/open-aviation/neuralfuel/blob/v0.1/docs/use.md#coverage)

## Physical constraints

In powered flight, recorder training favours a convex fuel-flow curve against Mach and higher flow as mass or energy demand increases. At high Mach, penalties capture drag rise and favour decreasing specific air range (distance per kilogram of fuel). [Recorder constraints](https://github.com/open-aviation/neuralfuel/blob/v0.1/docs/model.md#loss-and-physical-constraints) · [Cruise performance example](https://github.com/open-aviation/neuralfuel/blob/v0.1/examples/02_cruise_performance.py)

The ACARS model adds fuel for a climb or acceleration. In a constant-speed descent, gravity helps overcome drag and predicted flow falls toward idle. [ACARS model equations](https://github.com/open-aviation/neuralfuel/blob/v0.1/docs/model.md#direct-acars-network)

![A320 specific air range against Mach at three altitudes and three masses. Solid curves indicate data coverage. Dashed curves extend to the model’s maximum operating Mach of 0.82.](https://raw.githubusercontent.com/open-aviation/neuralfuel/v0.1/docs/img/sar_mach.png)

## Comparing the A320 models

All three fits can be evaluated against the same A320 CFM56-5B recorder measurements. The table gives mean absolute percentage error on clean-flight 10-second blocks at or above 10,000 ft. Acropole’s original training flights are undisclosed, so overlap with this test set is unknown. [Measured comparison and sample counts](https://github.com/open-aviation/neuralfuel/blob/v0.1/models/a320/acropole-validation.md)

| Model | Climb | Cruise | Descent |
|---|---:|---:|---:|
| Recorder | 1.23% | 1.76% | 7.03% |
| Direct ACARS | 6.30% | 1.96% | 22.81% |
| Acropole distilled | 2.59% | 3.72% | 14.59% |

The figure compares the ACARS and recorder **predictions** as Mach, altitude and climb rate vary. The curves agree closely in level flight and diverge in steep climb and descent. For a comparison with the AeroX CFM56-5B fuel model, run `neuralfuel compare --model a320`. [A320 comparison example](https://github.com/open-aviation/neuralfuel/blob/v0.1/examples/10_osint_tier.py) · [AeroX comparison](https://github.com/open-aviation/neuralfuel/blob/v0.1/examples/09_compare_aerox.py)

![A320 CFM56-5B cruise predictions and ACARS-to-recorder differences. A constant-speed sweep at Mach 0.76 compares descent, level flight and climb. Line styles indicate coverage.](https://raw.githubusercontent.com/open-aviation/neuralfuel/v0.1/docs/img/osint_tier.png)

## Examples and documentation

Clone the repository to run the examples or train a model with synthetic data. [Examples](https://github.com/open-aviation/neuralfuel/blob/v0.1/examples/README.md) · [Training quick start](https://github.com/open-aviation/neuralfuel/blob/v0.1/docs/quickstart.md) · [Documentation index](https://github.com/open-aviation/neuralfuel/blob/v0.1/docs/index.md)

```sh
git clone https://github.com/open-aviation/neuralfuel
cd neuralfuel
uv sync
uv run examples/01_predict.py
```

## Contributing to the federated model training

You can continue training a shared recorder model on local flight data or train a new recorder model. You share the weights, an ONNX export, the run record, an aggregate validation report and a manifest. The raw flight data stays with you. Maintainers check each contribution before combining compatible models into the next shared model. [Federated training workflow and quality checks](https://github.com/open-aviation/neuralfuel/blob/v0.1/docs/federated.md)

To contribute a model trained on your own data, see [CONTRIBUTING.md](https://github.com/open-aviation/neuralfuel/blob/v0.1/CONTRIBUTING.md).

### Contributing with an AI coding agent

The agent instructions give the complete workflow with exact commands. [AGENTS.md](https://github.com/open-aviation/neuralfuel/blob/v0.1/AGENTS.md)

> Read AGENTS.md. Then write an adapter for my data file, check it, train a model and prepare a contribution.

The agent works from two commands that summarize your data locally. It can write and correct the adapter without reading individual flight records.

- `neuralfuel profile` reports column names, types, missing fractions and value ranges for measurement columns.
- `neuralfuel check` checks the converted measurements against physical limits. When a value is out of range, the report names the column so the agent can check its units and scale factor.

Every command supports `--json` and uses fixed exit codes.

## Licence

NeuralFuel is licensed under GPL-3.0-only. [Licence text](https://github.com/open-aviation/neuralfuel/blob/v0.1/LICENSE)
