Skip to main content

roadtraffic

PyPI PyPI - Python Version Build

Overview

The roadtraffic Python package for traffic data processing and fundamental diagram estimation. A fundamental diagram is estimated using convex regression with the help of the pyStoNED package. The mosek solver is used for the estimation. For the academic purposes, you can obtain a free academic license for the solver. You can also use the free NEOS server for the estimation, but the computational time will be longer.

Currently only data from Finnish roads, collected through this package is supported. The source of data is Fintraffic / digitraffic.fi, license CC 4.0 BY.

The package works on the raw data. The data can be aggregated over time and road direction/lane. The aggregated data is then bagged for computational efficiency. The estimation of the fundamental diagram is done on the bagged data. The availability of raw data depends on the traffic measurement station. The earliest data are from 1995. New data are available every day at 3 am (Helsinki time zone). The developers of the package are not affiliated with Fintraffic and can't influence the availability or quality of the data.

Installation

The installation of the package is avalable through the PyPI:

    pip install roadtraffic

Basic usage

The package offers an opportunity to work with Finnish traffic data. You can select a traffic measurement station (TMS or LAM, in Finnish) from the official metadata using tmsNumber field or the map taking the integer part or lamid field.

Let's take as an example the traffic management station number 162, located on Kehä II in Espoo, Finland and load, process the data and estimate the model for September 10-11, 2019.

# Import dependencies
from roadtraffic import fintraffic 

# Traffic measurement station of interest
tms_id = 162

# Initiate the list of days (tuples) of interest (Sep 10-11, 2019)
days_list = [
    (2019, 253),
    (2019, 254),
]

# Specify the road direction
# Information about the direction could be obtained from the metadata or the map
direction = 1

# Initiate the class for Fintraffic data
tms = fintraffic.TrafficMeasurementStation(tms_id, days_list)

# Load raw data for the selected period
tms.raw.load()

# Clean data for the direction
tms.raw.clean(direction=direction)

# Aggregate data
tms.raw_to_agg(aggregation_time_period='5', aggregation_time_period_unit='min')

# Bag data
tms.agg_to_bag(num_bags_density=40, num_bags_flow=200)

# Estimate the model for the median
tms.bag.estimate_model("quantile", [0.5], email="test@test.test") # you can specify your email to receive the log file

# Obtain the results
tms.bag.models.get_estimate(0.5)

# Estimate the model for the mean
tms.bag.estimate_model("mean", email="test@test.test")

# Obtain the results
tms.bag.models.get_estimate("mean")

Authors

  • Iaroslav Kriuchkov, Doctoral Researcher at Aalto University School of Business, Finland
  • Timo Kuosmanen, Professor at Turku University School of Economics, Finland

License

roadtraffic is licensed under the GNU GPLv3 License - see the LICENSE file for details

Metadata

Release files for roadtraffic 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for roadtraffic 1.0.0
File Size Uploaded Provenance
roadtraffic-1.0.0.tar.gz 31.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for roadtraffic 1.0.0
File Interpreter ABI Platform
roadtraffic-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 63.6 kB

Release files / roadtraffic-1.0.0.tar.gz

Download URL roadtraffic-1.0.0.tar.gz
Size 31.3 kB
Tags Source
SHA-256 checksum
How to use checksums
50932b0aea34c7157a468330351a229de84b574d2a85e849dc24e1812bfaccf7
BLAKE2b-256 checksum
How to use checksums
50ebe21eb73449f1c90db0dd56e46c49c50e989c48110c2e4fc416554f731581
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Release files / roadtraffic-1.0.0-py3-none-any.whl

Download URL roadtraffic-1.0.0-py3-none-any.whl
Size 32.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fde2c3e2c2243cd116a32c3c387a2ec8aa9b560e97eb8f93a231ab8ed8ad67d3
BLAKE2b-256 checksum
How to use checksums
e6bbae041c776c7248d08c9e76c2d227b8f520b47044814cf8ec6c2f21d5298f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/4.0.2 CPython/3.11.6

Security for roadtraffic 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page