learn-codebase session · efficiency_codebase

Date: 2026-07-10

Tool: Claude Code, learn-codebase skill

Focus: general exploration · data-flow tour of Optimal_Routing_Benefits → analysis/proximity_analysis

Mina

efficiency_codebase please. my goal is general exploration

Claude

Great — this is a substantial codebase. Before I start peppering you with questions, let me get oriented and set up your learning journal.

Journal created at efficiency_codebase/.claude/learning-journal.md. ✅

Now let me orient you before we dive in. Here's what I see at a glance:

efficiency_codebase/
├── CONTEXT.md                          ← glossary of domain terms
├── ARCHITECTURE_SUMMARY_AND_REVIEW.md  ← detailed architecture review
├── Optimal_Routing_Benefits/           ← reusable scientific-computing foundation
│   ├── src/                            ← reusable modules (~55 files, ~12k lines)
│   ├── scripts/                        ← batch jobs (~389 files, ~55k lines)
│   └── processing_scripts/             ← pipelines (~105 files, ~23k lines)
└── analysis/
    └── proximity_analysis/worldwide/   ← script-first analysis layer

Domain in one sentence (from the glossary): this codebase studies flight trajectories — comparing what airplanes actually flew against optimal alternatives, and analyzing proximity/conflicts, fuel burn, and re-optimization scenarios.

Before we pick a path in, a quick prediction question to warm us up:

Given only the folder names Optimal_Routing_Benefits and analysis/proximity_analysis/, what's your best guess at the relationship between them?

(No wrong answer — I just want to see how the naming reads to you before we open anything up.)

Mina

proximity_analysis uses the trajectory outputs from Optimal_Routing_Benefits

Claude

Exactly right — that's the core dependency. Optimal_Routing_Benefits produces the trajectory/fuel data products, and proximity_analysis consumes them to detect and aggregate conflicts.

One nuance worth noting: the architecture review flagged that this dependency currently flows through file paths and naming conventions (parquet files with prefixes like flights, resampled_flights, wind_optimal_flights) rather than through imported Python modules with clean interfaces. That's called out as the top architectural issue.

Quick follow-up before we pick our entry point:

Which angle sounds most interesting to you for this exploration?

  1. Data-flow tour — trace one flight from raw input → optimal trajectory → proximity event, seeing what each layer does
  2. Domain deep-dive — really nail the vocabulary (as-flown, sector re-optimization, altitude probes, etc.) so the code reads clearly
  3. Module tour — look at Optimal_Routing_Benefits/src/ structure (flight, geometry, weather, routing, fuel-burn) as the reusable foundation
  4. Something else — you tell me what caught your eye

Which one grabs you?

Mina

data-flow tour

Claude

Perfect — data-flow tour it is. Let me set the stage.

The pipeline roughly looks like this:

Raw Spire flight data
        ↓
[Optimal_Routing_Benefits]  ← the "foundation" layer
        ↓
Parquet products (flights, resampled, wind-optimal, gridded, fuel)
        ↓
[analysis/proximity_analysis/worldwide]  ← the "consumer" layer
        ↓
Figures, animations, aggregated stats

And here's what's inside Optimal_Routing_Benefits/src/:

flight/         great_circle/    weather/
gridding/       routing/         fuel_burn/
plotting/       helpers/

Before we open any file — a prediction question:

If you were designing this pipeline, and raw data comes in as a stream of (flight_id, lat, lon, alt, timestamp) samples, what do you think has to happen first? What's the very first transformation step you'd expect to see, and why?

(Look at those src/ folder names for clues — several of them are candidates.)

Mina

gridding and resampling?

Claude

Half right — and the order between those two is worth pausing on.

Resampling — yes, that's typically first. Raw ADS-B/Spire data comes in irregular, noisy time intervals. You need clean, evenly-spaced samples before anything else works. That matches the resampled_flights parquet prefix mentioned in the config.

Gridding — think about what a "grid" is for, though. It bins flights into geographic cells (lat/lon squares) to summarize traffic density, count unique flights per cell, etc.

