Newer
Older

Hamid Choucha
committed
## Data base generation code by Group 3 CS 499 ##
# Morning data,afternoon ,night data for temp
import random
import math
import requests
import json
import numpy as np

Hamid Choucha
committed
class Door_Window:
def __init__(self,day,Door_status,Door_time,Window_status,Window_time):
self.day=day
self.Door_status=Door_status
self.Door_time=Door_time
self.Window_status=Window_status
self.Window_time=Window_time
WORKWEEK=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]

Hamid Choucha
committed
Door_Window_History=dict()

Hamid Choucha
committed
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
73
74
75
76
77
78
79
80
81
82
83
84
85
for i in range(0,NUM_WEEKS):
for j in range(0,7):
#door_opens = 0
# window_opens=0
if j < 5:
door_opens = random.randint(14,22)
window_open= random.randint(1,5)
else:
door_opens = random.randint(26,36)
window_open= random.randint(7,12)
door_minutes = door_opens*30/60
window_minutes = window_open *45/60
Door_Window_History[time_stamp] = Door_Window(WORKWEEK[j], door_opens, door_minutes, window_open, window_minutes)
time_stamp += 1
for i in Door_Window_History:
print(i,Door_Window_History[i].day,Door_Window_History[i].Door_status,Door_Window_History[i].Door_time,Door_Window_History[i].Window_status,Door_Window_History[i].Window_time)
class Appliance_1:
def __init__(self,day,micro_pwr,stove_pwr,oven_pwr,Lrtv_pwr,Brtv_pwr,fridge_pwr,lights_pwr,micro_ct,stove_ct,oven_ct,Lrtv_ct,Brtv_ct,fridge_ct,lights_ct):
self.day=day
self.micro_pwr=micro_pwr
self.stove_pwr=stove_pwr
self.oven_pwr=oven_pwr
self.Lrtv_pwr=Lrtv_pwr
self.Brtv_pwr=Brtv_pwr
self.fridge_pwr=fridge_pwr
self.micro_ct=micro_ct
self.stove_ct=stove_ct
self.oven_ct=oven_ct
self.Lrtv_ct=Lrtv_ct
self.Brtv_ct=Brtv_ct
self.fridge_ct=fridge_ct
self.lights_pwr=lights_pwr
self.lights_ct=lights_ct
App1_History=dict()
time_stamp2=1
Fridge=0
for i in range(0,NUM_WEEKS):
for j in range(0,7):
Fridge += 1440
if j<5:
Microwave=random.randint(18,25)
Stove=random.randint(13,18)
Oven=random.randint(40,50)
Living_roomTV=random.randint(230,330)
BedroomTV=random.randint(100,190)
lights=random.randint(35,65)
else:
Microwave=random.randint(26,40)
Stove=random.randint(25,41)
Oven=random.randint(54,67)
Living_roomTV=random.randint(432,490)
BedroomTV=random.randint(225,277)
lights=random.randint(55,95)
#Watts Ussage
Watts_micro=(Microwave/60)*1100
Watts_stove=(Stove/60)*3500

Hamid Choucha
committed
Watts_Lrtv=(Living_roomTV/60)*636
Watts_Brtv=(BedroomTV/60)*100
Watts_Fridge=(Fridge/60)*150

Hamid Choucha
committed
#Cost Calculations
Cost_micro=((Watts_micro/1000)*0.12)/100
Cost_stove=((Watts_stove/1000)*0.12)/100
Cost_oven=((Watts_oven/1000)*0.12)/100
Cost_Lrtv=((Watts_Lrtv/1000)*0.12)/100
Cost_Brtv=((Watts_Brtv/1000)*0.12)/100
Cost_Fridge=((Watts_Fridge/1000)*0.12)/100
Cost_lights=((Watts_Lights/1000)*0.12 )/100

