#So can save on ipad
import console
import logging
logging.basicConfig(level=logging.INFO) # can be commented out when not debugging
import matplotlib.pyplot as plt
import sys
lang = "en"
#lang = "tr"
#If text changed in future default size may chop off part of text so may need to set size
#fig = plt.figure(figsize=(width, height))
#fig = plt.figure(figsize=(6, 4))
fig = plt.figure()
# Set font size as default was a bit small to read
fontsize = 13
#Get current axes object
ax = fig.gca()
# Global warming potentials (GWP 100) to compare other gases with CO2 -
# from https://www.ipcc.ch/report/ar6/wg1/downloads/report/IPCC_AR6_WGI_Chapter_07_Supplementary_Material.pdf
# 7.SM.6 Tables of greenhouse gas lifetimes, radiative efficiencies and metrics
GWP_CH4 = 27.9
GWP_N2O = 273
data_source = 'https://unfccc.int/documents/656426'
#2024 data from Turkey. 2026 Common Reporting Format (CRF) Table
#New data yearly so please update above url on 15 April 2027 from https://unfccc.int/process-and-meetings/transparency-and-reporting/reporting-and-review-under-the-convention/greenhouse-gas-inventories-annex-i-parties/national-inventory-submissions-2027
year = "2024"
# Column letters below are ipad Numbers - on excel they may be the previous letter.
# TABLE 1.A(a) SECTORAL BACKGROUND DATA FOR ENERGY sheet 1
# Electricity Generation Solid Fuels
# kt CO2
# Current spreadsheet cell H33 (H26 includes Combined Heat and Power)
Electricity_coal = 121071.12
# Electricity Generation Gaseous Fuels
# H34 (H27 includes Combined Heat and Power)
Electricity_gas = 22975.56
# sheet 3 Road transportation
# H20 (cars and lorries have rows below but there is no data in them - check next year to see if can split)
# If not maybe best to continue splitting by fuel below
# Road_transport = 95112.06
# H21 Gasoline
Petrol = 14685.46
# Actually for 2024 non-residential buildings are very slightly more but I think within margin of error - put this here as it seems certain from #Climate Trace that petrol will be more in 2025
# H22
Diesel = 69954.14
# sheet 4 Residential H37
Home_fuel = 50956.33
# TABLE 2(I).A-H sheet 1 SECTORAL BACKGROUND DATA FOR INDUSTRIAL PROCESSES AND PRODUCT USE
# H11 (cement production)
Cement = 44781.64
# TABLE 3.A SECTORAL BACKGROUND DATA FOR AGRICULTURE G10 Enteric fermentation 1. Cattle
Cattle_enteric_fermentation = 1067.20 * GWP_CH4 # Convert methane to CO2eq
# TABLE 3.B(a) SECTORAL BACKGROUND DATA FOR AGRICULTURE
# K10 for CH4
# TABLE 3.B(b) SECTORAL BACKGROUND DATA FOR AGRICULTURE
# X10 for N2O
# Manure management 1. Cattle
Cattle_manure = (183.33 * GWP_CH4) + (6.19 * GWP_N2O)
Cattle = Cattle_enteric_fermentation + Cattle_manure
# Total without LULUCF from National Inventory Report table ES 1 or elsewhere
total_Mt = 584.5
total = total_Mt * 1000
logging.info('%s Electricity_coal', Electricity_coal)
logging.info('%s Diesel', Diesel)
#logging.info('%s Road_transport', Road_transport)
logging.info('%s Home_fuel', Home_fuel)
logging.info('%s Cement', Cement)
logging.info('%s Cattle', Cattle)
logging.info('%s Electricity_gas', Electricity_gas)
logging.info('%s Petrol', Petrol)
#Other = total - (Electricity_coal + Road_transport + Cattle + Home_fuel + Cement + Electricity_gas)
Other = total - (Electricity_coal + Diesel + Petrol + Cattle + Home_fuel + Cement + Electricity_gas)
#Put in order of size to make easier to compare
percents = [Electricity_coal, Diesel, Home_fuel, Cement, Cattle, Electricity_gas, Petrol, Other]
colors = [
'dimgrey',
'grey',
'darkgrey',
'silver',
'lightgrey',
'gainsboro',
'whitesmoke',
'white']
# Or from https://learnui.design/tools/data-color-picker.html#palette can pick e.g.
#colors = ['#6d5d42',
#'#796748',
#'#86714d',
#'#937c53',
#'#a08658',
#'#ae915e',
#'#bb9c64',
#'whitesmoke']
#colors = ['#4f4c4c', '#7e5853', '#a86452', '#cd7548', '#eb8a34', '#ffa600', 'whitesmoke']
if lang == "en":
plt.title ("Greenhouse gases largest sources in Turkey " + year, fontsize = fontsize)
# % sign after number in English
custom_autopct = lambda pct: ('%1.0f%%' % pct) if pct < 30 else '' # Kludge to avoid printing percent for the 'other' white slice
labels = ['Electricity (coal)','Diesel','Home fuel','Cement','Cattle','Electricity (gas)','Petrol','']
data_source = 'Source: Turkish Statistical Institute ' + data_source
elif lang == "tr":
plt.title (year + " Türkiye'de sera gazı emisyon kaynakları", fontsize = fontsize)
# % sign before number in Turkish
custom_autopct = lambda pct: ('%%%1.0f' % pct) if pct < 30 else '' # Kludge to avoid printing percent for the 'other' white slice
labels = ['Kömürden Elektrik', 'Mazot' , 'Konut Isıtma', 'Çimento','İnekler','Doğalgazdan Elektrik', 'Benzin', '']
data_source = 'Kaynak: Türkiye İstatistik Kurumu ' + data_source
else:
print("Unknown language " + lang)
sys.exit()
plt.xlabel(data_source, fontsize = 'small', color = 'grey')
#ax.pie(percents, labels=labels, textprops={'fontsize': fontsize}, colors=colors, counterclock=False, startangle=90)
ax.pie(percents, labels=labels, textprops={'fontsize': 10}, colors=colors, autopct=custom_autopct, startangle=90)
if lang == "en":
plt.savefig('ghg_pie_chart_Turkey.svg')
console.open_in('ghg_pie_chart_Turkey.svg') # Opens the Share Sheet for the file on ipad
elif lang == "tr":
plt.savefig('sera_gazlar_dairesel_grafik_Türkiye.svg')
console.open_in('sera_gazlar_dairesel_grafik_Türkiye.svg') # Opens the Share Sheet for the file on ipad
else:
print("Unknown language " + lang)
sys.exit()
#plt.show()