Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import wx
- import FinalProjectSolar as fp
- import numpy as np
- import requests
- import BeautifulSoup
- class frame(fp.MyFrame):
- def generate(self, event): # wxGlade: MyFrame. <event_handler>
- state = self.combo_box_1.GetValue()
- try:
- zipcode = float(self.zipcode_txt.GetValue())
- except:
- print "zipcode is not a float"
- zipcode = 02461
- try:
- roof_area = float(self.roof_txt.GetValue())
- except:
- print "roof area is not a float"
- roof_area = 500
- try:
- monthly_bill = float(self.bill_txt.GetValue())
- except:
- print "monthly bill is not a float"
- monthly_bill = 250
- return solar_power()
- event.Skip()
- # end of class MyFrame
- if __name__ == "__main__":
- app = wx.PySimpleApp(0)
- wx.InitAllImageHandlers()
- Result_generator = fp.MyFrame(None, wx.ID_ANY, "")
- app.SetTopWindow(Result_generator)
- Result_generator.Show()
- app.MainLoop()
- def solar_power():
- #Testing variables
- state = str(input("Enter your state: "))
- zipcode = str(input("Enter your zipcode: "))
- monthly_bill = float(input("Enter your monthly electricity bill: $"))
- roof_area = float(input("Enter your roof area: "))
- #Get electricity cost per kWh and install costs per kWh
- cost_kWh = cost_per_kWh(state)
- install_costs = raw_install_costs(state)
- #If desired power capacity is not entered, find it from given roof dimensions
- if capacity == None:
- capacity = power_cap(roof_area)
- #Get install cost per watt and then total install cost
- install_watt = install_cost_watt(capacity,install_costs)
- total_install = total_install_cost(capacity, install_watt)
- #Get peak hours and annual electrical bill to calculate annual savings (and annual bill after installation)
- avg_peak_hours = peak_hours(zipcode)
- annual_bill = annual_cost(monthly_bill)
- #Calculate power_produced annually from the custom solar power system, savings,
- #and return of investment values
- power_produced = annual_power_produced(capacity, avg_peak_hours)
- savings = savings_output(power_produced, cost_kWh)
- roi_min = ROI(savings, total_install["Min"])
- roi_max = ROI(savings,total_install["Max"])
- #Create HTML output from the determined and given values
- file = open("output.html", 'w')
- html_string = """
- <h1>How Could Solar Power Help You?</h1>
- <p>Your state is <b>{}</b> and zipcode is <b>{}</b></p>
- <p>Average cost per kWh in {} is <b>${}</b><p>
- <p>Your average annual electric bill is <b>${}</b><p>
- <p>Max solar capacity for your roof is <b>{}</b> kWh<p>
- <p>Minimum installation cost after federal incentives:<b> ${}</b>;
- Maximum:
- <b>${}</b></p>
- <p>Money saved each year with solar panels <b>${}</b></p>
- <p>Minimum Return of Investment: <b>{}</b> years; Maximum: <b>{}
- <b/> years</p>"""
- paragraph = html_string.format(state, zipcode, state, cost_kWh, annual_bill,
- str(kW(capacity))[:5], total_install['Min'],
- total_install['Max'], str(savings)[:6],
- str(roi_min)[:4], str(roi_max)[:4])
- file.write(paragraph)
- file.close()
- dictionary = {'Power Capacity': capacity, 'Raw Install Costs': install_costs, 'Install Cost per Watt':install_watt,
- 'Total Install Cost': total_install, 'Average Daily Peak Hours': avg_peak_hours,
- 'Annual Electrical Bill': annual_bill, 'Power Produced Annually': power_produced,
- 'Annual Savings': savings, 'ROI Min': roi_min, 'ROI Max':roi_max}
- return(dictionary)
Add Comment
Please, Sign In to add comment