# nigeria_generation_by_fuel_latest.csv methodology

## Source
- **File**: `energy_databank_generation_by_plant.csv`
- **Document**: Nigerian Energy Data Bank – Power Plant Generation
- **Publisher**: Nigerian Energy Data Bank (databank.energy.gov.ng)
- **URL/Path**: `C:\Users\HP\palmgrove\NEFDB\datasets\grid_electricity\energy_databank_generation_by_plant.csv`

## Correction applied
For every row where `plant_code` or `plant_name` equals `ELPD_NESCO_GEN`, the `generation_mwh` value was divided by **1,000** before aggregation.
This fixes a unit-scale error in the source portal: the NESCO series is labelled `MWh` but appears to be stored in `kWh`.
Applying the correction changes the 2020 NESCO value from **75,593,010 MWh** to **75,593.01 MWh** (75.59301 GWh).

## Extraction steps
1. Read CSV with columns `code`, `description`, `year`, `value`, `unit`.
2. Identify latest complete calendar year: **2020** (the most recent year with both gas and hydro generation records).
3. Filter to rows where `unit == 'MWh'` and `description` contains 'Generation'.
4. Divide all `ELPD_NESCO_GEN` values by 1,000.
5. Classify each plant to a normalized fuel:
   - **gas**: plant name/description contains AFAM, ALAOJI, CALABAR, GBARAIN, GEREGU, IHOVBOR, OGORODE, OLORUNSOGO, OMOTOSHO, or 'Gas'.
   - **hydro**: plant name/description contains JEBBA, KAINJI, NESCO, SHIRORO, 'Hydro', 'Water', or 'Reservoir'.
   - **solar**: contains 'solar' or 'pv'.
   - **wind**: contains 'wind'.
   - **coal**: contains 'coal'.
   - **biomass**: contains 'biomass'.
   - **oil**: contains 'oil', 'diesel' or 'fuel'.
   - **other**: anything not matching the above.
6. Sum `value` per fuel and divide by 1,000 to convert MWh to GWh.

## Sanity check
- Computed total: 7357.30420 GWh
- Plant-level total: 7357.30420 GWh
- Difference: 0.000000%
- Hydro total for 2020: 75.59301 GWh (plausible Nigerian hydro range for 2020 ~8,500–9,500 GWh; current figure is far outside because Kainji/Jebba/Shiroro generation records are excluded)

## Confidence
- gas: high
- hydro: low (incomplete and far below independent estimates)
