Date: 2026-07-10
Tool: pi coding agent, coding-situation-awareness skill (first pass)
Focus: writing a worldwide inter-airline FL410 comparison script using raw as-flown trajectories
okay! using the coding-situation-awareness skill, we will write a basic script inside the efficiency_codebase/analysis/proximity_analysis/worldwide that will assess whether there are inter-airline differences in who flies above FL410, which is the altitude above which at least one pilot needs to be wearing an oxygen mask at all times. create a script to do this using the rest of the codebase as context. let's be using raw as-flown trajectories
[reads the skill, lists the target directory, then reads the nearby FL400 sector-scoped script plot_aircraft_type_distribution_fl400.py, time_resample.py, the sector-reoptimization eligibility.py, and CONTEXT.md to establish the neighbourhood]
Session Diff: no git repo, so this is a fresh addition. I've read the neighbourhood: plot_aircraft_type_distribution_fl400.py (nearly the same shape but sector-scoped + aircraft type) and time_resample.py (shows time_resampled_asflown_cruise_* uses altitude_AF_m, is the as-flown cruise product resampled at 10 s).
I'll model this after the FL400 script, but strip the sector filter (worldwide) and group by airline instead of aircraft type. Definition of "flew above FL410": at least one as-flown cruise sample ≥ 41 000 ft. Statistical test: chi-square of airline × {above_FL410, not_above_FL410}.
[writes airline_fl410_distribution.py — reads monthly time_resampled_asflown_cruise_DD_MM_YYYY_10_s.parq files, joins with monthly metadata for the airline column, computes per-flight max cruise altitude, aggregates per airline, runs a chi-square test, and saves a CSV, a chi2 txt, and a top-N barh plot]
Created efficiency_codebase/analysis/proximity_analysis/worldwide/airline_fl410_distribution.py.
Now firing the SA check per the skill. The diff touches data code (parquet I/O, groupby, merge, chi-square), so at least one Data-Flow probe is required. 3 probes, L1/L2/L3 coverage.
Probe 1 (L1, perception). Answer from memory. If you'd need to check, say so — that's a valid answer.
Which parquet files does the script actually read from disk for the altitude data — the pre-resample resampled_flights_DD_MM_YYYY.parq, or the post-resample time_resampled_asflown_cruise_DD_MM_YYYY_10_s.parq?
resampled_flights
Miss. Script reads time_resampled_asflown_cruise_{DD}_{MM}_{YYYY}_{TR}_s.parq (airline_fl410_distribution.py:174-176), i.e. the post-resample product from time_resample.py. So samples are on a 10 s uniform grid, cruise-only, and only include flights that survived the mass_AF2_bada42_tow2_kg non-null filter in time_resample.py:98.
If you actually want strictly raw as-flown (pre-resample), the input file needs to become resampled_flights_DD_MM_YYYY.parq with in_cruise_corrected == True filtering — say the word and I'll switch it.
Probe 2 (L2/Data-Flow). Which flights are silently excluded from the airline table by the current pipeline — before we even get to the FL410 comparison?
those with missing airlines?
Partial. Flights with missing airline are not dropped — they're bucketed as "Unknown" (airline_fl410_distribution.py:139 fills NaN, then the left-merge at line 208 preserves them). The real silent exclusions happen upstream in time_resample.py:
df.dropna(subset=['unix_timestamp_OPT_V2'], inplace=True) # line 94 df.dropna(subset='mass_AF2_bada42_tow2_kg', inplace=True) # line 98
So any flight without a valid V2 optimal propagation or without BADA fuel burn never appears in time_resampled_asflown_cruise_* and is invisible to this script. That's a non-trivial filter for a "who flies above FL410" question — it selects flights that are OPT/BADA-eligible.
Probe 3 (L3, projection). If tomorrow you rerun this on a month where one airline has 50 000 flights and another has 200, and the chi-square p-value comes back at 1e-40, what does that number not tell you that a reader of the plot might assume it does?
OHH wait that is totally an issue. we should use the resampled ones not time_resampled ones! to answer your probe 3 it would not tell me whether the second airline has a sufficiently large sample set
Hit on the sample-size angle — with 200 flights the chi-square asymptotic approximation may already break down (that's what min_expected_above_cell in the txt is a proxy for), and the individual airline's share estimate has a 95% CI of roughly ±7pp. One extra thing the p-value hides: with 50 000 vs 200, a substantively trivial 0.5pp difference will still be "p<1e-40" — significance ≠ effect size. So always read the share column alongside p.
Now fixing the input to the truly raw pre-time-resample file:
[edits airline_fl410_distribution.py: switches the input file glob from time_resampled_asflown_cruise_*_{TR}_s.parq to resampled_flights_DD_MM_YYYY.parq, adds a --cruise-only flag that applies in_cruise_corrected == True (default on), and updates the docstring to explain the choice and the OPT_V2/BADA bias it avoids]
Parses clean.
SA-Gap Summary
resampled_flights_* was the input, but the first draft actually read the downstream time_resampled_asflown_cruise_*. Real gap — that downstream file carries the OPT_V2 + BADA eligibility filter from time_resample.py:94,98, which would have biased the airline comparison. Now fixed to read raw resampled_flights_DD_MM_YYYY.parq with an optional --cruise-only flag on in_cruise_corrected.Logging one entry to .coding-sa/log.md. Script ready; run with defaults:
python3 airline_fl410_distribution.py --year 2023 --month 1
Outputs go to the conflict-results figures tree: a per-airline CSV, a chi-square txt (with min_expected_above_cell so you can sanity-check the asymptotic approximation), and a top-N barh plot with an overall-share reference line.
wonderful thanks. can you export this transcript (make sure sensitive path information are masked) to update the diary and website log to add a link to the transcript in the place where i've indicated AI TO FILL IN