Skip to content

Add MPGe column to results#78

Merged
dan-mccabe merged 12 commits intomainfrom
dpm/add-mpge
Mar 10, 2026
Merged

Add MPGe column to results#78
dan-mccabe merged 12 commits intomainfrom
dpm/add-mpge

Conversation

@dan-mccabe
Copy link
Copy Markdown
Collaborator

@dan-mccabe dan-mccabe commented Mar 6, 2026

  • Add MPGe to results for powertrain-agnostic energy efficiency comparison
  • Exclude some unnecessary columns previously included in trip-level energy predictions
  • Add a new --feed_ids CLI option and changes feed collection behavior in gather_feeds.py

@dan-mccabe dan-mccabe linked an issue Mar 6, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an MPGe metric to trip-level energy prediction outputs to enable powertrain-agnostic efficiency comparisons, and also trims some trip-level columns. It additionally refactors the GTFS feed gathering script and adds a --feed_ids option for targeted Mobility Database processing.

Changes:

  • Add per-trip mpge calculation (via GGE conversion factors) and drop some trip-level GTFS metadata columns from prediction outputs.
  • Refactor scripts/feeds/gather_feeds.py into smaller functions and add --feed_ids for selecting specific Mobility Database feeds.
  • Add GtfsExtractor.query_mdb_feed() to support querying a single feed directly by ID.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
scripts/feeds/gather_feeds.py Refactors feed/dataset collection flow; adds --feed_ids filtering and writes feed/dataset summary CSVs.
scripts/feeds/extract_static_gtfs.py Adds query_mdb_feed() helper to fetch one feed record by ID.
routee/transit/predictor.py Adds mpge to trip-level results and drops selected trip metadata columns; updates energy model config with GGE conversion factors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/feeds/gather_feeds.py
Comment thread scripts/feeds/gather_feeds.py
Comment on lines +1282 to +1294
# Compute MPGe (miles per gallon equivalent) — a common efficiency
# metric across all fuel types using EPA GGE conversion factors
gge_per_unit = float(model_config["gge_per_unit"])
gge_consumed = trip_results["energy_used"] * gge_per_unit
trip_results["mpge"] = trip_results["miles"] / gge_consumed
# Replace inf/negative with NaN for trips with zero or invalid energy
trip_results.loc[gge_consumed <= 0, "mpge"] = float("nan")

# Drop columns that are not useful in trip-level output
trip_results = trip_results.drop(
columns=["service_id", "route_short_name", "route_desc", "route_type"],
errors="ignore",
)
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mpge is newly computed here but there are no unit tests exercising predict_energy() output (including the zero/negative-energy handling that should yield NaN). Since routee/transit/predictor.py already has a test module (tests/test_predictor.py), add coverage for MPGe calculation (at least one BEB and one diesel case) and confirm the dropped columns are absent/preserved as expected.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 10, 2026

@dan-mccabe I've opened a new pull request, #79, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits March 10, 2026 19:07
Co-authored-by: dan-mccabe <25916826+dan-mccabe@users.noreply.github.com>
Add unit tests for MPGe calculation in `predict_energy()`
@dan-mccabe dan-mccabe merged commit cd4812f into main Mar 10, 2026
4 checks passed
@dan-mccabe dan-mccabe deleted the dpm/add-mpge branch March 10, 2026 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add MPGe to results

3 participants