# To make a new chart download, amend and run on Python, don't forget to upload the amended code
# If you have time please check 2019 and previous data (as was from teias) and ADD 2014 to show EFFECTS OF DROUGHT THAT YEAR.
# When amending please keep colors and order same as energy graph e.g. order oil, coal, gas, hydro, geo, solar, wind, other
import numpy as np
import matplotlib.pyplot as plt
import sys
import seaborn as sns
lang = "en"
#lang = "tr"
# Data from https://www.epdk.gov.tr/Detay/Icerik/1-1271/electricityreports for each year
# For example 2021 page iv: Installed Capacity and Production by Resources by the end of 2021
year = ['2015','2016','2017','2018','2019','2020','2021','2022']
# Copied and pasted from above and manually rounded to nearest whole number and removed dots
Import_Coal = [39986,47718 ,51118, 62989, 60398, 62466, 54889, 63260]
HardCoal_Aspahaltite = [ 4844, 5985 , 5664, 5173, 5627, 3416 + 2222, 3540 + 2373, 3242 + 1568]
Lignite = [31336,38570 ,40694, 45087, 46872, 38164, 43400, 44746]
# Combine different types of coal
# Could not see how to add more than 2 arrays
Coal = np.add(Import_Coal,HardCoal_Aspahaltite).tolist()
Coal = np.add(Coal ,Lignite ).tolist()
# From 2021 both licensed + unlicensed
Natural_Gas = [99219, 89227, 110490, 92483, 57288, 69278, 108394 + 44, 70804 + 23]
FuelOil_Naptha_LNG_Diesel = [ 2224, 1926, 1200, 329, 336, 313 + 0 + 0 + 1, 337, 719 + 2386]
# Before 2020 data was from teias - this could be replaced below in Hydraulic if you have time
Barajlı = [47514,48962 ,41313, 40972, 65926]
D_Göl_Akarsu = [19639,18269 ,16906, 18966, 22897]
# Combine different types of hydro
Hydraulic = np.add(Barajlı,D_Göl_Akarsu).tolist()
#Append 2020 onwards
Hydraulic.append(78115)
# 2021 licensed + unlicensed
Hydraulic.append(55656 + 34)
# 2022 licensed + unlicensed
Hydraulic.append(67124 + 72)
# From 2021 both licensed + unlicensed
Wind = [11653,15517 ,17904, 19950, 21731, 24681, 30990 + 118, 34991 + 150]
# In earlier years instead of Yenilenebilir Atık added Biyokütle. From 2020 "biomass"
# From 2021 both licensed + unlicensed
Biomass = [1350 + 408 ,2372, 2124 + 848, 3623, 4624, 5502, 7371 + 251, 8948 + 132]
Geothermal = [3425, 4819 , 6128, 7431, 8952, 9929, 10771, 10919]
# From 2021 both licensed + unlicensed
Solar = [ 194, 1043 , 2889, 7800, 9250, 11242, 1552 + 11546, 3074 + 12363]
# Lump liquid fuel and waste as other because they are so small
Other = np.add(FuelOil_Naptha_LNG_Diesel,Biomass).tolist()
# Convert to TWh as easier to read
coal = np.divide(Coal, 1000).tolist()
gas = np.divide(Natural_Gas,1000).tolist()
hydro = np.divide(Hydraulic, 1000).tolist()
wind = np.divide(Wind, 1000).tolist()
geothermal = np.divide(Geothermal, 1000).tolist()
solar = np.divide(Solar, 1000).tolist()
other = np.divide(Other, 1000).tolist()
if lang == "en":
plt.title ("Electricity generation by source in Turkey")
plt.ylabel("Terawatt hours")
label_coal = "coal"
label_gas = "gas"
label_geothermal = "geothermal"
label_hydro = "hydro"
label_other = "other"
label_solar = "solar"
label_wind = "wind"
plt.xlabel("Data: https://www.epdk.gov.tr/Detay/Icerik/3-0-24/elektrikyillik-sektor-raporu", fontsize = 'small', color = 'grey')
elif lang == "tr":
plt.title (" Birincil Kaynaklara göre Elektrik Enerjisi Üretimi")
plt.ylabel("Terawatt-saat")
label_coal = "kömür"
label_gas = "gaz"
label_geothermal = "jeotermal"
label_hydro = "hidrolik"
label_other = "diğer"
label_solar = "güneş"
label_wind = "rüzgar"
plt.xlabel("Kaynak: https://www.epdk.gov.tr/Detay/Icerik/3-0-24/elektrikyillik-sektor-raporu", fontsize = 'small', color = 'grey')
else:
print("Unknown language " + lang)
sys.exit()
colors = ["brown","khaki","cornflowerblue","red","yellow","green","gray"]
plt.stackplot(year, coal, 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,325,label_other, fontsize = 'small')
plt.text(7.1,300,label_wind, fontsize = 'small')
plt.text(7.1,270,label_solar,fontsize = 'small')
plt.text(7.1,250,label_geothermal, fontsize = 'small')
plt.text(7.1,230,label_hydro, fontsize = 'large')
plt.text(7.1,140,label_gas, fontsize = 'large')
plt.text(7.1, 40,label_coal, fontsize = 'large')
#Don't need the frame
sns.despine(bottom = True, left = True)
# Save graphic
if lang == "en":
plt.savefig('electricity_Turkey.svg')
elif lang == "tr":
plt.savefig("elektriği_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?country=TURKEY&fuel=Electricity%20and%20heat&indicator=ElecGenByFuel but perhaps not exactly the same if Turkstat have revised their figures