Hamid Choucha
committed
App1_History[time_stamp2] = Appliance_1(WORKWEEK[j],Watts_micro,Watts_stove,Watts_oven,Watts_Lrtv,Watts_Brtv,Watts_Fridge,Watts_Lights,Cost_micro,Cost_stove,Cost_oven,Cost_Lrtv,Cost_Brtv,Cost_Fridge,Cost_lights)
time_stamp2 += 1
monthly_cost1_JAN=0
monthly_power1_JAN=0
monthly_cost1_FEB=0
monthly_power1_FEB=0
monthly_cost1_MAR=0
monthly_power1_MAR=0

Hamid Choucha
committed
print("###################################################### TOTAL APP1 HISTORY FOR 77 DAYS ###################################################### \n")

Hamid Choucha
committed
for i in App1_History:
if i<=31:
monthly_power1_JAN += App1_History[i].micro_pwr + App1_History[i].stove_pwr + App1_History[i].oven_pwr + App1_History[i].Lrtv_pwr + App1_History[i].Brtv_pwr + App1_History[i].fridge_pwr +App1_History[i].lights_pwr
monthly_cost1_JAN += App1_History[i].micro_ct + App1_History[i].stove_ct + App1_History[i].oven_ct + App1_History[i].Lrtv_ct + App1_History[i].Brtv_ct + App1_History[i].fridge_ct + App1_History[i].lights_ct
if i>32 and i<=60:
monthly_power1_FEB += App1_History[i].micro_pwr + App1_History[i].stove_pwr + App1_History[i].oven_pwr + App1_History[i].Lrtv_pwr + App1_History[i].Brtv_pwr + App1_History[i].fridge_pwr +App1_History[i].lights_pwr
monthly_cost1_FEB += App1_History[i].micro_ct + App1_History[i].stove_ct + App1_History[i].oven_ct + App1_History[i].Lrtv_ct + App1_History[i].Brtv_ct + App1_History[i].fridge_ct + App1_History[i].lights_ct
if i>61:
monthly_power1_MAR += App1_History[i].micro_pwr + App1_History[i].stove_pwr + App1_History[i].oven_pwr + App1_History[i].Lrtv_pwr + App1_History[i].Brtv_pwr + App1_History[i].fridge_pwr +App1_History[i].lights_pwr
monthly_cost1_MAR += App1_History[i].micro_ct + App1_History[i].stove_ct + App1_History[i].oven_ct + App1_History[i].Lrtv_ct + App1_History[i].Brtv_ct + App1_History[i].fridge_ct + App1_History[i].lights_ct
#print(i,App1_History[i].day,App1_History[i].micro_pwr,App1_History[i].stove_pwr,App1_History[i].oven_pwr,App1_History[i].Lrtv_pwr,App1_History[i].Brtv_pwr,App1_History[i].micro_ct,App1_History[i].stove_ct,App1_History[i].oven_ct,App1_History[i].Lrtv_ct,App1_History[i].Brtv_ct)
print( "_ - _ - _ - _ Power used for each Month _ - _ - _ - _ \n")
print( "Jan APP1 watts used : ",monthly_power1_JAN )
print( "FEB APP1 watts used : ",monthly_power1_FEB )
print( "MAR APP1 watts used : ",monthly_power1_MAR )
print( "_ - _ - _ - _ Cost used for each Month _ - _ - _ - _ \n")
print( "Jan APP1 cost used : ",monthly_cost1_JAN )
print( "FEB APP1 cost used : ",monthly_cost1_FEB )
print( "MAR APP1 cost used : ",monthly_cost1_MAR )
#print( "################################################################################################################################################################# \n")

