A Python package to analyze traffic and air pollution in Ticino
Project description
traffico_ticino – Air Pollution and Traffic Analysis in Southern Switzerland
traffico_ticino is a Python package designed to analyze the relationship between vehicular traffic and air pollution in the Canton of Ticino, Switzerland.
It combines observed data from environmental monitoring stations with meteorological inputs and provides forecasting tools for future pollution scenarios under different traffic evolution assumptions.
Key Features
- Regression analysis linking traffic intensity to pollutants and weather variables.
- Monte Carlo simulations of future pollution under customizable traffic trends (e.g., linear growth, historical patterns, green mobility).
- Visualization tools for diagnostics and station comparisons.
- Organized access to structured datasets at multiple spatial and temporal resolutions.
Installation
You can install the package locally by cloning the repository and running:
pip install .
Make sure you are using a Python environment with the following packages installed:
- pandas
- numpy
- seaborn
- matplotlib
- statsmodels
Modules Overview
summary() Function
The summary() function provides a flexible interface to run OLS regressions of pollutants on traffic data and meteorological conditions for selected monitoring stations in Ticino, Switzerland. It supports textual summaries and graphical diagnostics, as well as comparisons across stations and pollutants.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
station |
str or list |
"all" |
Station name (e.g., "Airolo") or list of names. "all" includes all available stations. |
show |
str |
"ols" |
Output type: "ols", "graphic", or "all". |
pollutants |
str or list |
"all" |
Target pollutants. "all" includes: ["no", "no2", "nox", "pm10"]. |
comparison |
bool |
True |
Whether to show summary tables and comparisons. |
Example
from summary import summary
summary(station=["Airolo", "Bioggio"], show="all", pollutants=["no2", "pm10"])
monte_verita_simulation() Function
Simulates future pollutant concentrations under different traffic evolution scenarios using Monte Carlo methods.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
df |
DataFrame |
Required | Input with date, traffic, and pollutant columns. |
variable |
str |
Required | Pollutant to simulate (e.g., "no2"). |
trend_type |
str |
"historical" |
One of: "historical", "historical_modified", "linear", "exponential", "manual". |
growth_rate |
float |
0.02 |
Used for exponential trend (e.g., 0.007974 = 10%/year monthly). |
n_periods |
int |
48 |
Number of simulation periods. |
n_simulations |
int |
1000 |
Number of Monte Carlo draws. |
meteo_csv_path |
str |
Optional | CSV with monthly average temperature, wind, rain. |
Example
from traffico_ticino.simulation import monte_verita_simulation
sim_df = monte_verita_simulation(
df=df_bioggio_full,
variable="no2",
traffic_col="traffic",
trend_type="exponential",
growth_rate=0.007974,
n_periods=60,
meteo_csv_path="data/meteo_mensile/bioggio_meteo_mensile.csv",
coef_json_path="data/coefficients/pooled.json"
)
load_dataset() Function
Helper function to load datasets from the data/ folder, including subdirectories and station-specific files.
Parameters
| Parameter | Type | Description |
|---|---|---|
nome_file |
str |
Base name of the file (without .csv). |
sottocartella |
str |
Subfolder under data/. |
stazione_singola |
bool |
If True, loads from data/stazioni singole/<sottocartella>. |
Example
from traffico_ticino.loader import load_dataset
df = load_dataset("O3_media", "media")
df_station = load_dataset("BIASCA_traffic_only", "traffic_only", stazione_singola=True)
Project Directory Structure
traffico_ticino/
├── data/
│ ├── media/
│ ├── all/
│ └── stazioni singole/
│ ├── traffic_only/
│ ├── noO3/
│ └── ...
├── summary.py
├── simulation.py
├── loader.py
└── ...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file traffico_ticino-0.1.1.tar.gz.
File metadata
- Download URL: traffico_ticino-0.1.1.tar.gz
- Upload date:
- Size: 53.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b8e48e91bd3a815253fb0b5cef4f469a64af65d27cc7f7deda69210dc911d3c
|
|
| MD5 |
ffd5b3b7a649c1ad055a570c9f034e92
|
|
| BLAKE2b-256 |
5d89424891a9688e8f58f6400d6bca558df721bf25b12bca8e78a3d05ae4d1e2
|
File details
Details for the file traffico_ticino-0.1.1-py3-none-any.whl.
File metadata
- Download URL: traffico_ticino-0.1.1-py3-none-any.whl
- Upload date:
- Size: 67.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8156209989674dc6c15cd7d6d6a8ce37c280d23dd205e5e2efa48025ac6c9dd
|
|
| MD5 |
951556a6b408832057fdc5da9777bc71
|
|
| BLAKE2b-256 |
1bf44c6770c213341da7e98bd4be90bc4acb5fff54f7f4fe9df00945d85a798f
|