Question: Does gridding sound like a step you'd do to one flight's trajectory, or a step you'd do across many flights? And does that answer suggest it comes early or late in the pipeline?

Mina

wouldnt either work

Claude

Fair pushback — let's actually check rather than argue about it. I peeked at src/gridding/grid.py, and here's what I found:

The GeospatialGrid dataclass defines a grid over latitude, longitude, altitude, and time. And in the config, there are parquet prefixes for both gridded_flights and gridded_wind_optimal_flights — so gridding gets applied to individual flights (and to their optimal counterparts), producing per-flight gridded outputs.

That's a hint about what gridding actually does here — it's not just "count flights per cell." It looks like it's snapping each flight's samples onto a shared grid so many flights can be compared/aggregated later.

Now here's the interesting bit — the config file lists these prefixes in what looks like pipeline order:

flights → resampled_flights → gridded_flights → wind_optimal_flights → gridded_wind_optimal_flights

Prediction question: Given that ordering, what do you think happens between resampled_flights and gridded_flights? And separately — what does wind_optimal_flights sound like, and why does it come after gridding the as-flown flights?

Mina

gridding happens between resampled and gridded flights. wind optimal flights uses the weather data (which exists on a grid) as it applies to each flights' trajectory

Claude

Nailed both.

Gridding step: yes — resampled_flights → gridding operation → gridded_flights. Clean, evenly-spaced samples get snapped onto the shared spatial grid.

Wind-optimal: exactly right. Weather (winds aloft) lives on a grid — a (lat, lon, altitude, time) cube. To compute the optimal route for a given flight (same origin, destination, departure time), you need to query wind at each candidate point. Putting the as-flown flight on the same grid as the wind makes that lookup cheap and consistent.

So now the picture looks like:

raw flights
   ↓ (resample: even time/distance spacing)
resampled_flights
   ↓ (snap onto shared grid)
gridded_flights ─────────┐
                         │  + weather grid
                         ↓
                  routing algorithm
                         ↓
                 wind_optimal_flights
                         ↓ (snap onto same grid)
              gridded_wind_optimal_flights

Now — before we peek at the routing step — a design-reasoning question:

The wind-optimal trajectory is a counterfactual: "what route would have minimized fuel/time given the winds that day?" We compare it against what actually flew.

Why bother computing this counterfactual at all? What kind of question about aviation efficiency does this pair (as-flown vs wind-optimal) let you answer that you couldn't answer from as-flown data alone?

Mina

how inefficiently are we flying, how much excess fuel, what are patterns etc

Claude

Exactly. That's the whole scientific motivation of the project in one sentence:

So the "excess" is a counterfactual gap — the delta between reality and the best-case-with-perfect-knowledge alternative.

Journal updated — you can safely pause anytime. ✅

Now let's step into the routing layer. Before opening any files:

Prediction question: A wind-optimal routing algorithm needs to answer "given origin, destination, departure time, and a 4D wind field, what's the best route?"

What kind of algorithm family do you think fits this problem? Think about it as a search problem — what are you searching over, and what are you optimizing?

Mina

optimize fuel burn (minimization) across a grid search? idk

Claude

Good instinct — you've got the two right pieces: minimization objective + search over a grid. Let me sharpen one part.

"Grid search" usually means "try every combination of parameters." But here, you're not searching over parameters — you're searching for a path through a graph of grid cells (or nodes). Origin cell → some sequence of neighbor cells → destination cell.

Question: If you frame it as "find the cheapest path through a graph, where each edge cost depends on winds," what classic algorithm from CS jumps to mind?

Mina

literally how would i know that

Claude

Fair — no reason you'd know if you haven't seen it. Let me just tell you.

📚 The classic answer is Dijkstra's algorithm (or its heuristic-guided cousin A*). Both find the shortest/cheapest path through a weighted graph.

The framing for wind-optimal routing:

Let's check whether that's actually what this codebase does:

Ha — turns out I was wrong to assume Dijkstra. This codebase does something different. Let me update your expectations.