Hamid Choucha
committed
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
class Appliance_with_Water:
def __init__(self,day,Water_Heat_pwr,DishWasher_pwr,Clothes_Wash_pwr,Clothes_dry_pwr,bath_fans_pwr,Water_Heat_ug,Bath_water_ug,Shower_water_ug,DishWasher_ug,Clothes_Wash_ug,Water_Heat_ct,DishWasher_ct,Clothes_Wash_ct,Clothes_dry_ct,bath_fans_ct,Water_ct,bath,shower):
self.day=day
self.Water_Heat_pwr=Water_Heat_pwr
self.DishWasher_pwr=DishWasher_pwr
self.Clothes_Wash_pwr=Clothes_Wash_pwr
self.Clothes_dry_pwr=Clothes_dry_pwr
self.Water_Heat_ug=Water_Heat_ug
self.DishWasher_ug=DishWasher_ug
self.Clothes_Wash_ug=Clothes_Wash_ug
self.Water_Heat_ct=Water_Heat_ct
self.DishWasher_ct=DishWasher_ct
self.Clothes_Wash_ct=Clothes_Wash_ct
self.Clothes_dry_ct=Clothes_dry_ct
self.bath_fans_pwr=bath_fans_pwr
self.bath_fans_ct=bath_fans_ct
self.Bath_water_ug=Bath_water_ug
self.Shower_water_ug=Shower_water_ug
self.Water_ct=Water_ct
self.bath=bath
self.shower=shower
App2_History=dict()

Hamid Choucha
committed
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
for i in range(0,NUM_WEEKS):
Dish_washer_run=random.randint(3,5)
Clths_wash_dry_run=random.randint(3,5)
for j in range(0,7):
if j<5:
Bath=random.randint(2,3)
Shower=random.randint(2,3)
else:
Bath=random.randint(3,4)
Shower=random.randint(3,4)
#Calaculate Total Water
Bath_water=30*Bath
Shower_water=25*Shower
Clths_water=20*Clths_wash_dry_run
Dish_washer_water=6*Dish_washer_run
# still have to apply floor to it ## hot water
Bath_hot=math.ceil(Bath_water*0.65)
Shower_hot=math.ceil(Shower_water*0.65)
Clths_wash_hot=math.ceil(Clths_water*0.85)
# hot water heater ## use ceil round up
Hot_water=(Bath_hot+Shower_hot+Clths_wash_hot)
Hot_water_time=Hot_water*4
# Watts used
Hot_water_pwr=(Hot_water_time/60)*4500
Dish_washer_pwr=((Dish_washer_run*45)/60)*1800
Clothes_wash_pwr=((Clths_wash_dry_run*30)/60)*500
Clothes_dry_pwr=((Clths_wash_dry_run*30)/60)*3000
Bath_Fans_pwr=((Bath*45)/60)*30
# Cost
Hot_water_ct=((Hot_water_pwr/1000)*0.12)/100
Dish_washer_ct=((Dish_washer_pwr/1000)*0.12)/100
Clothes_wash_ct=((Clothes_wash_pwr/1000)*0.12)/100
Clothes_dry_ct=((Clothes_dry_pwr/1000)*0.12)/100
Bath_Fans_ct=((Bath_Fans_pwr/1000)*0.12)/100

Hamid Choucha
committed
# Water Used / Cost
Water_Total=Bath_water+Shower_water+Clths_water+Dish_washer_water
Water_Feet=Water_Total/7.48
Water_cost=Water_Feet*(2.52/100)
#Water_Heat_pwr,DishWasher_pwr,Clothes_Wash_pwr,Clothes_dry_pwr,bath_fan_pwr,Water_Heat_ug,DishWasher_ug,Clothes_Wash_ug,Water_Heat_ct,DishWasher_ct,Clothes_Wash_ct,Clothes_dry_ct,bath_fan_ct,bath,shower
App2_History[time_stamp3] = Appliance_with_Water(WORKWEEK[j],Hot_water_pwr,Dish_washer_pwr,Clothes_wash_pwr,Clothes_dry_pwr,Bath_Fans_pwr,Hot_water,Bath_water,Shower_water,Dish_washer_water,Clths_water,Hot_water_ct,Dish_washer_ct,Clothes_wash_ct,Clothes_dry_ct,Bath_Fans_ct,Water_cost,Bath,Shower)
time_stamp3+=1
monthly_cost2_JAN=0
monthly_power2_JAN=0
monthly_water_usg_JAN=0
monthly_cost2_FEB=0
monthly_power2_FEB=0
monthly_water_usg_FEB=0
monthly_cost2_MAR=0
monthly_power2_MAR=0
monthly_water_usg_MAR=0
print("###################################################### TOTAL APP2 HISTORY FOR 77 DAYS ###################################################### \n")

