# wouyang26/idl_project_38 architecture

> Architecture diagram of the GitHub repository wouyang26/idl_project_38, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wouyang26/idl_project_38
- Repository: https://github.com/wouyang26/idl_project_38

## Overview

This repository combines a PyTorch port of a drone-flight energy prediction workflow with the original flight simulation and risk-analysis code. The main workflow prepares flight data and splits, trains or loads a TCN/LSTM model, then evaluates power and regime-level energy error; plotting and checkpoint conversion support that workflow. A separate simulation path models quadrotor motion under wind and includes energy-model and risk components. The README documents the port’s capabilities; some links in the older simulation branch are supported only by the source index, so unsampled internals are not expanded.

Main entry points: [`evaluate_torch.py`](https://github.com/wouyang26/idl_project_38/blob/main/evaluate_torch.py) (Torch evaluation), [`data_utils.py`](https://github.com/wouyang26/idl_project_38/blob/main/data_utils.py) (Flight preprocessing), [`sim.py`](https://github.com/wouyang26/idl_project_38/blob/main/sim.py) (Simulation entry), [`train_torch.py`](https://github.com/wouyang26/idl_project_38/blob/main/train_torch.py) (Model training)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Flight data"]
  node_flight_data["Flight records<br/>[data_utils.py]"]
  node_metar["METAR density<br/>[MetarHandler.py]"]
  node_preprocessing["Flight preprocessing<br/>[data_utils.py]"]
  node_flight_splits["Flight splits<br/>[splits.py]"]
  node_torch_tensors["Tensor preparation<br/>[torch_data.py]"]
end

subgraph group_energy["Energy modeling"]
  node_torch_model["TCN and LSTM<br/>[torch_model.py]"]
  node_keras_model["Legacy energy model"]
  node_power_model["Analytic power model<br/>[liu_model.py]"]
  node_pretrained["Pretrained weights"]
end

subgraph group_analysis["Training and evaluation"]
  node_training["Model training<br/>[train_torch.py]"]
  node_evaluation["Torch evaluation<br/>[evaluate_torch.py]"]
  node_legacy_evaluation["Legacy evaluation<br/>[evaluation.py]"]
  node_plots["Result plots<br/>[plot_results.py]"]
end

subgraph group_simulation["Simulation and risk"]
  node_quad_sim["Quadrotor simulation<br/>[QuadSim.py]"]
  node_wind["Wind field and gusts<br/>[windfield.py]"]
  node_sim_entry["Simulation entry<br/>[sim.py]"]
  node_risk["Risk analysis<br/>[Risk.py]"]
end

node_user(("Engineer"))
node_weather_service["Weather service"]
node_flight_operator(("Simulation user"))

node_user -->|"trains model"| node_training
node_user -->|"scores flights"| node_evaluation
node_flight_data -->|"provides records"| node_preprocessing
node_preprocessing -->|"gets density"| node_metar
node_metar -->|"downloads observations"| node_weather_service
node_preprocessing -->|"supplies flight ranges"| node_flight_splits
node_preprocessing -->|"provides processed data"| node_torch_tensors
node_flight_splits -->|"selects flights"| node_training
node_torch_tensors -->|"provides batches"| node_training
node_torch_model -->|"is optimized by"| node_training
node_training -->|"writes checkpoints"| node_pretrained
node_preprocessing -->|"provides flight data"| node_evaluation
node_flight_splits -->|"selects evaluation set"| node_evaluation
node_torch_tensors -->|"prepares model inputs"| node_evaluation
node_torch_model -->|"predicts power"| node_evaluation
node_pretrained -->|"loads weights"| node_evaluation
node_evaluation -->|"provides comparisons"| node_plots
node_preprocessing -->|"provides flight data"| node_legacy_evaluation
node_keras_model -->|"predicts power"| node_legacy_evaluation
node_power_model -->|"computes analytic estimates"| node_legacy_evaluation
node_flight_operator -.->|"runs simulation"| node_sim_entry
node_sim_entry -->|"uses simulator"| node_quad_sim
node_quad_sim -->|"queries wind"| node_wind
node_sim_entry -->|"uses risk analysis"| node_risk
node_sim_entry -->|"uses energy model"| node_keras_model
node_sim_entry -->|"uses power model"| node_power_model
node_sim_entry -->|"uses evaluation"| node_legacy_evaluation

click node_flight_data "https://github.com/wouyang26/idl_project_38/blob/main/data_utils.py"
click node_metar "https://github.com/wouyang26/idl_project_38/blob/main/MetarHandler.py"
click node_preprocessing "https://github.com/wouyang26/idl_project_38/blob/main/data_utils.py"
click node_flight_splits "https://github.com/wouyang26/idl_project_38/blob/main/splits.py"
click node_torch_tensors "https://github.com/wouyang26/idl_project_38/blob/main/torch_data.py"
click node_torch_model "https://github.com/wouyang26/idl_project_38/blob/main/torch_model.py"
click node_keras_model "https://github.com/wouyang26/idl_project_38/blob/main/deep_energy_model.py"
click node_power_model "https://github.com/wouyang26/idl_project_38/blob/main/liu_model.py"
click node_training "https://github.com/wouyang26/idl_project_38/blob/main/train_torch.py"
click node_evaluation "https://github.com/wouyang26/idl_project_38/blob/main/evaluate_torch.py"
click node_legacy_evaluation "https://github.com/wouyang26/idl_project_38/blob/main/evaluation.py"
click node_plots "https://github.com/wouyang26/idl_project_38/blob/main/plot_results.py"
click node_pretrained "https://github.com/wouyang26/idl_project_38/tree/main/models_torch"
click node_quad_sim "https://github.com/wouyang26/idl_project_38/blob/main/QuadSim.py"
click node_wind "https://github.com/wouyang26/idl_project_38/blob/main/windfield.py"
click node_sim_entry "https://github.com/wouyang26/idl_project_38/blob/main/sim.py"
click node_risk "https://github.com/wouyang26/idl_project_38/blob/main/Risk.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_flight_data,node_metar,node_preprocessing,node_flight_splits,node_torch_tensors,node_flight_operator toneBlue
class node_torch_model,node_keras_model,node_power_model,node_pretrained toneAmber
class node_training,node_evaluation,node_legacy_evaluation,node_plots toneMint
class node_quad_sim,node_wind,node_sim_entry,node_risk toneRose
class node_user,node_weather_service toneIndigo
```

## Components

### Flight data

- [Flight records](https://github.com/wouyang26/idl_project_38/blob/main/data_utils.py): `data_utils.py`
- [METAR density](https://github.com/wouyang26/idl_project_38/blob/main/MetarHandler.py): `MetarHandler.py`
- [Flight preprocessing](https://github.com/wouyang26/idl_project_38/blob/main/data_utils.py): `data_utils.py`
- [Flight splits](https://github.com/wouyang26/idl_project_38/blob/main/splits.py): `splits.py`
- [Tensor preparation](https://github.com/wouyang26/idl_project_38/blob/main/torch_data.py): `torch_data.py`

### Energy modeling

- [TCN and LSTM](https://github.com/wouyang26/idl_project_38/blob/main/torch_model.py): `torch_model.py`
- [Legacy energy model](https://github.com/wouyang26/idl_project_38/blob/main/deep_energy_model.py): `deep_energy_model.py`
- [Analytic power model](https://github.com/wouyang26/idl_project_38/blob/main/liu_model.py): `liu_model.py`
- [Pretrained weights](https://github.com/wouyang26/idl_project_38/tree/main/models_torch): `models_torch`

### Training and evaluation

- [Model training](https://github.com/wouyang26/idl_project_38/blob/main/train_torch.py): `train_torch.py`
- [Torch evaluation](https://github.com/wouyang26/idl_project_38/blob/main/evaluate_torch.py): `evaluate_torch.py`
- [Legacy evaluation](https://github.com/wouyang26/idl_project_38/blob/main/evaluation.py): `evaluation.py`
- [Result plots](https://github.com/wouyang26/idl_project_38/blob/main/plot_results.py): `plot_results.py`

### Simulation and risk

- [Quadrotor simulation](https://github.com/wouyang26/idl_project_38/blob/main/QuadSim.py): `QuadSim.py`
- [Wind field and gusts](https://github.com/wouyang26/idl_project_38/blob/main/windfield.py): `windfield.py`
- [Simulation entry](https://github.com/wouyang26/idl_project_38/blob/main/sim.py): `sim.py`
- [Risk analysis](https://github.com/wouyang26/idl_project_38/blob/main/Risk.py): `Risk.py`

### Other components

- **Engineer**
- **Weather service**
- **Simulation user**

## Connections

- Engineer → Model training: trains model (evidence: `README.md`)
- Engineer → Torch evaluation: scores flights (evidence: `README.md`)
- Flight records → Flight preprocessing: provides records (evidence: `data_utils.py`)
- Flight preprocessing → METAR density: gets density (evidence: `data_utils.py`)
- METAR density → Weather service: downloads observations (evidence: `MetarHandler.py`)
- Flight preprocessing → Flight splits: supplies flight ranges (evidence: `splits.py`)
- Flight preprocessing → Tensor preparation: provides processed data (evidence: `torch_data.py`)
- Flight splits → Model training: selects flights (evidence: `train_torch.py`)
- Tensor preparation → Model training: provides batches (evidence: `train_torch.py`)
- TCN and LSTM → Model training: is optimized by (evidence: `train_torch.py`)
- Model training → Pretrained weights: writes checkpoints (evidence: `README.md`)
- Flight preprocessing → Torch evaluation: provides flight data (evidence: `evaluate_torch.py`)
- Flight splits → Torch evaluation: selects evaluation set (evidence: `evaluate_torch.py`)
- Tensor preparation → Torch evaluation: prepares model inputs (evidence: `evaluate_torch.py`)
- TCN and LSTM → Torch evaluation: predicts power (evidence: `evaluate_torch.py`)
- Pretrained weights → Torch evaluation: loads weights (evidence: `README.md`)
- Torch evaluation → Result plots: provides comparisons (evidence: `plot_results.py`)
- Flight preprocessing → Legacy evaluation: provides flight data (evidence: `evaluation.py`)
- Legacy energy model → Legacy evaluation: predicts power (evidence: `evaluation.py`)
- Analytic power model → Legacy evaluation: computes analytic estimates (evidence: `evaluation.py`)
- Simulation user → Simulation entry: runs simulation
- Simulation entry → Quadrotor simulation: uses simulator (evidence: `sim.py`)
- Quadrotor simulation → Wind field and gusts: queries wind (evidence: `QuadSim.py`)
- Simulation entry → Risk analysis: uses risk analysis (evidence: `sim.py`)
- Simulation entry → Legacy energy model: uses energy model (evidence: `sim.py`)
- Simulation entry → Analytic power model: uses power model (evidence: `sim.py`)
- Simulation entry → Legacy evaluation: uses evaluation (evidence: `sim.py`)
