Repository navigation
Conversation
…-parallel) Uncommitted work of the deprecate-transport-parallel session, moved to dev as the base for the transport_model() fixes: the single gtfs2gps call, segments limited to the first-to-last stop of each trip, fill_speed() for missing and out-of-range speeds, one .rds per shape for output_path, and the related emission_model(), emis_*() and slope_class_europe_emep() updates. Not yet fully tested or reviewed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- veh_type, euro, fuel, tech and fcorr must have length 1 or one common length. They were reconciled against euro only, so extra vehicle types were dropped silently and a single euro returned only the first veh_type. fcorr must be non-negative. - CNG Euro EEV (and PRE) use tech "-" like Euro I-III, so EEV works with the default tech = "SCR". - "SPN23 [#/kWh]" is not a g/km factor and is no longer accepted. - EC is energy consumption: it is returned in MJ/km, so emission_model() rejects it, and ef_scaled_euro() rejects EC and SPN23 upfront. - slope_class_europe_emep() errors on a tp_model with no rows and uses the units of dist when it has them. Against master at slope 0 / load 0.5, all 1630 combinations that work in both are identical; the only new errors are the 161 SPN23 calls and the only new values the 24 CNG EEV calls. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Require gtfs2gps (>= 2.1-4.9000) with Remotes: ipea/gtfs2gps. With gtfs2gps 2.1-4 some trips lost segments or got segments joining two trips (608 instead of 632 segments on the Detroit feed), and an empty feed crashed R. This blocks a CRAN release until gtfs2gps is released. - A feed gtfs2gps can't convert gives a gtfs2emis_error (parent kept). - Segment speeds still outside min_speed/max_speed are capped at the limits; only missing speeds get new_speed or the feed-wide distance-weighted mean. - output_path file names encode every "%" (URLencode repeated = TRUE), so shape_ids round-trip. - Document the speed bounds, the output columns and units; drop the progressr wrapper from the intro vignette; fix the output description in the vignette and README. - Tests: segments per stop pair on two Detroit trips, empty feed, "%" file names, capping, invalid speeds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Dublin fixture now has one segment per pair of consecutive stops (73; gtfs2gps 2.1-4 gave 90) and trip 3412 keeps its scheduled 08:00-08:23 times (2.1-4 timed it at 16:27-17:00). The output therefore gains the 08 h and five grid cells: emis_grid 37 -> 42 cells, by hour 144 -> 188 rows, by minute 294 -> 306; emis_summary(by = "time") 8 -> 10 rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #120 +/- ##
==========================================
+ Coverage 83.91% 90.13% +6.22%
==========================================
Files 15 15
Lines 1355 1490 +135
==========================================
+ Hits 1137 1343 +206
+ Misses 218 147 -71 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
interpolate_stop_times(overwrite = TRUE) replaced every intermediate stop time with a constant-speed interpolation, discarding the schedule's own times, and ran after set_min_speed()/set_max_speed(), overwriting their corrections. Fill only blank times (overwrite = FALSE) and do it first, so the speed limits also apply to the filled times. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fill_speed() capped segment speeds and filled missing ones but left their timestamps, so speed, duration and cumtime disagreed (e.g. a 16.8 m segment at 80 km/h in 0 s, where gtfstools measures 0 m and can't fix it). - New internal retime_segments(): a changed segment's duration becomes dist / speed, and the later times of its trip (from/to_timestamp, timestamp, cumtime) shift by the difference. Each trip keeps its first departure and its dwell times; times wrap at midnight as in gtfs2gps; 0 m segments and rows without times are not shifted. - With new_speed = NULL, missing speeds get the average speed (total distance / total time) of their shape_id, or of the feed if the shape has none; before, a feed-wide distance-weighted mean. - new_speed must be within [min_speed, max_speed]. Full Dublin feed: 0 speeds out of range, every duration within 0.15 s of dist / speed, no first departure changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uard
- ef_brazil_scaled_euro: fleet_data$tech was required but never passed to
ef_scaled_euro(), so every row used "SCR". Results change for Euro IV+
rows with another technology (e.g. EGR).
- process is now validated for every ef_model: wear processes with a
non-EMEP model crashed with "object 'temp_emis' not found", and
c("hot_exhaust", "tyre") silently dropped the wear part.
- Error when output_path is the tp_model folder, which overwrote the
transport model files.
- Remove a stray empty argument in the ef_usa_emfac() call.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…3.0 NEWS points Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- ef_europe_emep(): compute each emission factor once per unique (slope, load, speed) and expand, instead of once per segment. 10^6 speeds: 4.0 s / 7.7 GB -> 0.67 s / 0.9 GB. Output identical. - emis_grid(): sparse st_intersects() instead of a dense grid x segment matrix; intersect each segment geometry with the grid once and join the per-time-bin emissions back, instead of intersecting every (bin, segment) row; drop two redundant copies. Dublin, 459 cells: hour 45 s / 860 MB -> 14 s / 315 MB, minute 52 s / 1004 MB -> 15 s / 331 MB, day unchanged. Day/aggregate output identical; hour and minute equal up to summation order. - Tests: repeated speed/slope/load values give the per-element EF; hour and minute grid totals equal the day total; input unchanged. - NEWS: Performance section (vs gtfs2emis 0.1.2 on CRAN). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- emis_to_dt(): build the long table in one pass (stack the emission columns, repeat the labels) instead of one table per column and rbindlist(). It now errors when the emission columns have different lengths or a segment_vars column has the wrong length, instead of misaligning rows or giving a data.table error. - multiply_ef(): multiply plain numbers (units are checked to be exactly g/km and km) and setDT(), instead of units arithmetic, cbind() and as.data.table(). - ef_usa_moves(), ef_usa_emfac(): find the speed bin with one findInterval() call instead of a loop over the limits; drop a copy() before a subset. 160k segments x 16 columns, installed builds: emis_to_dt 1.65x faster, -37% memory; emis_summary 1.2-1.45x, -17%; emission_model 1.25x and -26% (EMEP), -52% memory (CETESB); MOVES/EMFAC 1.2x, -23% at 10^6 speeds. Outputs identical() on 45 goldens. Tests: speeds on bin limits, sorted EF databases, emis_to_dt leaves its input unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The vignettes had wrong statements (NOx instead of CO2 in the intro
example, a detailed fleet table that emission_model() supposedly maps to
routes, a "Brazilian" comment on EMEP code), unclear prose and mixed code
styles. Rewrite the prose, check every claim against R/, and format all
vignette code in one (tidyverse) style; the parsed code is unchanged
apart from small cleanups.
The GitHub organisation moved from ipeaGIT to ipea and the old
ipeagit.github.io site returns 404, so replace every ipeaGIT/ipeagit
reference (DESCRIPTION, README, _pkgdown.yml, roxygen and man/, NEWS,
vignettes, maintainer scratch scripts, CLAUDE.md).
Also fix the emi_europe_emep_wear() veh_type doc ("Coaches Std <=18 t").
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
@Joaobazzo , this PR is ready for review. Here's a quick summary of all changes:
|
emission_model() had parallel = TRUE and ncores = NULL, i.e. all cores minus one, and started a multisession plan even for an sf tp_model, where it is never used. Match transport_model(): `parallel` now gives a gtfs2emis_deprecated warning, and `ncores` (default 2, NULL -> 2, Inf -> all available cores, capped at parallelly::availableCores()) controls the number of R processes. parallel = FALSE still runs sequentially so old code does not start processes. Workers are only started for a folder tp_model with ncores > 1, and the caller's plan is restored. Tests: parity of ncores = 1 vs 2 on a 3-file folder, plan restored, deprecation warning, ncores validation; parallel removed from the other calls. NEWS and the project rules (parity check is now ncores = 1 vs 2) are updated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rafapereirabr
marked this pull request as ready for review
November 7, 2026 03:08
Joaobazzo
approved these changes
Nov 8, 2026
Joaobazzo
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @rafapereirabr Merging it now
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.