Guest User

Untitled

a guest
Dec 18th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. import wx
  2. import FinalProjectSolar as fp
  3. import numpy as np
  4. import requests
  5. import BeautifulSoup
  6.  
  7. class frame(fp.MyFrame):
  8. def generate(self, event): # wxGlade: MyFrame. <event_handler>
  9.  
  10. state = self.combo_box_1.GetValue()
  11.  
  12. try:
  13. zipcode = float(self.zipcode_txt.GetValue())
  14. except:
  15. print "zipcode is not a float"
  16. zipcode = 02461
  17. try:
  18. roof_area = float(self.roof_txt.GetValue())
  19. except:
  20. print "roof area is not a float"
  21. roof_area = 500
  22. try:
  23. monthly_bill = float(self.bill_txt.GetValue())
  24. except:
  25. print "monthly bill is not a float"
  26. monthly_bill = 250
  27.  
  28.  
  29. return solar_power()
  30. event.Skip()
  31.  
  32. # end of class MyFrame
  33. if __name__ == "__main__":
  34. app = wx.PySimpleApp(0)
  35. wx.InitAllImageHandlers()
  36. Result_generator = fp.MyFrame(None, wx.ID_ANY, "")
  37. app.SetTopWindow(Result_generator)
  38. Result_generator.Show()
  39. app.MainLoop()
  40.  
  41. def solar_power():
  42.  
  43. #Testing variables
  44. state = str(input("Enter your state: "))
  45. zipcode = str(input("Enter your zipcode: "))
  46. monthly_bill = float(input("Enter your monthly electricity bill: $"))
  47. roof_area = float(input("Enter your roof area: "))
  48.  
  49. #Get electricity cost per kWh and install costs per kWh
  50. cost_kWh = cost_per_kWh(state)
  51. install_costs = raw_install_costs(state)
  52.  
  53. #If desired power capacity is not entered, find it from given roof dimensions
  54. if capacity == None:
  55. capacity = power_cap(roof_area)
  56.  
  57. #Get install cost per watt and then total install cost
  58. install_watt = install_cost_watt(capacity,install_costs)
  59. total_install = total_install_cost(capacity, install_watt)
  60.  
  61. #Get peak hours and annual electrical bill to calculate annual savings (and annual bill after installation)
  62. avg_peak_hours = peak_hours(zipcode)
  63. annual_bill = annual_cost(monthly_bill)
  64.  
  65. #Calculate power_produced annually from the custom solar power system, savings,
  66. #and return of investment values
  67. power_produced = annual_power_produced(capacity, avg_peak_hours)
  68. savings = savings_output(power_produced, cost_kWh)
  69. roi_min = ROI(savings, total_install["Min"])
  70. roi_max = ROI(savings,total_install["Max"])
  71.  
  72. #Create HTML output from the determined and given values
  73. file = open("output.html", 'w')
  74. html_string = """
  75. <h1>How Could Solar Power Help You?</h1>
  76. <p>Your state is <b>{}</b> and zipcode is <b>{}</b></p>
  77. <p>Average cost per kWh in {} is <b>${}</b><p>
  78. <p>Your average annual electric bill is <b>${}</b><p>
  79. <p>Max solar capacity for your roof is <b>{}</b> kWh<p>
  80. <p>Minimum installation cost after federal incentives:<b> ${}</b>;
  81. Maximum:
  82. <b>${}</b></p>
  83. <p>Money saved each year with solar panels <b>${}</b></p>
  84. <p>Minimum Return of Investment: <b>{}</b> years; Maximum: <b>{}
  85. <b/> years</p>"""
  86.  
  87. paragraph = html_string.format(state, zipcode, state, cost_kWh, annual_bill,
  88. str(kW(capacity))[:5], total_install['Min'],
  89. total_install['Max'], str(savings)[:6],
  90. str(roi_min)[:4], str(roi_max)[:4])
  91.  
  92. file.write(paragraph)
  93. file.close()
  94.  
  95.  
  96. dictionary = {'Power Capacity': capacity, 'Raw Install Costs': install_costs, 'Install Cost per Watt':install_watt,
  97. 'Total Install Cost': total_install, 'Average Daily Peak Hours': avg_peak_hours,
  98. 'Annual Electrical Bill': annual_bill, 'Power Produced Annually': power_produced,
  99. 'Annual Savings': savings, 'ROI Min': roi_min, 'ROI Max':roi_max}
  100.  
  101. return(dictionary)
Add Comment
Please, Sign In to add comment