Hamid Choucha
committed
for i in App2_History:
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
if i>=31:
monthly_cost2_JAN+= App2_History[i].Water_Heat_ct + App2_History[i].DishWasher_ct + App2_History[i].Clothes_Wash_ct + App2_History[i].Clothes_dry_ct +App2_History[i].Water_ct + App2_History[i].bath_fans_ct
monthly_power2_JAN+= App2_History[i].Water_Heat_pwr+ App2_History[i].DishWasher_pwr + App2_History[i].Clothes_Wash_pwr + App2_History[i].Clothes_dry_pwr + App2_History[i].bath_fans_pwr
monthly_water_usg_JAN+= App2_History[i].Bath_water_ug + App2_History[i].Shower_water_ug + App2_History[i].DishWasher_ug+ App2_History[i].Clothes_Wash_ug
if i>32 and i<=60:
monthly_cost2_FEB+= App2_History[i].Water_Heat_ct + App2_History[i].DishWasher_ct + App2_History[i].Clothes_Wash_ct + App2_History[i].Clothes_dry_ct +App2_History[i].Water_ct + App2_History[i].bath_fans_ct
monthly_power2_FEB+= App2_History[i].Water_Heat_pwr+ App2_History[i].DishWasher_pwr + App2_History[i].Clothes_Wash_pwr + App2_History[i].Clothes_dry_pwr + App2_History[i].bath_fans_pwr
monthly_water_usg_FEB+= App2_History[i].Bath_water_ug + App2_History[i].Shower_water_ug + App2_History[i].DishWasher_ug+ App2_History[i].Clothes_Wash_ug
if i>61:
monthly_cost2_MAR+= App2_History[i].Water_Heat_ct + App2_History[i].DishWasher_ct + App2_History[i].Clothes_Wash_ct + App2_History[i].Clothes_dry_ct +App2_History[i].Water_ct + App2_History[i].bath_fans_ct
monthly_power2_MAR+= App2_History[i].Water_Heat_pwr+ App2_History[i].DishWasher_pwr + App2_History[i].Clothes_Wash_pwr + App2_History[i].Clothes_dry_pwr + App2_History[i].bath_fans_pwr
monthly_water_usg_MAR+= App2_History[i].Bath_water_ug + App2_History[i].Shower_water_ug + App2_History[i].DishWasher_ug+ App2_History[i].Clothes_Wash_ug
#print(i,App2_History[i].day,App2_History[i].Water_Heat_pwr,App2_History[i].DishWasher_pwr,App2_History[i].Clothes_Wash_pwr,App2_History[i].Clothes_dry_pwr,App2_History[i].bath_fans_pwr,App2_History[i].Water_Heat_ug,App2_History[i].Bath_water_ug,App2_History[i].Shower_water_ug,App2_History[i].DishWasher_ug,App2_History[i].Clothes_Wash_ug,App2_History[i].Water_Heat_ct,App2_History[i].DishWasher_ct,App2_History[i].Clothes_Wash_ct,App2_History[i].Clothes_dry_ct,App2_History[i].bath_fans_ct,App2_History[i].Water_ct,App2_History[i].bath,App2_History[i].shower)
print( "_ - _ - _ - _ Power used for each Month _ - _ - _ - _ \n")
print( "Jan APP1 watts used : ",monthly_power2_JAN )
print( "FEB APP1 watts used : ",monthly_power2_FEB )
print( "MAR APP1 watts used : ",monthly_power2_MAR )
print( "_ - _ - _ - _ Cost used for each Month _ - _ - _ - _ \n")
print( "Jan APP1 cost used : ",monthly_cost2_JAN )
print( "FEB APP1 cost used : ",monthly_cost2_FEB )
print( "MAR APP1 cost used : ",monthly_cost2_MAR )
print( "_ - _ - _ - _ Gallons used for each Month _ - _ - _ - _ \n")
print( "Jan APP1 water used : ",monthly_water_usg_JAN )
print( "FEB APP1 water used : ",monthly_water_usg_FEB )
print( "MAR APP1 water used : ",monthly_water_usg_MAR )
#print( "################################################################################################################################################################# \n")

