-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPeak_to_Base_Creation_Hybrid_Microgrids.py
72 lines (43 loc) · 1.85 KB
/
Peak_to_Base_Creation_Hybrid_Microgrids.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# -*- coding: utf-8 -*-
"""
Created on Thu Aug 13 19:28:42 2020
@author: Dell
"""
import pandas as pd
from joblib import load
import matplotlib.pyplot as plt
data = pd.read_csv('Onsset_Scenarios/onsset/Bolivia/bo-1-0_0_0_0_0_0.csv', index_col=0)
independant_variables = pd.read_csv('Onsset_Scenarios/onsset/Bolivia/Independent_Variables2025.csv', index_col=0)
Base_to_Peak = 0.000001
X = independant_variables['HouseHolds']
X = pd.DataFrame(X)
#'Demand_Name'
Base_To_Peak_Villages = pd.DataFrame(index=data.index)
Base_To_Peak_Villages['Base_To_Peak_Ratio'] = Base_to_Peak
path = 'Peak_to_Base.joblib'
Base_To_Peak_Function = load(path)
Base_to_Peak_Values = pd.DataFrame(Base_To_Peak_Function.predict(X))
constraints = pd.DataFrame()
constraints['elevation'] = list(data['Elevation'] < 800)
constraints['HouseHold minor'] = list(X['HouseHolds'] < 550)
constraints['HouseHold mayor'] = list(X['HouseHolds'] >= 50)
constraints['Values'] = constraints.all(axis=1)
Base_To_Peak_Villages.loc[constraints['Values'] ,'Base_To_Peak_Ratio'] = round(Base_to_Peak_Values[0],2)
test = Base_to_Peak_Values.loc[constraints['Values']]
test['HouseHolds'] = X['HouseHolds'].loc[constraints['Values']]
Demand = pd. DataFrame()
for i in range(50, 570,50):
Village = 'village_' + str(i)
Energy_Demand = pd.read_excel('Example/Demand.xls',sheet_name=Village
,index_col=0,Header=None)
Demand[i] = Energy_Demand[1]
Demand_mean = Demand.mean()
Demand_max = Demand.max()
Peak_to_Base = Demand_mean/Demand_max
plt.scatter(test['HouseHolds'], test[0])
plt.scatter(Peak_to_Base.index,Peak_to_Base)
plt.xlabel('HouseHolds')
plt.ylabel('Peak to base ratio')
Base_To_Peak_Villages.to_csv('Onsset_Scenarios/onsset/Bolivia/Base_to_Peak_Hybrid_MicroGrid.csv')
df = constraints.loc[constraints['Values']==True]
print(len(df))