| """Generate synthetic noise pollution & urban health dataset for SSA. |
| |
| Research-based parameterization: |
| - WHO (2024): Environmental noise causes cardiovascular, mental health, |
| sleep disturbance; updated disability weights for noise exposure. |
| - WHO guidelines: 53 dB Lden road traffic; 45 dB Lnight for sleep. |
| - Nature (2022): Traffic noise quantified in South African cities. |
| - PMC11221953: Nigerian noise levels and health perceptions - annoyance, |
| mental stress, sleep disturbance, hearing loss, cardiovascular effects. |
| - IntechOpen (2022): Noise policy challenges in developing countries; |
| most lack enforceable legislation. |
| """ |
|
|
| from __future__ import annotations |
|
|
| from pathlib import Path |
|
|
| import numpy as np |
| import pandas as pd |
|
|
| SEED = 42 |
| N_PER_SCENARIO = 10_000 |
|
|
| YEAR_RANGE = np.arange(2010, 2025) |
| YEAR_WEIGHTS = np.linspace(0.85, 1.3, len(YEAR_RANGE)) |
| YEAR_WEIGHTS = YEAR_WEIGHTS / YEAR_WEIGHTS.sum() |
|
|
| SCENARIOS = { |
| "megacity_traffic": { |
| "setting_probs": {"commercial_road": 0.35, "residential_road": 0.30, |
| "industrial": 0.15, "market": 0.20}, |
| "noise_source_probs": {"road_traffic": 0.40, "generators": 0.20, "industry": 0.15, |
| "entertainment": 0.10, "construction": 0.10, "religious": 0.05}, |
| "lden_mean": 72, "lden_sd": 10, |
| "lnight_mean": 58, "lnight_sd": 8, |
| "hearing_loss_prev": 0.12, |
| "hypertension_noise_pct": 0.08, |
| "sleep_disturbance_pct": 0.35, |
| "noise_regulation": 0.15, |
| }, |
| "secondary_city_mixed": { |
| "setting_probs": {"commercial_road": 0.30, "residential": 0.35, |
| "market": 0.20, "industrial": 0.15}, |
| "noise_source_probs": {"road_traffic": 0.30, "generators": 0.25, "entertainment": 0.15, |
| "religious": 0.10, "construction": 0.10, "industry": 0.10}, |
| "lden_mean": 65, "lden_sd": 10, |
| "lnight_mean": 52, "lnight_sd": 8, |
| "hearing_loss_prev": 0.08, |
| "hypertension_noise_pct": 0.05, |
| "sleep_disturbance_pct": 0.25, |
| "noise_regulation": 0.08, |
| }, |
| "periurban_emerging": { |
| "setting_probs": {"residential": 0.40, "market": 0.25, |
| "peri_urban_road": 0.20, "industrial_fringe": 0.15}, |
| "noise_source_probs": {"road_traffic": 0.25, "generators": 0.20, "entertainment": 0.15, |
| "religious": 0.15, "agriculture": 0.10, "construction": 0.15}, |
| "lden_mean": 58, "lden_sd": 10, |
| "lnight_mean": 45, "lnight_sd": 8, |
| "hearing_loss_prev": 0.05, |
| "hypertension_noise_pct": 0.03, |
| "sleep_disturbance_pct": 0.15, |
| "noise_regulation": 0.05, |
| }, |
| } |
|
|
| SCENARIO_FILES = { |
| "megacity_traffic": "noise_megacity.csv", |
| "secondary_city_mixed": "noise_secondary_city.csv", |
| "periurban_emerging": "noise_periurban.csv", |
| } |
|
|
|
|
| def _choice(rng, prob_map): |
| keys = list(prob_map.keys()) |
| weights = np.array(list(prob_map.values()), dtype=float) |
| weights = weights / weights.sum() |
| return rng.choice(keys, p=weights) |
|
|
|
|
| def _simulate_scenario(name, params, seed): |
| rng = np.random.default_rng(seed) |
| records = [] |
|
|
| for idx in range(N_PER_SCENARIO): |
| year = int(rng.choice(YEAR_RANGE, p=YEAR_WEIGHTS)) |
| setting = _choice(rng, params["setting_probs"]) |
| age = int(np.clip(rng.normal(32, 15), 5, 75)) |
| sex = rng.choice(["male", "female"], p=[0.50, 0.50]) |
| is_child = int(age < 15) |
| occupation = rng.choice(["outdoor_worker", "indoor_worker", "student", "homemaker", "vendor"], |
| p=[0.25, 0.20, 0.20, 0.20, 0.15]) |
|
|
| noise_source = _choice(rng, params["noise_source_probs"]) |
| distance_to_source_m = float(np.clip(rng.exponential(50), 5, 500)) |
| proximity_factor = max(0.5, 1.0 - distance_to_source_m / 200) |
|
|
| lden = float(np.clip( |
| rng.normal(params["lden_mean"] * proximity_factor, params["lden_sd"]), 35, 110)) |
| lnight = float(np.clip( |
| rng.normal(params["lnight_mean"] * proximity_factor, params["lnight_sd"]), 25, 90)) |
|
|
| exceeds_who_lden = int(lden > 53) |
| exceeds_who_lnight = int(lnight > 45) |
| exceeds_85db = int(lden > 85) |
|
|
| exposure_years = int(np.clip(rng.normal(8, 5), 0, 30)) |
| daily_exposure_hours = float(np.clip(rng.normal(8, 3), 1, 16)) |
|
|
| uses_hearing_protection = int(rng.random() < 0.05) |
|
|
| risk_mult = lden / 53 |
| hearing_loss = int(rng.random() < np.clip( |
| params["hearing_loss_prev"] * risk_mult * (exposure_years / 10), 0, 0.35)) |
| tinnitus = int(rng.random() < np.clip(0.05 + risk_mult * 0.04, 0, 0.25)) |
|
|
| hypertension = int(age >= 25 and rng.random() < np.clip( |
| params["hypertension_noise_pct"] * risk_mult, 0, 0.20)) |
| cardiovascular = int(age >= 35 and hypertension and rng.random() < 0.15) |
|
|
| sleep_disturbance = int(rng.random() < np.clip( |
| params["sleep_disturbance_pct"] * (lnight / 45), 0, 0.60)) |
| annoyance = int(rng.random() < np.clip(0.20 + risk_mult * 0.15, 0, 0.70)) |
| stress_anxiety = int(rng.random() < np.clip(0.10 + risk_mult * 0.08, 0, 0.35)) |
| concentration_difficulty = int(rng.random() < np.clip(0.08 + risk_mult * 0.06, 0, 0.30)) |
|
|
| child_learning = int(is_child and rng.random() < np.clip(risk_mult * 0.08, 0, 0.20)) |
|
|
| noise_complaint = int(annoyance and rng.random() < 0.10) |
| noise_regulation = int(rng.random() < params["noise_regulation"]) |
| noise_monitoring = int(rng.random() < 0.05) |
|
|
| record = { |
| "record_id": f"{name[:3].upper()}-{idx:05d}", |
| "scenario": name, |
| "year": year, |
| "setting": setting, |
| "age": age, |
| "sex": sex, |
| "is_child": is_child, |
| "occupation": occupation, |
| "noise_source": noise_source, |
| "distance_to_source_m": round(distance_to_source_m, 0), |
| "lden_db": round(lden, 1), |
| "lnight_db": round(lnight, 1), |
| "exceeds_who_lden_53": exceeds_who_lden, |
| "exceeds_who_lnight_45": exceeds_who_lnight, |
| "exceeds_85db": exceeds_85db, |
| "exposure_years": exposure_years, |
| "daily_exposure_hours": round(daily_exposure_hours, 1), |
| "uses_hearing_protection": uses_hearing_protection, |
| "hearing_loss": hearing_loss, |
| "tinnitus": tinnitus, |
| "hypertension": hypertension, |
| "cardiovascular": cardiovascular, |
| "sleep_disturbance": sleep_disturbance, |
| "annoyance": annoyance, |
| "stress_anxiety": stress_anxiety, |
| "concentration_difficulty": concentration_difficulty, |
| "child_learning": child_learning, |
| "noise_complaint": noise_complaint, |
| "noise_regulation": noise_regulation, |
| "noise_monitoring": noise_monitoring, |
| } |
| records.append(record) |
|
|
| return pd.DataFrame(records) |
|
|
|
|
| def main(): |
| output_dir = Path("data") |
| output_dir.mkdir(parents=True, exist_ok=True) |
| for idx, (name, params) in enumerate(SCENARIOS.items()): |
| df = _simulate_scenario(name, params, SEED + idx * 211) |
| df.to_csv(output_dir / SCENARIO_FILES[name], index=False) |
| print(f"Saved {name} -> {SCENARIO_FILES[name]}") |
|
|
|
|
| if __name__ == "__main__": |
| main() |
|
|