Hamid Choucha
committed
# weather api to get temp from history
# Used this to help me understand and gather API.data: https://pypi.org/project/requests/ and https://realpython.com/api-integration-in-python/

Hamid Choucha
committed
self.temp_power=temp_power
self.temp_cost=temp_cost
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
response_API = requests.get("https://archive-api.open-meteo.com/v1/archive?latitude=33.52&longitude=-86.80&start_date=2023-01-01&end_date=2023-03-12&hourly=temperature_2m&timezone=America%2FChicago&temperature_unit=fahrenheit")
data = response_API.text
parse_temp=json.loads(data)
hourly_pull = parse_temp['hourly']
dict_pull=hourly_pull["temperature_2m"]
App3_History=dict()
time_stamp4=0
daily_arr=np.array_split(dict_pull,77)
for i in range(0,len(daily_arr)):
daily_arr[i]
d_t=Door_Window_History[i].Door_time
w_t=Door_Window_History[i].Window_time
diff_inc = 0
diff_dec = 0
for j in range(0,len(daily_arr[i])-1):
num_nxt=daily_arr[i][j+1]
num=daily_arr[i][j]
if num > num_nxt :
diff_inc= num - num_nxt
if num < num_nxt :
diff_dec= num_nxt - num
# print(diff_inc)
# print(diff_dec)
sum=(diff_inc+diff_dec)*random.randint(2,17)
#Total number of minutes ac runs
min_op=sum*60+(d_t+w_t)
watts_per_day=(min_op)*3500
ct_per_day=((watts_per_day/1000)*0.12)/100
App3_History[time_stamp4]=Temperature_data(watts_per_day,ct_per_day)
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
time_stamp4+=1
#print(ct_per_day)
#print(watts_per_day)
# print("what i is",i)
# print("timestamp",i)
monthly_temp_ct_JAN=0
monthly_temp_watts_JAN=0
monthly_temp_ct_FEB=0
monthly_temp_watts_FEB=0
monthly_temp_ct_MAR=0
monthly_temp_watts_MAR=0
print("###################################################### TOTAL TEMP HISTORY FOR 77 DAYS ###################################################### \n")
for i in App3_History:
if i<=31:
monthly_temp_watts_JAN+=App3_History[i].temp_power
monthly_temp_ct_JAN+=App3_History[i].temp_cost
if i>31 and i<=59:
monthly_temp_watts_FEB+=App3_History[i].temp_power
monthly_temp_ct_FEB+=App3_History[i].temp_cost
if i>59:
monthly_temp_ct_MAR+=App3_History[i].temp_cost
monthly_temp_watts_MAR+=App3_History[i].temp_power
print( "_ - _ - _ - _ Power used for each Month _ - _ - _ - _ \n")
print( "Jan APP1 watts used : ",monthly_temp_watts_JAN )
print( "FEB APP1 watts used : ",monthly_temp_watts_FEB )
print( "MAR APP1 watts used : ",monthly_temp_watts_MAR )
print( "_ - _ - _ - _ Cost used for each Month _ - _ - _ - _ \n")
print( "Jan APP1 cost used : ",monthly_temp_ct_JAN )
print( "FEB APP1 cost used : ",monthly_temp_ct_FEB )
print( "MAR APP1 cost used : ",monthly_temp_ct_MAR )
print( "################################################################################################################################################################# \n")
print("January Total cost",monthly_temp_ct_JAN+monthly_cost2_JAN+monthly_cost1_JAN)
print("Febuary Total cost",monthly_temp_ct_FEB+monthly_cost2_FEB+monthly_cost1_FEB)
print("March Total cost",monthly_temp_ct_MAR+monthly_cost2_FEB+monthly_cost1_MAR)
print("January Total Watts",monthly_temp_watts_JAN+monthly_power2_JAN+monthly_power1_JAN)
print("Febuary Total Watts",monthly_temp_watts_FEB+monthly_power2_FEB+monthly_power1_FEB)
print("March Total Watts",monthly_temp_watts_MAR+monthly_power2_MAR+monthly_power1_MAR)