# When amending please keep colors and order same as energy graph
lang = "en"
#lang = "tr"
import numpy as np
import matplotlib.pyplot as plt
import sys
import seaborn as sns
# Data from https://enerji.gov.tr/eigm-raporlari Ulusal Enerji Denge Tabloları Sheet:BİN TEP yyyy Row 12:Enerji̇ Ürünleri̇ Arzi
year = ['2014','2015','2016','2017','2018','2019','2020','2021']
Taş_Kömürü = [20199, 22428, 23597, 24707, 24679, 25120, 25449, 23444]
Linyit = [12702, 11446, 13556, 13791, 15086, 15453, 13863, 16672]
Asfaltit = [ 372, 499, 778, 555, 697, 1022, 979, 707]
Kok = [ 234, 299, 527, 504, 513, 420, 430, 744]
# Combine different types of coal
# Could not see how to add more than 2 arrays
Kömür = np.add(Taş_Kömürü,Linyit).tolist()
Kömür = np.add(Kömür, Asfaltit).tolist()
Kömür = np.add(Kömür, Kok).tolist()
Ham_Petrol = [20802, 28015, 28709, 29491, 25099, 35448, 34393, 36241]
Petrol_Ürünleri = [10823, 11194, 13495, 14786, 16814, 6006, 7797, 7742]
# Combine different types of oil
Petrol = np.add(Ham_Petrol,Petrol_Ürünleri).tolist()
Doğalgaz = [40201, 39651, 38338, 44319, 41171, 37128, 39806, 49231]
#Other (Diğer) is Bio and waste and may be wrong as not sure how to add up early years as categories changed for bio and waste
Diğer = [ 3495, 2938, 2843, 2531, 3014, 3157, 3396, 4099]
Hidrolik = [ 3495, 5775, 5782, 5007, 5155, 7639, 6716, 4810]
Rüzgar = [ 733, 1002, 1334, 1540, 1716, 1869, 2135, 2704]
Jeotermal = [ 3524, 4805, 6034, 7128, 8343, 9651, 10576, 11234]
Güneş = [ 803, 828, 917, 1091, 1547, 1622, 1784, 2059]
# Convert to megatonnes as easier to read
coal = np.divide(Kömür, 1000).tolist()
oil = np.divide(Petrol, 1000).tolist()
gas = np.divide(Doğalgaz, 1000).tolist()
other = np.divide(Diğer, 1000).tolist()
hydro = np.divide(Hidrolik, 1000).tolist()
wind = np.divide(Rüzgar, 1000).tolist()
geothermal = np.divide(Jeotermal, 1000).tolist()
solar = np.divide(Güneş, 1000).tolist()
if lang == "en":
plt.title ("Primary energy supply in Turkey")
plt.ylabel("Millions of tonnes of oil equivalent")
plt.xlabel('Source: https://enerji.gov.tr/eigm-raporlari Ulusal Enerji Denge Tabloları Sheet:BİN TEP yyyy Row 12:Enerji̇ Ürünleri̇ Arzi', fontsize = 'x-small', color = 'grey')
label_coal = "coal"
label_oil = "oil"
label_gas = "gas"
label_geothermal = "geothermal"
label_hydro = "hydro"
label_other = "other"
label_solar = "solar"
label_wind = "wind"
elif lang == "tr":
plt.title ("Türkiye'de birincil enerji arzı")
plt.ylabel("Milyon TEP")
labels = ["Kömür", "Petrol", "Doğalgaz", "Jeotermal", "Hidrolik", "Biyoenerji_ve_Atıklar", "Güneş", "Rüzgar"]
plt.xlabel('Kaynak: https://enerji.gov.tr/eigm-raporlari Ulusal Enerji Denge Tabloları Tablo:BİN TEP yyyy Satır 12:Enerji̇ Ürünleri̇ Arzi', fontsize = 'x-small', color = 'grey')
label_coal = "kömür"
label_oil = "petrol"
label_gas = "gaz"
label_geothermal = "jeotermal"
label_hydro = "hidrolik"
label_other = "diğer"
label_solar = "güneş"
label_wind = "rüzgar"
else:
print("Unknown language " + lang)
sys.exit()
colors = ["brown","black","khaki","cornflowerblue","red","yellow","green","gray"]
plt.stackplot(year, coal, oil, gas, hydro, geothermal, solar, wind, other, colors=colors)
#Position labels manually to make them quicker to read than a legend in a corner - might need slight adjustment as years added
plt.text(7.1,160,label_other, fontsize = 'small')
plt.text(7.1,155,label_wind, fontsize = 'small')
plt.text(7.1,150,label_solar, fontsize = 'small')
plt.text(7.1,143,label_geothermal, fontsize = 'small')
plt.text(7.1,136,label_hydro, fontsize = 'small')
plt.text(7.1,113,label_gas, fontsize = 'large')
plt.text(7.1, 60,label_oil, fontsize = 'large')
plt.text(7.1, 18,label_coal, fontsize = 'large')
#Avoid chopping off labels
plt.tight_layout()
#Don't need the frame
sns.despine(bottom = True, left = True)
#Don't need the dash marks
plt.tick_params(left=False, bottom=False)
# Save graphic
if lang == "en":
plt.savefig("primary_energy_Turkey.svg")
elif lang == "tr":
plt.savefig("birincil_enerji_arzı_Türkiye.svg")
else:
print("Unknown language " + lang)
sys.exit()
# Show graphic
plt.show()
# Resulting graph should be roughly similar to graph "Total primary energy supply (TPES) by source, Turkey"
# from https://www.iea.org/data-and-statistics but perhaps not exactly the same if Turkstat have revised their figures