Segmentation and Booking Timeframes

When do different kinds of passengers book, and how much revenue do they bring in? These charts let you follow bookings through the time leading up to departure and focus on a carrier, booking class, or market.

You can read about the underlying data and how to collect it in Segmentation and Booking Timeframes.

Bookings and Revenue by Timeframe

This chart shows bookings or revenue within each booking timeframe, separated by passenger segment. It is useful for seeing whether different groups book early or wait until close to departure.

Choose metric="bookings" to count bookings or metric="revenue" to show the revenue they generate. Use by_carrier and by_class to separate carriers and booking classes: True shows them separately, False combines them, and a name selects just that carrier or class.

For a single run, exclude_nogo=True leaves out the no-go carrier, which represents passengers who did not book. Comparisons offer source_labels to identify the runs on the chart and ratio to add reference values to the tooltips.

For one run, call fig_segmentation_by_timeframe on a single SimulationTables object:

summary.fig_segmentation_by_timeframe(metric="revenue", by_carrier="Tapas")

To compare runs, use fig_segmentation_by_timeframe on a Contrast object:

contrast.fig_segmentation_by_timeframe(metric="revenue", by_carrier="Tapas")

Bookings by Timeframe

If you are interested in bookings rather than revenue, you can use this shortcut. For a single run, it gives the same result as fig_segmentation_by_timeframe("bookings", ...).

Use by_carrier and by_class as above. Comparisons also let you select a passenger segment with by_segment. Set source_labels=True to label runs directly, which is useful when you share a static image without hover tooltips.

For one run, call fig_bookings_by_timeframe on a single SimulationTables object:

summary.fig_bookings_by_timeframe(by_carrier="Tapas", by_class=True)

To compare runs, use fig_bookings_by_timeframe on a Contrast object:

contrast.fig_bookings_by_timeframe(by_carrier="Tapas", by_class=True)

Cumulative Bookings by Market

This view adds market detail to the passenger-segment breakdown. Unlike the timeframe charts above, its booking counts are cumulative: a point includes bookings made up to that day.

This chart uses the segmentation_detail table, which requires booking detail to be recorded during the simulation. Follow the collection instructions in Segmentation and Booking Timeframes before running your own network. You can focus on a carrier or booking class with by_carrier and by_class, and choose a market with orig and dest.

The default demo archive has no fare-detail records. To show this chart, we replay the same demo configurations with fare recording enabled and prepare segmentation_detail before discarding the temporary databases. The sample counts, seed, and RM settings stay the same. This first collection can take a little longer; later calls use its separate cache.

from pathlib import Path
import tempfile
from passengersim.contrast import Contrast


def collect_demo(name: str) -> pax.SimulationTables:
    """Replay a demo with the recording needed by this page."""
    cfg = pax.Config.from_yaml(pax.demo_network(name))
    cfg.outputs._write_no_files()
    cfg.outputs.reports = {"segmentation_detail"}
    cfg.simulation_controls.show_progress_bar = False
    cfg.db.write_items = {"fare"}
    cfg.db.filename = None
    cfg.db.result_directory = None
    cfg.db.result_storage = "summary_only"
    cache_dir = Path(tempfile.gettempdir()) / "passengersim-viz-guide" / "segmentation-detail-v1" / name
    simulation_class = pax.MultiSimulation if cfg.simulation_controls.num_trials > 1 else pax.Simulation
    with simulation_class(cfg) as sim:
        return sim.run(cache_dir=cache_dir)


recorded = Contrast({name: collect_demo(name) for name in ("europa", "europa/upe")})
recorded_summary = recorded["europa/upe"]
Cache miss for config with hash 7c74c79403d233a14081a639859d93ace135807ff5ad681ca38c87a8ad08e179. Running simulation and saving summary to cache.

╭─────────────────── Summary revenue statistics · Europa ───────────────────╮
│                            Brat            Stroop             Tapas       │
│ Run      Samples     Mean  ~95% CI     Mean  ~95% CI     Mean  ~95% CI    │
│ Europa       900   943.2K   ±7,066   920.6K   ±7,443   292.5K   ±2,336    │
│ Post-burn-in only · Approx. 95% CI for mean                               │
╰───────────────────────────────────────────────────────────────────────────╯
Cache miss for config with hash ebaaa4a9de522e7748ec39869f0b89712230440c4182804cebdc551d262e0e72. Running simulation and saving summary to cache.

╭─────────────────── Summary revenue statistics · Europa ───────────────────╮
│                            Brat            Stroop             Tapas       │
│ Run      Samples     Mean  ~95% CI     Mean  ~95% CI     Mean  ~95% CI    │
│ Europa       900   968.6K   ±8,193   935.5K   ±8,308   291.7K   ±2,130    │
│ Post-burn-in only · Approx. 95% CI for mean                               │
╰───────────────────────────────────────────────────────────────────────────╯

For one run, call fig_segmentation_detail on a single SimulationTables object:

recorded_summary.fig_segmentation_detail(by_carrier="Tapas", orig="KEF", dest="MAD")

To compare runs, call fig_segmentation_detail with a Contrast object. This is a standalone function, so import it before calling it. It accepts the same carrier, class, and market filters, plus width and height to adjust the layout.

from passengersim.summaries.segmentation_detail import fig_segmentation_detail

fig_segmentation_detail(recorded, by_carrier="Tapas", orig="KEF", dest="MAD")