Look at what I found:

That's a big clue. Instead of searching a discrete graph, it's solving a continuous-time ODE — an equation of motion.

So the split is:

Two questions for you:

  1. Given dlat/dt = (V·cos(heading) + v_wind) / R_earth, what physical scenario does this equation describe? Say it in plain English.
  2. Why do you think they split horizontal routing from vertical/speed optimization, rather than solving them together?
Mina

wind correction; vertical and speed are split from horizontal routing because they don't have to depend on each other and this ay a clean counterfactual can be built based on how much excess fuel across the dimensions

Claude

Both good instincts. Let me sharpen each one.

On the equation — you got the ingredient right (wind correction), but the equation is describing more than a correction. Let me offer it back:

dlat/dt = (V·cos(heading) + v_wind) / R_earth

This says: "the rate at which latitude changes equals the aircraft's northward ground speed divided by Earth's radius." The V·cos(heading) is the aircraft's north component of airspeed, and + v_wind (the meridional wind) adds the wind's push. Together they give ground speed north. Divide by R_earth to convert meters/second into radians/second of latitude.

So this isn't correcting for wind — it is the equation of motion of an aircraft over a rotating sphere with wind. Given a heading policy, you can integrate this forward in time and get a trajectory.

That reframes the routing problem: instead of "find the best path in a graph," it's "find the heading policy that reaches the destination with minimum fuel/time."

On the split — you're onto something real, but let me offer a sharper reason:

Cleanly separating counterfactuals is a nice consequence, but the deeper reason is probably computational. If you tried to jointly optimize lateral path + altitude profile + speed profile in continuous space, the search space explodes. Splitting them makes each sub-problem tractable:

The trade-off: it's not globally optimal — the true optimum might couple them. But it's close enough and much faster.

Design-reasoning follow-up: This decoupling actually shows up in the CONTEXT.md glossary. Look at these two entries:

Question: Why do you think the vertical re-optimization is constrained to stepwise altitude changes rather than a smooth continuous altitude profile? What real-world constraint is that mirroring?

Mina

can't be constantly climbing

Claude

Exactly — that's the physical reason. Aircraft can't smoothly and continuously vary altitude in cruise:

  1. Air traffic control assigns discrete flight levels (FL340, FL360, FL380 — every 2000 ft in RVSM airspace). You get cleared to a level, you fly it, then you get cleared to a new one.
  2. Fuel economics: engines are most efficient at a stable cruise altitude for a given weight; constantly climbing wastes energy.
  3. Passenger comfort & workload: pilots don't hand-fly a continuous climb; they set an altitude in the autopilot and hold it.

So the "stepwise-constant" constraint in the code is enforcing what real cruise altitude changes look like: level segments joined by discrete step-climbs. The optimizer picks where to step and to what level, not a continuous function.

📚 If you're curious: https://en.wikipedia.org/wiki/Flight_level and https://en.wikipedia.org/wiki/Step_climb

Journal updated with two aha-moments. ✅

Quick checkpoint — you've now got a solid mental model of:

Where should we go next?

  1. Continue the data-flow tour → open src/fuel_burn/ and see how excess-fuel numbers actually get computed from the trajectory pair
  2. Jump downstream → cross into analysis/proximity_analysis/worldwide and see what the consumer layer actually does with all these parquet products (proximity events, conflict detection)
  3. Zoom in on routing → peek inside ArrowMethodCalculator to see how the ODE integration actually plays out in code
  4. Pause here — this is a natural stopping point

Your call.

Mina

pause here

Claude

Sounds good. Here's your session summary:

Today you:

Two aha-moments captured in your journal (in your own framing).

When you come back, three natural next steps are queued up:

  1. src/fuel_burn/ — how excess-fuel numbers get computed
  2. Cross into analysis/proximity_analysis/worldwide — the consumer layer
  3. Zoom into ArrowMethodCalculator internals

All progress saved to efficiency_codebase/.claude/learning-journal.md. Safe to close anytime — see you next session. 👋