electricitymaps / electricitymaps-contrib

A real-time visualisation of the CO2 emissions of electricity consumption
https://app.electricitymaps.com
GNU Affero General Public License v3.0
3.46k stars 923 forks source link

aggregated view CO2 sum seems strange, yearly CO2 sum probably not updated after emission factor correction #6313

Closed w-flo closed 8 months ago

w-flo commented 8 months ago

Describe the bug When looking at the "aggregated" CO2 emission data for a country, the sum given in the yearly bar chart at the bottom and in tooltips does not seem to correspond to the individual numbers displayed in the bar chart at the top for different power plant types.

This might also affect the "CO2 intensity" data shown in the other (left) tab for power production.

To Reproduce

Expected behavior I would expect both methods to result in the same number. Or if there is some reason for the discrepancy: Maybe an explanation or an additional bar in the upper bar chart, to contain the missing 8 Mt of emissions.

Desktop (if relevant):

Additional context It might be related to the recent change of natural gas emission factors for Germany / Europe. I noticed this while trying to find out why the drop in CO2 intensity caused by that change wasn't as pronounced as I had expected (maybe there was no drop at all, I don't remember the exact value from a few days ago), so maybe that sum for 2023 simply is the old value from before the emission factor update.

VIKTORVAV99 commented 8 months ago

Is this in consumption or production mode?

It's likely that if this is in consumption mode that Germany exported more carbon than they imported which makes up the discrepancy. Exchanges are currently not shown (some more work needed to make that happen) but the values for carbon emissions are calculated from our hourly values that contain the exchange data. (Exchange data is currently not aggregated).

w-flo commented 8 months ago

Oh yeah, I looked at production mode for this reproducer. So import / export shouldn't really matter for these numbers, right?

However, the steps described in the repro section above seem to be independent of consumption / production mode. They don't change when I switch to consumption mode, it's still 194 Mt of CO2eq emissions.

VIKTORVAV99 commented 8 months ago

They should change... But it seems like they indeed don't. I'll have to look further into this.

w-flo commented 8 months ago

Looking into this a bit more, it seems like the emission sum matches my manual calculation (as described above) for 2019, 2020, 2021. There is a discrepancy in 2022 and 2023 only.

Now, regarding the 2022 numbers, the gas emissions are given as 30.6 Mt. This is using the updated gas emission factor of of 572g/kWh for Germany. Manually calculating the emissions using the previous, incorrect emission factor of 733 and generation of 53.3 TWh results in emissions of 39.2 Mt, which is 8.6 Mt more than the updated value.

The difference between my manually calculated sum for total emissions in 2022 (242.5 Mt) and the sum given by electricitymaps (251 Mt) happens to be 8.5 Mt, so it matches the old/new gas emission factor difference almost exactly.

The same calculation works for 2023.

I believe this strongly supports my suspicion that the emission sum was not updated after the gas emission factor fix for 2022+ in #6308

VIKTORVAV99 commented 8 months ago

The monthly and yearly aggregations are updated once per month, so these should be updated in February. I do think we have already re-run flow tracing for all historical dates affected by it but I'll double check just to be sure.

w-flo commented 8 months ago

Oh, that's probably why the numbers don't add up for me.

So waiting for the February update should hopefully fix this issue. Thank you @VIKTORVAV99 ! :-)

I'm closing this issue since everything seems to be working as intended. (Of course I'd welcome manually triggering the aggregations update now to fix them after #6308, but if it's computationally expensive or difficult, waiting a few weeks is fine.)

VIKTORVAV99 commented 8 months ago

I took a look if we have a easy way to re-compute these ahead of time but it seems like we don't using our internal tools and I don't really want to go an poke around the system directly. So unfortunately we'll have to wait a bit until feb. But I'll make sure all the flow tracing has been run before that at least.

w-flo commented 7 months ago

Thanks for taking a look!