""" African Cement Plant Operations Dataset Generator ================================================== Generates 15,000+ records across 12 African countries with 3 scenarios. Literature-calibrated parameters sourced from: - USGS Mineral Industry of Africa (2019-2024) - Dangote Cement Annual Reports 2024-2025 - GCCA Cement Industry Net Zero Progress Report 2024/25 - IEA Cement Energy System analysis - AfDB Infrastructure Reports - Global Cement Magazine Top 100 2026 - World Cement: Sub-Saharan Africa industry reports - Natural Resources Canada: Cement Clinker Energy Benchmark Guide - MDPI: Alternative Fuels Substitution in Cement Industries - Discover Applied Sciences: Ethiopian GHG cement emission factors """ import numpy as np import pandas as pd import json import os from datetime import datetime, timedelta np.random.seed(42) # --------------------------------------------------------------------------- # Country configurations (literature-calibrated) # --------------------------------------------------------------------------- COUNTRIES = { "South Africa": { "region": "Southern Africa", "installed_capacity_mt": 16.5, "num_plants": 8, "avg_plant_age_years": 32, "capacity_utilization_mean": 0.72, "coal_share_mean": 0.70, "gas_share_mean": 0.05, "petcoke_share_mean": 0.15, "alt_fuels_share_mean": 0.10, "electrical_kwh_per_ton_mean": 95, "thermal_gj_per_ton_mean": 3.65, "clinker_factor_mean": 0.78, "co2_kg_per_ton_cement_mean": 620, "cost_usd_per_ton_mean": 78, "export_share_mean": 0.08, "quality_compliance_mean": 0.96, "grid_reliability": 0.78, "gdp_growth_impact": 0.02, }, "Nigeria": { "region": "West Africa", "installed_capacity_mt": 52.0, "num_plants": 14, "avg_plant_age_years": 18, "capacity_utilization_mean": 0.48, "coal_share_mean": 0.45, "gas_share_mean": 0.35, "petcoke_share_mean": 0.12, "alt_fuels_share_mean": 0.08, "electrical_kwh_per_ton_mean": 105, "thermal_gj_per_ton_mean": 3.85, "clinker_factor_mean": 0.80, "co2_kg_per_ton_cement_mean": 650, "cost_usd_per_ton_mean": 95, "export_share_mean": 0.03, "quality_compliance_mean": 0.93, "grid_reliability": 0.55, "gdp_growth_impact": 0.03, }, "Egypt": { "region": "North Africa", "installed_capacity_mt": 90.0, "num_plants": 22, "avg_plant_age_years": 25, "capacity_utilization_mean": 0.58, "coal_share_mean": 0.55, "gas_share_mean": 0.25, "petcoke_share_mean": 0.12, "alt_fuels_share_mean": 0.08, "electrical_kwh_per_ton_mean": 90, "thermal_gj_per_ton_mean": 3.50, "clinker_factor_mean": 0.76, "co2_kg_per_ton_cement_mean": 610, "cost_usd_per_ton_mean": 52, "export_share_mean": 0.15, "quality_compliance_mean": 0.95, "grid_reliability": 0.92, "gdp_growth_impact": 0.02, }, "Morocco": { "region": "North Africa", "installed_capacity_mt": 22.0, "num_plants": 7, "avg_plant_age_years": 28, "capacity_utilization_mean": 0.75, "coal_share_mean": 0.55, "gas_share_mean": 0.10, "petcoke_share_mean": 0.20, "alt_fuels_share_mean": 0.15, "electrical_kwh_per_ton_mean": 88, "thermal_gj_per_ton_mean": 3.45, "clinker_factor_mean": 0.74, "co2_kg_per_ton_cement_mean": 595, "cost_usd_per_ton_mean": 65, "export_share_mean": 0.12, "quality_compliance_mean": 0.97, "grid_reliability": 0.90, "gdp_growth_impact": 0.02, }, "Kenya": { "region": "East Africa", "installed_capacity_mt": 12.0, "num_plants": 6, "avg_plant_age_years": 22, "capacity_utilization_mean": 0.55, "coal_share_mean": 0.50, "gas_share_mean": 0.05, "petcoke_share_mean": 0.25, "alt_fuels_share_mean": 0.20, "electrical_kwh_per_ton_mean": 98, "thermal_gj_per_ton_mean": 3.70, "clinker_factor_mean": 0.77, "co2_kg_per_ton_cement_mean": 630, "cost_usd_per_ton_mean": 85, "export_share_mean": 0.18, "quality_compliance_mean": 0.94, "grid_reliability": 0.82, "gdp_growth_impact": 0.03, }, "Ethiopia": { "region": "East Africa", "installed_capacity_mt": 18.0, "num_plants": 9, "avg_plant_age_years": 12, "capacity_utilization_mean": 0.42, "coal_share_mean": 0.40, "gas_share_mean": 0.05, "petcoke_share_mean": 0.30, "alt_fuels_share_mean": 0.25, "electrical_kwh_per_ton_mean": 102, "thermal_gj_per_ton_mean": 3.80, "clinker_factor_mean": 0.82, "co2_kg_per_ton_cement_mean": 660, "cost_usd_per_ton_mean": 72, "export_share_mean": 0.10, "quality_compliance_mean": 0.91, "grid_reliability": 0.65, "gdp_growth_impact": 0.04, }, "Tanzania": { "region": "East Africa", "installed_capacity_mt": 8.5, "num_plants": 5, "avg_plant_age_years": 15, "capacity_utilization_mean": 0.52, "coal_share_mean": 0.48, "gas_share_mean": 0.12, "petcoke_share_mean": 0.22, "alt_fuels_share_mean": 0.18, "electrical_kwh_per_ton_mean": 100, "thermal_gj_per_ton_mean": 3.75, "clinker_factor_mean": 0.79, "co2_kg_per_ton_cement_mean": 640, "cost_usd_per_ton_mean": 80, "export_share_mean": 0.12, "quality_compliance_mean": 0.92, "grid_reliability": 0.72, "gdp_growth_impact": 0.03, }, "Senegal": { "region": "West Africa", "installed_capacity_mt": 6.0, "num_plants": 4, "avg_plant_age_years": 14, "capacity_utilization_mean": 0.60, "coal_share_mean": 0.52, "gas_share_mean": 0.08, "petcoke_share_mean": 0.22, "alt_fuels_share_mean": 0.18, "electrical_kwh_per_ton_mean": 97, "thermal_gj_per_ton_mean": 3.68, "clinker_factor_mean": 0.77, "co2_kg_per_ton_cement_mean": 625, "cost_usd_per_ton_mean": 88, "export_share_mean": 0.15, "quality_compliance_mean": 0.93, "grid_reliability": 0.70, "gdp_growth_impact": 0.03, }, "Algeria": { "region": "North Africa", "installed_capacity_mt": 28.0, "num_plants": 12, "avg_plant_age_years": 30, "capacity_utilization_mean": 0.62, "coal_share_mean": 0.30, "gas_share_mean": 0.55, "petcoke_share_mean": 0.10, "alt_fuels_share_mean": 0.05, "electrical_kwh_per_ton_mean": 92, "thermal_gj_per_ton_mean": 3.55, "clinker_factor_mean": 0.75, "co2_kg_per_ton_cement_mean": 600, "cost_usd_per_ton_mean": 48, "export_share_mean": 0.06, "quality_compliance_mean": 0.94, "grid_reliability": 0.88, "gdp_growth_impact": 0.02, }, "Cameroon": { "region": "Central Africa", "installed_capacity_mt": 5.5, "num_plants": 4, "avg_plant_age_years": 20, "capacity_utilization_mean": 0.50, "coal_share_mean": 0.42, "gas_share_mean": 0.20, "petcoke_share_mean": 0.25, "alt_fuels_share_mean": 0.13, "electrical_kwh_per_ton_mean": 103, "thermal_gj_per_ton_mean": 3.78, "clinker_factor_mean": 0.80, "co2_kg_per_ton_cement_mean": 645, "cost_usd_per_ton_mean": 92, "export_share_mean": 0.10, "quality_compliance_mean": 0.91, "grid_reliability": 0.62, "gdp_growth_impact": 0.03, }, "Zimbabwe": { "region": "Southern Africa", "installed_capacity_mt": 3.0, "num_plants": 3, "avg_plant_age_years": 38, "capacity_utilization_mean": 0.35, "coal_share_mean": 0.65, "gas_share_mean": 0.02, "petcoke_share_mean": 0.20, "alt_fuels_share_mean": 0.13, "electrical_kwh_per_ton_mean": 110, "thermal_gj_per_ton_mean": 3.95, "clinker_factor_mean": 0.83, "co2_kg_per_ton_cement_mean": 670, "cost_usd_per_ton_mean": 105, "export_share_mean": 0.05, "quality_compliance_mean": 0.88, "grid_reliability": 0.45, "gdp_growth_impact": 0.01, }, "Ghana": { "region": "West Africa", "installed_capacity_mt": 8.0, "num_plants": 5, "avg_plant_age_years": 16, "capacity_utilization_mean": 0.55, "coal_share_mean": 0.48, "gas_share_mean": 0.15, "petcoke_share_mean": 0.22, "alt_fuels_share_mean": 0.15, "electrical_kwh_per_ton_mean": 99, "thermal_gj_per_ton_mean": 3.72, "clinker_factor_mean": 0.78, "co2_kg_per_ton_cement_mean": 635, "cost_usd_per_ton_mean": 82, "export_share_mean": 0.08, "quality_compliance_mean": 0.93, "grid_reliability": 0.75, "gdp_growth_impact": 0.03, }, } # Cement type distribution by region (OPC, PPC, PSC) CEMENT_TYPE_DIST = { "Southern Africa": {"OPC": 0.40, "PPC": 0.45, "PSC": 0.15}, "West Africa": {"OPC": 0.55, "PPC": 0.30, "PSC": 0.15}, "North Africa": {"OPC": 0.60, "PPC": 0.25, "PSC": 0.15}, "East Africa": {"OPC": 0.50, "PPC": 0.35, "PSC": 0.15}, "Central Africa": {"OPC": 0.52, "PPC": 0.33, "PSC": 0.15}, } # --------------------------------------------------------------------------- # Scenario modifiers # --------------------------------------------------------------------------- SCENARIOS = { "baseline": { "description": "Normal operations reflecting current African cement industry conditions (2024-2025)", "capacity_utilization_mult": 1.0, "energy_efficiency_mult": 1.0, "co2_mult": 1.0, "cost_mult": 1.0, "alt_fuels_add": 0.0, "downtime_mult": 1.0, "quality_mult": 1.0, "demand_mult": 1.0, }, "energy_crisis": { "description": "Energy supply disruptions, fuel price spikes, grid instability (modelled on South Africa load-shedding, Nigeria gas shortages)", "capacity_utilization_mult": 0.78, "energy_efficiency_mult": 1.18, "co2_mult": 1.12, "cost_mult": 1.35, "alt_fuels_add": 0.03, "downtime_mult": 1.6, "quality_mult": 0.95, "demand_mult": 0.88, }, "green_transition": { "description": "Accelerated adoption of alternative fuels, energy efficiency upgrades, carbon reduction initiatives aligned with GCCA 2050 net-zero roadmap", "capacity_utilization_mult": 0.92, "energy_efficiency_mult": 0.88, "co2_mult": 0.72, "cost_mult": 1.15, "alt_fuels_add": 0.20, "downtime_mult": 1.25, "quality_mult": 1.02, "demand_mult": 1.08, }, } # --------------------------------------------------------------------------- # Helper functions # --------------------------------------------------------------------------- def generate_plant_id(country, idx): return f"{country[:3].upper()}-{idx:03d}" def generate_monthly_timestamps(start_year=2020, end_year=2025): """Generate monthly timestamps.""" timestamps = [] for year in range(start_year, end_year + 1): for month in range(1, 13): timestamps.append(datetime(year, month, 1)) return timestamps def generate_plant_data(country_name, plant_idx, scenario_name, scenario_cfg, timestamps): """Generate time-series data for a single plant under a scenario.""" cfg = COUNTRIES[country_name] region = cfg["region"] records = [] plant_age_base = cfg["avg_plant_age_years"] + np.random.normal(0, 5) plant_age_base = max(3, min(50, plant_age_base)) # Plant-specific efficiency factor (newer plants are more efficient) age_efficiency = 1.0 - (plant_age_base - 15) * 0.003 # Capacity per plant capacity_per_plant = cfg["installed_capacity_mt"] / cfg["num_plants"] # Grinding capacity (typically 10-20% higher than clinker capacity) grinding_capacity_mt = capacity_per_plant * np.random.uniform(1.08, 1.22) for ts in timestamps: # Seasonal variation (construction is higher in dry seasons) month = ts.month if region in ["West Africa", "Central Africa", "East Africa"]: # Dry season boost: Nov-Mar seasonal = 1.0 + 0.08 * np.cos(2 * np.pi * (month - 1) / 12) elif region == "Southern Africa": # Dry season: Apr-Oct seasonal = 1.0 + 0.06 * np.cos(2 * np.pi * (month - 7) / 12) elif region == "North Africa": # Milder seasonal effect seasonal = 1.0 + 0.03 * np.cos(2 * np.pi * (month - 3) / 12) else: seasonal = 1.0 # Year-over-year improvement (gradual efficiency gains) yoy_improvement = 1.0 - (ts.year - 2020) * 0.008 # Random noise noise = np.random.normal(1.0, 0.04) # Capacity utilization base_util = cfg["capacity_utilization_mean"] util = base_util * scenario_cfg["capacity_utilization_mult"] * seasonal * yoy_improvement * noise util = np.clip(util, 0.15, 0.95) # Clinker production (tons/month) clinker_production = capacity_per_plant * util * (1_000_000 / 12) clinker_production = max(500, clinker_production) # Energy consumption elec_kwh = cfg["electrical_kwh_per_ton_mean"] * age_efficiency * scenario_cfg["energy_efficiency_mult"] elec_kwh *= np.random.normal(1.0, 0.06) elec_kwh = max(60, min(140, elec_kwh)) thermal_gj = cfg["thermal_gj_per_ton_mean"] * age_efficiency * scenario_cfg["energy_efficiency_mult"] thermal_gj *= np.random.normal(1.0, 0.05) thermal_gj = max(2.8, min(4.8, thermal_gj)) # Fuel mix coal_share = cfg["coal_share_mean"] gas_share = cfg["gas_share_mean"] petcoke_share = cfg["petcoke_share_mean"] alt_share = cfg["alt_fuels_share_mean"] + scenario_cfg["alt_fuels_add"] # Add some plant-level variation fuel_noise = np.random.normal(0, 0.03, 4) coal_share = max(0.10, min(0.85, coal_share + fuel_noise[0])) gas_share = max(0.0, min(0.60, gas_share + fuel_noise[1])) petcoke_share = max(0.02, min(0.40, petcoke_share + fuel_noise[2])) alt_share = max(0.0, min(0.45, alt_share + fuel_noise[3])) # Normalize to sum to 1 total_fuel = coal_share + gas_share + petcoke_share + alt_share coal_share /= total_fuel gas_share /= total_fuel petcoke_share /= total_fuel alt_share /= total_fuel # CO2 emissions per ton of cement # Process emissions from clinker (~0.52 tCO2/t clinker) + fuel combustion base_co2 = cfg["co2_kg_per_ton_cement_mean"] co2_intensity = base_co2 * scenario_cfg["co2_mult"] * age_efficiency # Alt fuels reduce CO2 co2_intensity *= (1.0 - alt_share * 0.15) co2_intensity *= np.random.normal(1.0, 0.04) co2_intensity = max(420, min(800, co2_intensity)) # Maintenance downtime (hours/month) base_downtime = 24 + np.random.exponential(12) downtime = base_downtime * scenario_cfg["downtime_mult"] # Older plants have more downtime downtime *= (1.0 + (plant_age_base - 15) * 0.01) downtime = max(4, min(120, downtime)) # Quality compliance rate quality = cfg["quality_compliance_mean"] * scenario_cfg["quality_mult"] quality *= np.random.normal(1.0, 0.015) quality = np.clip(quality, 0.75, 0.999) # Cement type distribution type_dist = CEMENT_TYPE_DIST[region] opc_share = type_dist["OPC"] + np.random.normal(0, 0.03) ppc_share = type_dist["PPC"] + np.random.normal(0, 0.03) psc_share = type_dist["PSC"] + np.random.normal(0, 0.02) total_type = opc_share + ppc_share + psc_share opc_share /= total_type ppc_share /= total_type psc_share /= total_type # Cost per ton (USD) cost = cfg["cost_usd_per_ton_mean"] * scenario_cfg["cost_mult"] cost *= np.random.normal(1.0, 0.08) # Inflation cost *= (1.0 + (ts.year - 2020) * 0.04) cost = max(30, min(180, cost)) # Sales volumes total_cement = clinker_production * cfg["clinker_factor_mean"] * np.random.normal(1.0, 0.03) export_share = cfg["export_share_mean"] * np.random.normal(1.0, 0.15) export_share = np.clip(export_share, 0.0, 0.35) export_volumes = total_cement * export_share * scenario_cfg["demand_mult"] domestic_sales = total_cement * (1 - export_share) * scenario_cfg["demand_mult"] record = { "plant_id": generate_plant_id(country_name, plant_idx), "country": country_name, "region": region, "scenario": scenario_name, "timestamp": ts.strftime("%Y-%m-%d"), "year": ts.year, "month": ts.month, "plant_age_years": round(plant_age_base + (ts.year - 2020), 1), "installed_capacity_mt": round(capacity_per_plant, 2), "grinding_capacity_mt": round(grinding_capacity_mt, 2), "capacity_utilization": round(util, 4), "clinker_production_tons": round(clinker_production, 1), "cement_production_tons": round(total_cement, 1), "electrical_energy_kwh_per_ton": round(elec_kwh, 2), "thermal_energy_gj_per_ton": round(thermal_gj, 3), "fuel_coal_share": round(coal_share, 4), "fuel_gas_share": round(gas_share, 4), "fuel_petcoke_share": round(petcoke_share, 4), "fuel_alternative_share": round(alt_share, 4), "co2_kg_per_ton_cement": round(co2_intensity, 2), "total_co2_tons_monthly": round(co2_intensity * total_cement / 1000, 2), "maintenance_downtime_hours": round(downtime, 1), "quality_compliance_rate": round(quality, 4), "cement_type_opc_share": round(opc_share, 4), "cement_type_ppc_share": round(ppc_share, 4), "cement_type_psc_share": round(psc_share, 4), "cost_usd_per_ton": round(cost, 2), "export_volumes_tons": round(export_volumes, 1), "domestic_sales_tons": round(domestic_sales, 1), "total_revenue_usd": round(cost * total_cement * np.random.uniform(0.95, 1.15), 0), } records.append(record) return records def generate_dataset(output_dir, target_records=15000): """Generate the full dataset.""" os.makedirs(output_dir, exist_ok=True) timestamps = generate_monthly_timestamps(2020, 2025) all_records = [] # Calculate how many plants per country to hit target total_plants = sum(c["num_plants"] for c in COUNTRIES.values()) # We'll generate all plants across all scenarios # Each plant * 72 months * 3 scenarios # If that exceeds target, we sample; if less, we add more plants for country_name, country_cfg in COUNTRIES.items(): num_plants = country_cfg["num_plants"] for plant_idx in range(1, num_plants + 1): for scenario_name, scenario_cfg in SCENARIOS.items(): records = generate_plant_data( country_name, plant_idx, scenario_name, scenario_cfg, timestamps ) all_records.extend(records) df = pd.DataFrame(all_records) # If we have more than target, we can keep all (more is better) # If fewer, we'd need to add more plants, but our config should exceed 15k print(f"Generated {len(df)} records across {df['country'].nunique()} countries, " f"{df['plant_id'].nunique()} plants, {df['scenario'].nunique()} scenarios") # Split by scenario for scenario_name in SCENARIOS: scenario_df = df[df["scenario"] == scenario_name].reset_index(drop=True) output_path = os.path.join(output_dir, f"{scenario_name}.csv") scenario_df.to_csv(output_path, index=False) print(f" {scenario_name}: {len(scenario_df)} records -> {output_path}") # Save metadata metadata = { "dataset_name": "African Cement Plant Operations", "description": "Comprehensive dataset of cement plant operations across 12 African countries with baseline, energy crisis, and green transition scenarios", "version": "1.0.0", "generated_at": datetime.now().isoformat(), "total_records": len(df), "countries": list(COUNTRIES.keys()), "scenarios": list(SCENARIOS.keys()), "time_range": "2020-01 to 2025-12", "num_plants": df["plant_id"].nunique(), "features": list(df.columns), "references": [ "USGS Mineral Industry of Africa (2019-2024)", "Dangote Cement Annual Reports 2024-2025", "GCCA Cement Industry Net Zero Progress Report 2024/25", "IEA Cement Energy System Analysis", "African Development Bank Infrastructure Reports", "Global Cement Magazine Top 100 2026", "Natural Resources Canada: Cement Clinker Energy Benchmark Guide", "MDPI: Alternative Fuels Substitution in Cement Industries (2023)", "Discover Applied Sciences: Ethiopian GHG Cement Emission Factors (2025)", "World Cement: Sub-Saharan Africa Industry Reports (2025)", ], "scenario_configs": { "baseline": SCENARIOS["baseline"]["description"], "energy_crisis": SCENARIOS["energy_crisis"]["description"], "green_transition": SCENARIOS["green_transition"]["description"], }, "country_configs": { name: { "region": cfg["region"], "installed_capacity_mt": cfg["installed_capacity_mt"], "num_plants": cfg["num_plants"], "avg_plant_age_years": cfg["avg_plant_age_years"], "capacity_utilization_mean": cfg["capacity_utilization_mean"], "co2_kg_per_ton_cement_mean": cfg["co2_kg_per_ton_cement_mean"], "cost_usd_per_ton_mean": cfg["cost_usd_per_ton_mean"], } for name, cfg in COUNTRIES.items() }, } metadata_path = os.path.join(output_dir, "metadata.json") with open(metadata_path, "w") as f: json.dump(metadata, f, indent=2) return df, metadata if __name__ == "__main__": output_dir = os.path.dirname(os.path.abspath(__file__)) df, metadata = generate_dataset(output_dir) print(f"\nDataset generation complete!") print(f"Total records: {len(df)}") print(f"Files written to: {output_dir}")