UXsim
UXsim copied to clipboard
Analyzer: Add time_bin argument to area_to_pandas
This PR introduces time-binned analysis capabilities to the link_to_pandas and area_to_pandas methods in the Analyzer class, while also addressing an issue with traffic volume calculation. These changes allow for more flexible, granular, and accurate analysis of traffic data over time.
Changes
-
Added
time_binargument tolink_to_pandas:- When
time_binis None, the method behaves as before. - When
time_binis specified, data is aggregated into time bins. - Performance is improved for time-binned analysis due to reduced iterations.
- When
-
Updated
area_to_pandasto work with time-binned data:- Now uses the time-binned data from
link_to_pandaswhentime_binis specified. - Calculates area statistics for each time bin.
- Now uses the time-binned data from
-
Fixed traffic volume calculation in
area_to_pandas:- Now correctly counts vehicles entering the area from outside.
- Also counts vehicles starting their trip within the area.
- Avoids double-counting vehicles passing through multiple links within the area.
-
Data validation:
traffic_volumenow represents the volume per bin instead of cumulative.total_travel_timeis calculated per bin, which is more logical for a binned approach.
Notes
- The test suite has been updated to reflect the changes in traffic volume calculation.
- The new approach provides a more accurate representation of traffic patterns over time.
Part of #120.
TODO
- [x] Validate data
- [x] Add argument to
link_to_pandas - [x] Fix traffic volume calculation