daily pastebin goal
90%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2. from PyQt5 import QtCore
  3. from PyQt5.QtWidgets import QStackedWidget, QApplication, QMainWindow, QSizePolicy, QWidget, QComboBox, QLabel, QRadioButton, QMenu,QVBoxLayout,  QCheckBox, QGridLayout, QLineEdit, QPushButton, QPushButton, QAction, QSizePolicy
  4. from PyQt5.QtGui import *
  5. from PyQt5.QtCore import *
  6. import matplotlib
  7. matplotlib.use("Qt5Agg")
  8. from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
  9. from matplotlib.figure import Figure
  10. import matplotlib.patches as mpatches
  11. import matplotlib as mpl
  12.  
  13. from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas
  14. import matplotlib.pyplot as plt
  15. import backend
  16. import random
  17.  
  18. import xlrd
  19. import xlsxwriter
  20.  
  21. import pandas
  22. import numpy as np
  23.  
  24. workbook = xlrd.open_workbook('maindatafromneckelandlabs.xlsx')
  25. Data = pandas.read_excel("maindatafromneckelandlabs.xlsx")
  26. Lambda = list(Data.loc[:,"Wavelength"])
  27. ETS = list(Data.loc[:,"Spectrum"])
  28. a_w = list(Data.loc[:,"aw"])
  29. a_o = list(Data.loc[:,"ao"])
  30. a_u = list(Data.loc[:,"au"])
  31. Number = len(Lambda)
  32. CO_excel = xlrd.open_workbook('Carbon_monoxide.xlsx')
  33. CO_data = pandas.read_excel("Carbon_monoxide.xlsx")
  34. CO_values = list(CO_data.loc[:,"absorp"])
  35. Methane_excel = xlrd.open_workbook('Methane.xlsx')
  36. Methane_data = pandas.read_excel("Methane.xlsx")
  37. Methane_values = list(Methane_data.loc[:,"absorp"])
  38. Ammonium_excel = xlrd.open_workbook('Ammonium.xlsx')
  39. Ammonium_data = pandas.read_excel("Ammonium.xlsx")
  40. Ammonium_values = list(Ammonium_data.loc[:,"absorp"])
  41. HCL_excel = xlrd.open_workbook('Hydrogen_Chloride.xlsx')
  42. HCL_data = pandas.read_excel("Hydrogen_Chloride.xlsx")
  43. HCL_values = list(HCL_data.loc[:,"absorp"])
  44.  
  45. SD_excel = xlrd.open_workbook('Sulphur_Dioxide.xlsx')
  46. SD_data = pandas.read_excel("Sulphur_Dioxide.xlsx")
  47. SD_values = list(SD_data.loc[:,"absorp"])
  48. ND_excel = xlrd.open_workbook('Nitrogen_Dioxide.xlsx')
  49. ND_data = pandas.read_excel("Nitrogen_Dioxide.xlsx")
  50. ND_values = list(ND_data.loc[:,"absorp"])
  51. NM_excel = xlrd.open_workbook('Nitrogen_Monoxide.xlsx')
  52. NM_data = pandas.read_excel("Nitrogen_Monoxide.xlsx")
  53. NM_values = list(NM_data.loc[:,"absorp"])
  54. DM_excel = xlrd.open_workbook('Dinitrogen_monoxide.xlsx')
  55. DM_data = pandas.read_excel("Dinitrogen_monoxide.xlsx")
  56. DM_values = list(DM_data.loc[:,"absorp"])
  57.  
  58.  
  59. Solid_values = [1]*Number
  60.  
  61.  
  62. TG = [1]*Number
  63.  
  64. class MyCanvas(FigureCanvas):
  65.     def __init__(self, parent=None, width=6, height=4, dpi=100):
  66.         fig = Figure(figsize=(width, height), dpi=dpi)
  67.         self.axes = fig.add_subplot(111)
  68.         self.compute_figure()
  69.         FigureCanvas.__init__(self, fig)
  70.         self.setParent(parent)
  71.         FigureCanvas.setSizePolicy(self,
  72.                 600,
  73.                 400)
  74.         FigureCanvas.updateGeometry(self)
  75.     def compute_figure(self):
  76.         pass
  77.  
  78. class App(QMainWindow):
  79.    
  80.     def __init__(self):
  81.         super().__init__()
  82.         self.left = 30
  83.         self.top = 30
  84.         self.title = 'Irradiance calculator'
  85.         self.width = 900
  86.         self.height =500
  87.         self.initUI()
  88.  
  89.     def initUI(self):
  90.         self.setWindowTitle(self.title)
  91.         self.setGeometry(self.left, self.top, self.width, self.height)
  92.  
  93.         mainMenu = self.menuBar()
  94.         fileMenu = mainMenu.addMenu('File')
  95.         editMenu = mainMenu.addMenu('Edit')
  96.         viewMenu = mainMenu.addMenu('View')
  97.         searchMenu = mainMenu.addMenu('Search')
  98.         toolsMenu = mainMenu.addMenu('Tools')
  99.         helpMenu = mainMenu.addMenu('Help')
  100.  
  101.         exitButton = QAction(QIcon('exit24.png'), 'Exit', self)
  102.         exitButton.setShortcut('Ctrl+Q')
  103.         exitButton.setStatusTip('Exit application')
  104.         exitButton.triggered.connect(self.close)
  105.         fileMenu.addAction(exitButton)
  106.  
  107.         self.Index = 0
  108.  
  109.         self.main_widget = QWidget(self)
  110.  
  111.  
  112.         Main = QGridLayout(self.main_widget)
  113.  
  114.         InputsL = QLabel("Inputs",self)
  115.         Main.addWidget(InputsL,0,3,1,1)
  116.  
  117.         VariL = QLabel("Variables",self)
  118.         Main.addWidget(VariL,0,4,1,1)
  119.  
  120.  
  121.         GasL = QLabel("Gas Variables",self)
  122.         Main.addWidget(GasL,0,5,1,1)
  123.  
  124.         PathL = QLabel("Height of gas (km)",self)
  125.         Main.addWidget(PathL,0,6,1,1)
  126.  
  127.         PathL = QLabel("Concentration(mol/m^2))",self)
  128.         Main.addWidget(PathL,0,7,1,1)
  129.  
  130.         self.DayV = QLineEdit("10",self)
  131.         Main.addWidget(self.DayV,1,3,1,1)
  132.         DayL = QLabel("Day (1-365)",self)
  133.         Main.addWidget(DayL,1,4,1,1)
  134.  
  135.         self.PressureV = QLineEdit("1013",self)
  136.         Main.addWidget(self.PressureV,2,3,1,1)
  137.         PressureL = QLabel("Pressure at surface (mb)",self)
  138.         Main.addWidget(PressureL,2,4,1,1)
  139.  
  140.         self.WaterV = QLineEdit("2.5",self)
  141.         Main.addWidget(self.WaterV,3,3,1,1)
  142.         WaterL = QLabel("Precitable water vapour (cm)",self)
  143.         Main.addWidget(WaterL,3,4,1,1)
  144.  
  145.         self.HeightV = QLineEdit("22",self)
  146.         Main.addWidget(self.HeightV,4,3,1,1)
  147.         HeightL = QLabel("Ozone Height (km)",self)
  148.         Main.addWidget(HeightL,4,4,1,1)
  149.  
  150.         self.OzoneV = QLineEdit("0.344",self)
  151.         Main.addWidget(self.OzoneV,5,3,1,1)
  152.         OzoneL = QLabel("Ozone amount (atm-cm)",self)
  153.         Main.addWidget(OzoneL,5,4,1,1)
  154.  
  155.  
  156.         self.TiltV = QLineEdit("0",self)
  157.         Main.addWidget(self.TiltV,6,3,1,1)
  158.         TiltL = QLabel("Tilt angle towards equator",self)
  159.         Main.addWidget(TiltL,6,4,1,1)
  160.  
  161.  
  162.         self.TurbV = QLineEdit("0.1",self)
  163.         Main.addWidget(self.TurbV,7,3,1,1)
  164.         TurbL = QLabel("Turbidity at 0.5",self)
  165.         Main.addWidget(TurbL,7,4,1,1)
  166.        
  167.         self.drop = QComboBox()
  168.         self.drop.addItem( "User inputs of Zenith and Incidence Angles",0)
  169.         self.drop.addItem( "User inputs of Time and Latitude",1)
  170.         Main.addWidget(self.drop,8,3,1,2)
  171.  
  172.         self.drop1 = QComboBox()
  173.         Main.addWidget(self.drop1,1,5,1,1)
  174.         self.drop1.addItem( "None",0)
  175.         self.drop1.addItem( "Carbon Monoxide",1)
  176.         self.drop1.addItem( "Methane",2)
  177.         self.drop1.addItem( "Ammonium",3)
  178.         self.drop1.addItem( "Hydrogen Chloride",4)
  179.         self.drop1.addItem( "Sulphur Dioxide",5)
  180.         self.drop1.addItem( "Nitrogen Dioxide",6)
  181.         self.drop1.addItem( "Nitrogen Monoxide",7)
  182.         self.drop1.addItem( "Dinitorgen Monoxide",8)
  183.         self.drop1.addItem( "Solid",9)
  184.         self.drop1.activated.connect(self.display1)
  185.         self.path1 = QLineEdit("0",self)
  186.         Main.addWidget(self.path1,1,6,1,1)
  187.         self.mass1 = QLineEdit("0",self)
  188.         Main.addWidget(self.mass1,1,7,1,1)
  189.  
  190.         self.drop2 = QComboBox()
  191.         Main.addWidget(self.drop2,2,5,1,1)
  192.         self.drop2.addItem( "None",0)
  193.         self.drop2.addItem( "Carbon Monoxide",1)
  194.         self.drop2.addItem( "Methane",2)
  195.         self.drop2.addItem( "Ammonium",3)
  196.         self.drop2.addItem( "Hydrogen Chloride",4)
  197.         self.drop2.addItem( "Sulphur Dioxide",5)
  198.         self.drop2.addItem( "Nitrogen Dioxide",6)
  199.         self.drop2.addItem( "Nitrogen Monoxide",7)
  200.         self.drop2.addItem( "Dinitorgen Monoxide",8)
  201.         self.drop2.addItem( "Solid",9)
  202.         self.drop2.activated.connect(self.display2)
  203.         self.path2 = QLineEdit("0",self)
  204.         Main.addWidget(self.path2,2,6,1,1)
  205.         self.mass2 = QLineEdit("0",self)
  206.         Main.addWidget(self.mass2,2,7,1,1)
  207.  
  208.         self.drop3 = QComboBox()
  209.         Main.addWidget(self.drop3,3,5,1,1)
  210.         self.drop3.addItem( "None",0)
  211.         self.drop3.addItem( "Carbon Monoxide",1)
  212.         self.drop3.addItem( "Methane",2)
  213.         self.drop3.addItem( "Ammonium",3)
  214.         self.drop3.addItem( "Hydrogen Chloride",4)
  215.         self.drop3.addItem( "Sulphur Dioxide",5)
  216.         self.drop3.addItem( "Nitrogen Dioxide",6)
  217.         self.drop3.addItem( "Nitrogen Monoxide",7)
  218.         self.drop3.addItem( "Dinitorgen Monoxide",8)
  219.         self.drop3.addItem( "Solid",9)
  220.         self.drop3.activated.connect(self.display3)
  221.         self.path3 = QLineEdit("0",self)
  222.         Main.addWidget(self.path3,3,6,1,1)
  223.         self.mass3 = QLineEdit("0",self)
  224.         Main.addWidget(self.mass3,3,7,1,1)
  225.  
  226.         self.drop4 = QComboBox()
  227.         Main.addWidget(self.drop4,4,5,1,1)
  228.         self.drop4.addItem( "None",0)
  229.         self.drop4.addItem( "Carbon Monoxide",1)
  230.         self.drop4.addItem( "Methane",2)
  231.         self.drop4.addItem( "Ammonium",3)
  232.         self.drop4.addItem( "Hydrogen Chloride",4)
  233.         self.drop4.addItem( "Sulphur Dioxide",5)
  234.         self.drop4.addItem( "Nitrogen Dioxide",6)
  235.         self.drop4.addItem( "Nitrogen Monoxide",7)
  236.         self.drop4.addItem( "Dinitorgen Monoxide",8)
  237.         self.drop4.addItem( "Solid",9)
  238.         self.drop4.activated.connect(self.display4)
  239.         self.path4 = QLineEdit("0",self)
  240.         Main.addWidget(self.path4,4,6,1,1)
  241.         self.mass4 = QLineEdit("0",self)
  242.         Main.addWidget(self.mass4,4,7,1,1)
  243.  
  244.         self.drop5 = QComboBox()
  245.         Main.addWidget(self.drop5,5,5,1,1)
  246.         self.drop5.addItem( "None",0)
  247.         self.drop5.addItem( "Carbon Monoxide",1)
  248.         self.drop5.addItem( "Methane",2)
  249.         self.drop5.addItem( "Ammonium",3)
  250.         self.drop5.addItem( "Hydrogen Chloride",4)
  251.         self.drop5.addItem( "Sulphur Dioxide",5)
  252.         self.drop5.addItem( "Nitrogen Dioxide",6)
  253.         self.drop5.addItem( "Nitorgen Monoxide",7)
  254.         self.drop5.addItem( "Dinitorgen Monoxide",8)
  255.         self.drop5.addItem( "Solid",9)
  256.         self.drop5.activated.connect(self.display5)
  257.         self.path5 = QLineEdit("0",self)
  258.         Main.addWidget(self.path5,5,6,1,1)
  259.         self.mass5 = QLineEdit("0",self)
  260.         Main.addWidget(self.mass5,5,7,1,1)
  261.  
  262.         self.drop6 = QComboBox()
  263.         Main.addWidget(self.drop6,6,5,1,1)
  264.         self.drop6.addItem( "None",0)
  265.         self.drop6.addItem( "Carbon Monoxide",1)
  266.         self.drop6.addItem( "Methane",2)
  267.         self.drop6.addItem( "Ammonium",3)
  268.         self.drop6.addItem( "Hydrogen Chloride",4)
  269.         self.drop6.addItem( "Sulphur Dioxide",5)
  270.         self.drop6.addItem( "Nitrogen Dioxide",6)
  271.         self.drop6.addItem( "Nitorgen Monoxide",7)
  272.         self.drop6.addItem( "Dinitorgen Monoxide",8)
  273.         self.drop6.addItem( "Solid",9)
  274.         self.drop6.activated.connect(self.display6)
  275.         self.path6 = QLineEdit("0",self)
  276.         Main.addWidget(self.path6,6,6,1,1)
  277.         self.mass6 = QLineEdit("0",self)
  278.         Main.addWidget(self.mass6,6,7,1,1)
  279.  
  280.         self.drop7 = QComboBox()
  281.         Main.addWidget(self.drop7,7,5,1,1)
  282.         self.drop7.addItem( "None",0)
  283.         self.drop7.addItem( "Carbon Monoxide",1)
  284.         self.drop7.addItem( "Methane",2)
  285.         self.drop7.addItem( "Ammonium",3)
  286.         self.drop7.addItem( "Hydrogen Chloride",4)
  287.         self.drop7.addItem( "Sulphur Dioxide",5)
  288.         self.drop7.addItem( "Nitrogen Dioxide",6)
  289.         self.drop7.addItem( "Nitorgen Monoxide",7)
  290.         self.drop7.addItem( "Dinitorgen Monoxide",8)
  291.         self.drop7.addItem( "Solid",9)
  292.         self.drop1.activated.connect(self.display7)
  293.         self.path7 = QLineEdit("0",self)
  294.         Main.addWidget(self.path7,7,6,1,1)
  295.         self.mass7 = QLineEdit("0",self)
  296.         Main.addWidget(self.mass7,7,7,1,1)
  297.  
  298.         Solar1L = QLabel("Solar Panel Inputs",self)
  299.         Main.addWidget(Solar1L,9,5,1,1)
  300.         Solar2L = QLabel("Solar Panel Variables",self)
  301.         Main.addWidget(Solar2L,9,7,1,1)
  302.  
  303.         self.AreaV = QLineEdit("1",self)
  304.         Main.addWidget(self.AreaV,10,5,1,2)
  305.         AreaL = QLabel("Area (m^2)",self)
  306.         Main.addWidget(AreaL,10,7,1,1)
  307.  
  308.         self.EffV = QLineEdit("0.3",self)
  309.         Main.addWidget(self.EffV,11,5,1,2)
  310.         EffL = QLabel("Efficiency (%)",self)
  311.         Main.addWidget(EffL,11,7,1,1)
  312.  
  313.         self.PerV = QLineEdit("0.3",self)
  314.         Main.addWidget(self.PerV,12,5,1,2)
  315.         PerL = QLabel("Performance",self)
  316.         Main.addWidget(PerL,12,7,1,1)
  317.  
  318.         self.EPV = QLineEdit("0.3",self)
  319.         Main.addWidget(self.EPV,13,4,1,1)
  320.         EPL = QLabel("Energy produced (kW)",self)
  321.         Main.addWidget(EPL,13,3,1,1)
  322.  
  323.         self.EDV = QLineEdit("0.3",self)
  324.         Main.addWidget(self.EDV,14,4,1,1)
  325.         EDL = QLabel("Energy produced over a day (kJ)",self)
  326.         Main.addWidget(EDL,14,3,1,1)
  327.  
  328.         self.EYV = QLineEdit("0.3",self)
  329.         Main.addWidget(self.EYV,15,4,1,1)
  330.         EYL = QLabel("Energy produced over a year (kJ)",self)
  331.         Main.addWidget(EYL,15,3,1,1)
  332.  
  333.         self.Incidence_Zenith = QWidget()
  334.         self.Incidence_Zenith_UI()
  335.         self.Time_Latitude = QWidget()
  336.         self.Time_Latitude_UI()
  337.  
  338.         self.Stack = QStackedWidget(self)
  339.         self.Stack.addWidget(self.Incidence_Zenith)
  340.         self.Stack.addWidget(self.Time_Latitude)
  341.         Main.addWidget(self.Stack,9,3,3,2)
  342.         self.variables()
  343.         self.drop.activated.connect(self.display)
  344.  
  345.         sc = PlotCanvas(self.main_widget)
  346.         Main.addWidget(sc,0,0,15,3)
  347.  
  348.         Button_Plot = QPushButton("Initalize current values",self)
  349.         Main.addWidget(Button_Plot,12,4,1,1)
  350.         Button_Plot.clicked.connect(self.plot)
  351.  
  352.         Button_Day = QPushButton("Display curve for the day",self)
  353.         Main.addWidget(Button_Day,15,2,1,1)
  354.         Button_Day.clicked.connect(self.plot_day)
  355.  
  356.         Button_Elements = QPushButton("Display individual sources",self)
  357.         Main.addWidget(Button_Elements,15,0,1,1)
  358.         Button_Elements.clicked.connect(self.plot_current_elements)
  359.  
  360.         Button_Year = QPushButton("Display curve for the year",self)
  361.         Main.addWidget(Button_Year,15,1,1,1)
  362.         Button_Year.clicked.connect(self.plot_year)
  363.  
  364.         Button_Current = QPushButton("Display current curve",self)
  365.         Main.addWidget(Button_Current,12,3,1,1)
  366.         Button_Current.clicked.connect(self.plot_current)
  367.  
  368.         Button_Energy = QPushButton("Calcualte Energy",self)
  369.         Main.addWidget(Button_Energy,13,5,1,2)
  370.         Button_Energy.clicked.connect(self.energy)
  371.  
  372.         Button_Energy = QPushButton("Display Normal vs gases",self)
  373.         Main.addWidget(Button_Energy,13,7,3,3)
  374.         Button_Energy.clicked.connect(self.plot_gas_normal)
  375.        
  376.         Button_Day = QPushButton("Display Energy produced over a day",self)
  377.         Main.addWidget(Button_Day,14,5,1,2)
  378.         Button_Day.clicked.connect(self.plot_energy_day)
  379.  
  380.         Button_Year = QPushButton("Display Energy produced over a year",self)
  381.         Main.addWidget(Button_Year,15,5,1,2)
  382.         Button_Year.clicked.connect(self.plot_energy_year)
  383.  
  384.         Button_Gases = QPushButton("Add gases",self)
  385.         Main.addWidget(Button_Gases,8,5,1,3)
  386.         Button_Gases.clicked.connect(self.change_TG)
  387.         self.Index1 = 0
  388.         self.Index2 = 0
  389.         self.Index3 = 0
  390.         self.Index4 = 0
  391.         self.Index5 = 0
  392.         self.Index6 = 0
  393.         self.Index7 = 0
  394.         self.change_TG
  395.         self.main_widget.setFocus()
  396.         self.setCentralWidget(self.main_widget)
  397.         self.show()
  398.  
  399.     def plot_gas_normal(self):
  400.         self.variables()
  401.         self.change_TG()
  402.         plot_gas_normal()
  403.  
  404.     def plot_current_elements(self):
  405.         self.variables()
  406.         plot_current_elements()
  407.  
  408.     def change_TG(self):
  409.         global TG
  410.         TG = []
  411.         Mass1 = float(self.mass1.text())
  412.         Path1 = float(self.path1.text())
  413.         TG1 = []
  414.         if self.Index1 == 0:
  415.             TG1 = [1]*Number
  416.         else:
  417.             pass
  418.         if self.Index1 == 1:
  419.             for i in range (Number):
  420.                 TG1 = TG1 +[backend.gas_constant(Mass1,Path1,CO_values[i])]
  421.         else:
  422.             pass
  423.         if self.Index1 == 2:
  424.             for i in range (Number):
  425.                 TG1 = TG1 +[backend.gas_constant(Mass1,Path1,Methane_values[i])]
  426.         else:
  427.             pass
  428.         if self.Index1 == 3:
  429.             for i in range (Number):
  430.                 TG1 = TG1 +[backend.gas_constant(Mass1,Path1,Ammonium_values[i])]
  431.         else:
  432.             pass
  433.         if self.Index1 == 4:
  434.             for i in range (Number):
  435.                 TG1 = TG1 +[backend.gas_constant(Mass1,Path1,HCL_values[i])]
  436.         else:
  437.             pass
  438.         if self.Index1 == 5:
  439.             for i in range (Number):
  440.                 TG1 = TG1 +[backend.gas_constant(Mass1,Path1,SD_values[i])]
  441.         else:
  442.             pass
  443.         if self.Index1 == 6:
  444.             for i in range (Number):
  445.                 TG1 = TG1 +[backend.gas_constant(Mass1,Path1,ND_values[i])]
  446.         else:
  447.             pass
  448.         if self.Index1 == 7:
  449.             for i in range (Number):
  450.                 TG1 = TG1 +[backend.gas_constant(Mass1,Path1,NM_values[i])]
  451.         else:
  452.             pass
  453.         if self.Index1 == 8:
  454.             for i in range (Number):
  455.                 TG1 = TG1 +[backend.gas_constant(Mass1,Path1,DM_values[i])]
  456.         else:
  457.             pass
  458.         if self.Index1 == 9:
  459.             for i in range (Number):
  460.                 TG1 = TG1 +[backend.gas_constant(Mass1,Path1,Solid_values[i])]
  461.         else:
  462.             pass
  463.  
  464.  
  465.         Mass2 = float(self.mass2.text())
  466.         Path2 = float(self.path2.text())
  467.         TG2 = []
  468.         if self.Index2 == 0:
  469.             TG2 = [1]*Number
  470.         else:
  471.             pass
  472.         if self.Index2 == 1:
  473.             for i in range (Number):
  474.                 TG2 = TG2 +[backend.gas_constant(Mass2,Path2,CO_values[i])]
  475.         else:
  476.             pass
  477.         if self.Index2 == 2:
  478.             for i in range (Number):
  479.                 TG2 = TG2 +[backend.gas_constant(Mass2,Path2,Methane_values[i])]
  480.         else:
  481.             pass
  482.         if self.Index2 == 3:
  483.             for i in range (Number):
  484.                 TG2 = TG2 +[backend.gas_constant(Mass2,Path2,Ammonium_values[i])]
  485.         else:
  486.             pass
  487.         if self.Index2 == 4:
  488.             for i in range (Number):
  489.                 TG2 = TG2 +[backend.gas_constant(Mass2,Path2,HCL_values[i])]
  490.         else:
  491.             pass
  492.         if self.Index1 == 5:
  493.             for i in range (Number):
  494.                 TG2 = TG2 +[backend.gas_constant(Mass1,Path1,SD_values[i])]
  495.         else:
  496.             pass
  497.         if self.Index1 == 6:
  498.             for i in range (Number):
  499.                 TG2 = TG2 +[backend.gas_constant(Mass1,Path1,ND_values[i])]
  500.         else:
  501.             pass
  502.         if self.Index1 == 7:
  503.             for i in range (Number):
  504.                 TG2 = TG2 +[backend.gas_constant(Mass1,Path1,NM_values[i])]
  505.         else:
  506.             pass
  507.         if self.Index1 == 8:
  508.             for i in range (Number):
  509.                 TG2 = TG2 +[backend.gas_constant(Mass1,Path1,DM_values[i])]
  510.         else:
  511.             pass
  512.         if self.Index2 == 9:
  513.             for i in range (Number):
  514.                 TG2 = TG2 +[backend.gas_constant(Mass2,Path2,Solid_values[i])]
  515.         else:
  516.             pass
  517.         Mass3 = float(self.mass3.text())
  518.         Path3 = float(self.path3.text())
  519.         TG3 = []
  520.         if self.Index3 == 0:
  521.             TG3 = [1]*Number
  522.         else:
  523.             pass
  524.         if self.Index3 == 1:
  525.             for i in range (Number):
  526.                 TG3 = TG3 +[backend.gas_constant(Mass3,Path3,CO_values[i])]
  527.         else:
  528.             pass
  529.         if self.Index3 == 2:
  530.             for i in range (Number):
  531.                 TG3 = TG3 +[backend.gas_constant(Mass3,Path3,Methane_values[i])]
  532.         else:
  533.             pass
  534.         if self.Index3 == 3:
  535.             for i in range (Number):
  536.                 TG3 = TG3 +[backend.gas_constant(Mass3,Path3,Ammonium_values[i])]
  537.         else:
  538.             pass
  539.         if self.Index3 == 4:
  540.             for i in range (Number):
  541.                 TG3 = TG3 +[backend.gas_constant(Mass3,Path3,HCL_values[i])]
  542.         else:
  543.             pass
  544.         if self.Index1 == 5:
  545.             for i in range (Number):
  546.                 TG3 = TG3 +[backend.gas_constant(Mass1,Path1,SD_values[i])]
  547.         else:
  548.             pass
  549.         if self.Index1 == 6:
  550.             for i in range (Number):
  551.                 TG3 = TG3 +[backend.gas_constant(Mass1,Path1,ND_values[i])]
  552.         else:
  553.             pass
  554.         if self.Index1 == 7:
  555.             for i in range (Number):
  556.                 TG3 = TG3 +[backend.gas_constant(Mass1,Path1,NM_values[i])]
  557.         else:
  558.             pass
  559.         if self.Index1 == 8:
  560.             for i in range (Number):
  561.                 TG3 = TG3 +[backend.gas_constant(Mass1,Path1,DM_values[i])]
  562.         else:
  563.             pass
  564.         if self.Index3 == 9:
  565.             for i in range (Number):
  566.                 TG3 = TG3 +[backend.gas_constant(Mass3,Path3,Solid_values[i])]
  567.         else:
  568.             pass
  569.         Mass4 = float(self.mass4.text())
  570.         Path4 = float(self.path4.text())
  571.         TG4 = []
  572.         if self.Index4 == 0:
  573.             TG4 = [1]*Number
  574.         else:
  575.             pass
  576.         if self.Index4 == 1:
  577.             for i in range (Number):
  578.                 TG4 = TG4 +[backend.gas_constant(Mass4,Path4,CO_values[i])]
  579.         else:
  580.             pass
  581.         if self.Index4 == 2:
  582.             for i in range (Number):
  583.                 TG4 = TG4 +[backend.gas_constant(Mass4,Path4,Methane_values[i])]
  584.         else:
  585.             pass
  586.         if self.Index4 == 3:
  587.             for i in range (Number):
  588.                 TG4 = TG4 +[backend.gas_constant(Mass4,Path4,Ammonium_values[i])]
  589.         else:
  590.             pass
  591.         if self.Index4 == 4:
  592.             for i in range (Number):
  593.                 TG4 = TG4 +[backend.gas_constant(Mass4,Path4,HCL_values[i])]
  594.         else:
  595.             pass
  596.         if self.Index1 == 5:
  597.             for i in range (Number):
  598.                 TG4 = TG4 +[backend.gas_constant(Mass1,Path1,SD_values[i])]
  599.         else:
  600.             pass
  601.         if self.Index1 == 6:
  602.             for i in range (Number):
  603.                 TG4 = TG4 +[backend.gas_constant(Mass1,Path1,ND_values[i])]
  604.         else:
  605.             pass
  606.         if self.Index1 == 7:
  607.             for i in range (Number):
  608.                 TG4 = TG4 +[backend.gas_constant(Mass1,Path1,NM_values[i])]
  609.         else:
  610.             pass
  611.         if self.Index1 == 8:
  612.             for i in range (Number):
  613.                 TG4 = TG4 +[backend.gas_constant(Mass1,Path1,DM_values[i])]
  614.         else:
  615.             pass
  616.         if self.Index4 == 9:
  617.             for i in range (Number):
  618.                 TG4 = TG4 +[backend.gas_constant(Mass4,Path4,Solid_values[i])]
  619.         else:
  620.             pass
  621.         Mass5 = float(self.mass5.text())
  622.         Path5 = float(self.path5.text())
  623.         TG5 = []
  624.         if self.Index5 == 0:
  625.             TG5 = [1]*Number
  626.         else:
  627.             pass
  628.         if self.Index5 == 1:
  629.             for i in range (Number):
  630.                 TG5 = TG5 +[backend.gas_constant(Mass5,Path5,CO_values[i])]
  631.         else:
  632.             pass
  633.         if self.Index5 == 2:
  634.             for i in range (Number):
  635.                 TG5 = TG5 +[backend.gas_constant(Mass5,Path5,Methane_values[i])]
  636.         else:
  637.             pass
  638.         if self.Index5 == 3:
  639.             for i in range (Number):
  640.                 TG5 = TG5 +[backend.gas_constant(Mass5,Path5,Ammonium_values[i])]
  641.         else:
  642.             pass
  643.         if self.Index5 == 4:
  644.             for i in range (Number):
  645.                 TG5 = TG5 +[backend.gas_constant(Mass5,Path5,HCL_values[i])]
  646.         else:
  647.             pass
  648.         if self.Index1 == 5:
  649.             for i in range (Number):
  650.                 TG5 = TG5 +[backend.gas_constant(Mass1,Path1,SD_values[i])]
  651.         else:
  652.             pass
  653.         if self.Index1 == 6:
  654.             for i in range (Number):
  655.                 TG5 = TG5 +[backend.gas_constant(Mass1,Path1,ND_values[i])]
  656.         else:
  657.             pass
  658.         if self.Index1 == 7:
  659.             for i in range (Number):
  660.                 TG5 = TG5 +[backend.gas_constant(Mass1,Path1,NM_values[i])]
  661.         else:
  662.             pass
  663.         if self.Index1 == 8:
  664.             for i in range (Number):
  665.                 TG5 = TG5 +[backend.gas_constant(Mass1,Path1,DM_values[i])]
  666.         else:
  667.             pass
  668.         if self.Index5 == 9:
  669.             for i in range (Number):
  670.                 TG5 = TG5 +[backend.gas_constant(Mass5,Path5,Solid_values[i])]
  671.         else:
  672.             pass
  673.         Mass6 = float(self.mass6.text())
  674.         Path6 = float(self.path6.text())
  675.         TG6 = []
  676.         if self.Index6 == 0:
  677.             TG6 = [1]*Number
  678.         else:
  679.             pass
  680.         if self.Index6 == 1:
  681.             for i in range (Number):
  682.                 TG6 = TG6 +[backend.gas_constant(Mass6,Path6,CO_values[i])]
  683.         else:
  684.             pass
  685.         if self.Index6 == 2:
  686.             for i in range (Number):
  687.                 TG6 = TG6 +[backend.gas_constant(Mass6,Path6,Methane_values[i])]
  688.         else:
  689.             pass
  690.         if self.Index6 == 3:
  691.             for i in range (Number):
  692.                 TG6 = TG6 +[backend.gas_constant(Mass6,Path6,Ammonium_values[i])]
  693.         else:
  694.             pass
  695.         if self.Index6 == 4:
  696.             for i in range (Number):
  697.                 TG6 = TG6 +[backend.gas_constant(Mass6,Path6,HCL_values[i])]
  698.         else:
  699.             pass
  700.         if self.Index1 == 5:
  701.             for i in range (Number):
  702.                 TG6 = TG6 +[backend.gas_constant(Mass1,Path1,SD_values[i])]
  703.         else:
  704.             pass
  705.         if self.Index1 == 6:
  706.             for i in range (Number):
  707.                 TG6 = TG6 +[backend.gas_constant(Mass1,Path1,ND_values[i])]
  708.         else:
  709.             pass
  710.         if self.Index1 == 7:
  711.             for i in range (Number):
  712.                 TG6 = TG6 +[backend.gas_constant(Mass1,Path1,NM_values[i])]
  713.         else:
  714.             pass
  715.         if self.Index1 == 8:
  716.             for i in range (Number):
  717.                 TG6 = TG6 +[backend.gas_constant(Mass1,Path1,DM_values[i])]
  718.         else:
  719.             pass
  720.         if self.Index6 == 9:
  721.             for i in range (Number):
  722.                 TG6 = TG6 +[backend.gas_constant(Mass6,Path6,Solid_values[i])]
  723.         else:
  724.             pass
  725.         Mass7 = float(self.mass7.text())
  726.         Path7 = float(self.path7.text())
  727.         TG7 = []
  728.         if self.Index7 == 0:
  729.             TG7 = [1]*Number
  730.         else:
  731.             pass
  732.         if self.Index7 == 1:
  733.             for i in range (Number):
  734.                 TG7 = TG7 +[backend.gas_constant(Mass7,Path7,CO_values[i])]
  735.         else:
  736.             pass
  737.         if self.Index7 == 2:
  738.             for i in range (Number):
  739.                 TG7 = TG7 +[backend.gas_constant(Mass7,Path7,Methane_values[i])]
  740.         else:
  741.             pass
  742.         if self.Index7 == 3:
  743.             for i in range (Number):
  744.                 TG7 = TG7 +[backend.gas_constant(Mass7,Path7,Ammonium_values[i])]
  745.         else:
  746.             pass
  747.         if self.Index7 == 4:
  748.             for i in range (Number):
  749.                 TG7 = TG7 +[backend.gas_constant(Mass7,Path7,HCL_values[i])]
  750.         else:
  751.             pass
  752.         if self.Index1 == 5:
  753.             for i in range (Number):
  754.                 TG7 = TG7 +[backend.gas_constant(Mass1,Path1,SD_values[i])]
  755.         else:
  756.             pass
  757.         if self.Index1 == 6:
  758.             for i in range (Number):
  759.                 TG7 = TG7 +[backend.gas_constant(Mass1,Path1,ND_values[i])]
  760.         else:
  761.             pass
  762.         if self.Index1 == 7:
  763.             for i in range (Number):
  764.                 TG7 = TG7 +[backend.gas_constant(Mass1,Path1,NM_values[i])]
  765.         else:
  766.             pass
  767.         if self.Index1 == 8:
  768.             for i in range (Number):
  769.                 TG7 = TG7 +[backend.gas_constant(Mass1,Path1,DM_values[i])]
  770.         else:
  771.             pass
  772.         if self.Index7 == 9:
  773.             for i in range (Number):
  774.                 TG7 = TG7 +[backend.gas_constant(Mass7,Path7,Solid_values[i])]
  775.         else:
  776.             pass
  777.         for i in range (Number):
  778.             TG = TG +[TG1[i]*TG2[i]*TG3[i]*TG4[i]*TG5[i]*TG6[i]*TG7[i]]
  779.        
  780.  
  781.     def display1(self,i):
  782.         self.Index1 = i
  783.     def display2(self,i):
  784.         self.Index2 = i
  785.     def display3(self,i):
  786.         self.Index3 = i
  787.     def display4(self,i):
  788.         self.Index4 = i
  789.     def display5(self,i):
  790.         self.Index5 = i
  791.     def display6(self,i):
  792.         self.Index6 = i
  793.     def display7(self,i):
  794.         self.Index7 = i
  795.        
  796.     def energy(self):
  797.         self.variables()
  798.         Irr = Sum()
  799.         Irr_d = values_in_day()
  800.         Irr_y = values_in_year()
  801.         global Area
  802.         Area = float(self.AreaV.text())
  803.         global Per
  804.         Per = float(self.PerV.text())
  805.         global Eff
  806.         Eff = float(self.EffV.text())
  807.         Energy = (energy_produced(Area,Eff,Per,Irr))/1000
  808.         Energy_d = (energy_produced(Area,Eff,Per,Irr_d))*7.8*60*60/1000
  809.         Energy_y = (energy_produced(Area,Eff,Per,Irr_d))*7.8*365*60*60/1000
  810.         print(average_day)
  811.        
  812.    
  813.     def plot_energy_day(self):
  814.         self.variables()
  815.         global Area
  816.         Area = float(self.AreaV.text())
  817.         global Per
  818.         Per = float(self.PerV.text())
  819.         global Eff
  820.         Eff = float(self.EffV.text())
  821.         plot_energy_day()
  822.  
  823.     def plot_energy_year(self):
  824.         self.variables()
  825.         global Area
  826.         Area = float(self.AreaV.text())
  827.         global Per
  828.         Per = float(self.PerV.text())
  829.         global Eff
  830.         Eff = float(self.EffV.text())
  831.         plot_energy_year()
  832.  
  833.     def Incidence_Zenith_UI(self):
  834.         layout = QGridLayout()
  835.  
  836.         self.ThetaV = QLineEdit("0",self)
  837.         layout.addWidget(self.ThetaV,0,0,1,1)
  838.         ThetaL = QLabel("Angle of Incidence (Degrees)",self)
  839.         layout.addWidget(ThetaL,0,1,1,1)
  840.  
  841.         self.ZenithV = QLineEdit("0",self)
  842.         layout.addWidget(self.ZenithV,1,0,1,1)
  843.         ZenithL = QLabel("Zenith Solar Angle (Degrees)",self)
  844.         layout.addWidget(ZenithL,1,1,1,1)
  845.         self.Incidence_Zenith.setLayout(layout)
  846.  
  847.     def Time_Latitude_UI(self):
  848.         layout = QGridLayout()
  849.  
  850.         self.timeV = QLineEdit("13",self)
  851.         layout.addWidget(self.timeV,0,0,1,1)
  852.         timeL = QLabel("Time of day (7.5-16.5)",self)
  853.         layout.addWidget(timeL,0,1,1,1)
  854.  
  855.         self.LatiV = QLineEdit("40",self)
  856.         layout.addWidget(self.LatiV,1,0,1,1)
  857.         LatiL = QLabel("Latitude",self)
  858.         layout.addWidget(LatiL,1,1,1,1)
  859.         self.Time_Latitude.setLayout(layout)
  860.  
  861.     def display(self,i):
  862.         self.Stack.setCurrentIndex(i)
  863.         self.Index = i
  864.  
  865.     def plot(self):
  866.         self.variables()
  867.         workbook=xlsxwriter.Workbook('example.xlsx')
  868.         worksheet1 = workbook.add_worksheet()
  869.         worksheet1.write_column(0, 0, Irr_t)
  870.         workbook.close()
  871.        
  872.  
  873.     def plot_day(self):
  874.         self.variables()
  875.         plot_day()
  876.  
  877.     def plot_year(self):
  878.         self.variables()
  879.         plot_year()
  880.  
  881.     def plot_current(self):
  882.         self.variables
  883.         plot_current()
  884.        
  885.     def variables(self):
  886.         global d
  887.         d = float(self.DayV.text())
  888.         global P
  889.         P = float(self.PressureV.text())
  890.         global W
  891.         W = float(self.WaterV.text())
  892.         global h_o
  893.         h_o = float(self.HeightV.text())
  894.         global O_3
  895.         O_3 = float(self.OzoneV.text())
  896.         global Turb
  897.         Turb = float(self.TurbV.text())
  898.         global t
  899.         t = float(self.TiltV.text())
  900.         global time
  901.         global Lati
  902.         global Z
  903.         global theta
  904.         if self.Index == 0:
  905.             theta = float(self.ThetaV.text())
  906.             Z = float(self.ZenithV.text())
  907.             time = 12
  908.             Lati = 40
  909.         else:
  910.             pass
  911.         if self.Index == 1:
  912.             time = float(self.timeV.text())
  913.             Lati = float(self.LatiV.text())
  914.             dec_angle = backend.Declination_Angle(d)
  915.             hour_angle = backend.Hour_Angle(time)
  916.             Z = backend.Zenith_Calculation(Lati,dec_angle,hour_angle)
  917.             theta = backend.Incidence_Calculation(dec_angle,Lati,t,hour_angle)
  918.         else:
  919.             pass
  920.        
  921.  
  922. class PlotCanvas(MyCanvas):
  923.     def __init__(self, *args, **kwargs):
  924.         MyCanvas.__init__(self, *args, **kwargs)
  925.         timer = QtCore.QTimer(self)
  926.         timer.timeout.connect(self.update_figure)
  927.         timer.start(1000)
  928.        
  929.     def compute_figure(self):
  930.         #Fixed values
  931.         Omega04 = 0.945
  932.         Omega_Dash = 0.095
  933.         cos_theta = 0.65
  934.         P_o = 1013
  935.         Alpha = 1.140
  936.         rg = 0.12
  937.  
  938.         #fixed values from a function
  939.         Beta = backend.Beta_Function(Alpha,Turb)
  940.         angle = backend.Day_Angle(d)
  941.         D = backend.Earth_Sun_Distance_Factor(angle)
  942.         M = backend.Air_Mass(Z)
  943.         M1 = backend.Pressure_Corrected_Mass(M,P,P_o)
  944.         M_o =  backend.Ozone_Mass(h_o,Z)
  945.         ALG = backend.ALG_Function(cos_theta)
  946.         AFS = backend.AFS_Function(ALG)
  947.         BFS = backend.BFS_Function(ALG)
  948.         F_Dash = backend.F_Dash_Function(AFS,BFS)
  949.         Fs = backend.Fs_Function(AFS,BFS,Z)
  950.         dec_angle = backend.Declination_Angle(d)
  951.  
  952.         TO = []
  953.         TW = []
  954.         TAA = []
  955.         TR = []
  956.         TAS = []
  957.         Omega = []
  958.         Turbidity = []
  959.         global Irr_t
  960.         Irr_t = []
  961.         rs = []
  962.  
  963.         #Run through values for M=1.8
  964.         for i in range (Number):
  965.             Omega = Omega + [backend.Omega_Function(Omega04,Omega_Dash,Lambda[i])]
  966.             Turbidity = Turbidity + [backend.Turbidity_Function(Beta,Lambda[i],Alpha)]
  967.             M = 1.8
  968.             TO =  TO + [backend.Transmission_Ozone(a_o[i],O_3,M_o)]
  969.             TW = TW + [backend.Transmission_Water_Vapor(a_w[i],W,M)]
  970.             TAA = TAA + [backend.TransmissionAA(Omega[i],Turbidity[i],M)]
  971.             M1 = backend.Pressure_Corrected_Mass(M,P,P_o)
  972.             TR = TR + [backend.Transmission_Rayleigh(Lambda[i],M1)]
  973.             TAS = TAS + [backend.TransmissionAS(Omega[i],Turbidity[i],M)]
  974.             rs = rs + [backend.rs_function(TO[i],TW[i],TAA[i],TR[i],F_Dash,TAS[i])]
  975.  
  976.         #Set Blank lists and re-define M
  977.         M = backend.Air_Mass(Z)
  978.         M1 = backend.Pressure_Corrected_Mass(M,P,P_o)
  979.         TR = []
  980.         TA = []
  981.         TO = []
  982.         TU = []
  983.         TAA = []
  984.         TAS = []
  985.         global Irr_d
  986.         Irr_d = []
  987.         Irr_r = []
  988.         Irr_a = []
  989.         Irr_g = []
  990.         global Irr_s
  991.         Irr_s = []
  992.         #Run through values for rest of values and populate lists
  993.         for i in range(Number):
  994.             TR = TR + [backend.Transmission_Rayleigh(Lambda[i],M1)]
  995.             TA = TA + [backend.Transmission_Aerosol(Beta,Lambda[i],Alpha,M)]
  996.             TW = TW + [backend.Transmission_Water_Vapor(a_w[i],W,M)]
  997.             TO = TO + [backend.Transmission_Ozone(a_o[i],O_3,M_o)]
  998.             TU = TU + [backend.Transmission_Uniform(a_u[i],M1)]
  999.             TAA = TAA + [backend.TransmissionAA(Omega[i],Turbidity[i],M)]
  1000.             TAS = TAS + [backend.TransmissionAS(Omega[i],Turbidity[i],M)]
  1001.             Irr_d = Irr_d + [backend.Irradiance_Normal(ETS[i],D,TR[i],TA[i],TW[i],TO[i],TU[i],Z,TG[i])]
  1002.             Irr_r = Irr_r + [backend.Irradiance_Rayleigh(ETS[i],D,Z,TO[i],TU[i],TW[i],TAA[i],TR[i],TG[i])]
  1003.             Irr_a = Irr_a + [backend.Irradiance_Aerosol(ETS[i],D,Z,TO[i],TU[i],TW[i],TAA[i],TAS[i],Fs,TR[i])]
  1004.             Irr_g = Irr_g + [backend.Irradiance_Ground(Irr_d[i],Z,Irr_r[i],Irr_a[i],rs[i],rg)]
  1005.             Irr_s = Irr_s + [backend.Irradiance_Scattering(Irr_r[i],Irr_a[i],Irr_g[i],Lambda[i])]
  1006.             Irr_t = Irr_t + [backend.Irradiance_Global(Irr_d[i],theta,Irr_s[i],ETS[i],D,Z,t,rg)]
  1007.         y = Irr_t
  1008.         x = Lambda
  1009.         self.axes.set_title("Irradiance vs Wavelength")
  1010.         self.axes.set_xlabel("Wavelength (µm)")
  1011.         self.axes.set_ylabel("Irradiance (W/ m^2 µm)")
  1012.         self.axes.plot(x, y)
  1013.  
  1014.     def update_figure(self):
  1015.         self.axes.clear()
  1016.         self.compute_figure()
  1017.         self.draw()
  1018. def Sum():
  1019.     Irr_s = []
  1020.     Irr_t = compute()
  1021.     for i in range(Number):
  1022.         Irr_s = Irr_s +[backend.Irradiance_Sum(Irr_t[i],Lambda[i])]
  1023.  
  1024.     Irr = sum(Irr_s)
  1025.     return Irr
  1026.    
  1027. def values_in_day():
  1028.     global time_axes
  1029.     global day_curve
  1030.     global Irr_day
  1031.     day_curve = []
  1032.     time_axes = []
  1033.     Irr_day = []
  1034.     global time
  1035.     time = 8.1
  1036.     while time < 15.9:
  1037.         Irr = Sum()
  1038.         time_axes.append(time)
  1039.         time = time +0.1
  1040.         day_curve.append(Irr)
  1041.     global average_day
  1042.     average_day = np.mean(day_curve)
  1043.     return average_day
  1044.  
  1045. def values_in_day_energy():
  1046.     global time_axes
  1047.     global day_energy_curve
  1048.     day_energy_curve = []
  1049.     time_axes = []
  1050.     global time
  1051.     time = 8.1
  1052.     while time < 15.9:
  1053.         Irr = Sum()
  1054.         Irr_day = (energy_produced(Area,Eff,Per,Irr))/1000
  1055.         time_axes.append(time)
  1056.         time = time +0.1
  1057.         day_energy_curve.append(Irr_day)
  1058.  
  1059. def plot_energy_day():
  1060.     values_in_day_energy()  
  1061.     plt.xlabel('Time')
  1062.     plt.ylabel('Energy produced (kW)')
  1063.     plt.title('Energy produced vs Time of day')
  1064.     plt.plot(time_axes,day_energy_curve)
  1065.     plt.show()
  1066.  
  1067.  
  1068. def plot_day():
  1069.     values_in_day()    
  1070.     plt.xlabel('Time')
  1071.     plt.ylabel('Total Irradiance (W/m^2)')
  1072.     plt.title('Total Irradiance vs Time of day')
  1073.     plt.plot(time_axes,day_curve)
  1074.     plt.show()
  1075.  
  1076. def values_in_day_simple():
  1077.     global time_axes
  1078.     global day_curve
  1079.     day_curve = []
  1080.     time_axes = []
  1081.     global time
  1082.     time = 8
  1083.     while time < 15:
  1084.         Irr = Sum()
  1085.         time_axes.append(time)
  1086.         time = time +1
  1087.         day_curve.append(Irr)
  1088.     global average_day
  1089.     average_day = np.mean(day_curve)
  1090.     return average_day
  1091.  
  1092. def values_in_year():
  1093.     global day_axes
  1094.     global year_curve
  1095.     day_axes = []
  1096.     year_curve = []
  1097.     global d
  1098.     d = 1
  1099.     while d < 366:
  1100.         Irr_y = values_in_day_simple()
  1101.         day_axes.append(d)
  1102.         d = d + 10
  1103.         year_curve.append(Irr_y)
  1104.     global average_year
  1105.     average_year = np.mean(year_curve)
  1106.     return average_year
  1107.  
  1108. def plot_year():
  1109.     values_in_year()    
  1110.     plt.xlabel('Day of the year (1-365)')
  1111.     plt.ylabel('Total Irradiance (W/m^2)')
  1112.     plt.title('Total Irradiance vs Time of day')
  1113.     plt.plot(day_axes,year_curve)
  1114.     plt.show()
  1115.  
  1116. def values_in_year_energy():
  1117.     global day_axes
  1118.     global year_energy_curve
  1119.     day_axes = []
  1120.     year_energy_curve = []
  1121.     global d
  1122.     d = 1
  1123.     while d < 366:
  1124.         Irr_y = values_in_day_simple()
  1125.         Irr_year = (energy_produced(Area,Eff,Per,Irr_y))/1000
  1126.         day_axes.append(d)
  1127.         d = d + 10
  1128.         year_energy_curve.append(Irr_year)
  1129.  
  1130. def plot_energy_year():
  1131.     values_in_year_energy()    
  1132.     plt.xlabel('Day of the year (1-365)')
  1133.     plt.ylabel('Energy produced (kW)')
  1134.     plt.title('Energy produced vs Day of year')
  1135.     plt.plot(day_axes,year_energy_curve)
  1136.     plt.show()
  1137.  
  1138. def compute():
  1139.     #Fixed values
  1140.     Omega04 = 0.945
  1141.     Omega_Dash = 0.095
  1142.     cos_theta = 0.65
  1143.     P_o = 1013
  1144.     Alpha = 1.140
  1145.     rg = 0.12
  1146.  
  1147.     #fixed values from a function
  1148.     #hour_angle = backend.Hour_Angle(time)
  1149.     #dec_angle = backend.Declination_Angle(d)
  1150.     #Z = backend.Zenith_Calculation(Lati,dec_angle,hour_angle)
  1151.     Beta = backend.Beta_Function(Alpha,Turb)
  1152.     angle = backend.Day_Angle(d)
  1153.     D = backend.Earth_Sun_Distance_Factor(angle)
  1154.     M = backend.Air_Mass(Z)
  1155.     M1 = backend.Pressure_Corrected_Mass(M,P,P_o)
  1156.     M_o =  backend.Ozone_Mass(h_o,Z)
  1157.     ALG = backend.ALG_Function(cos_theta)
  1158.     AFS = backend.AFS_Function(ALG)
  1159.     BFS = backend.BFS_Function(ALG)
  1160.     F_Dash = backend.F_Dash_Function(AFS,BFS)
  1161.     Fs = backend.Fs_Function(AFS,BFS,Z)
  1162.     dec_angle = backend.Declination_Angle(d)
  1163.  
  1164.     TO = []
  1165.     TW = []
  1166.     TAA = []
  1167.     TR = []
  1168.     TAS = []
  1169.     Omega = []
  1170.     Turbidity = []
  1171.     global Irr_t
  1172.     Irr_t = []
  1173.     rs = []
  1174.  
  1175.     #Run through values for M=1.8
  1176.     for i in range (Number):
  1177.         Omega = Omega + [backend.Omega_Function(Omega04,Omega_Dash,Lambda[i])]
  1178.         Turbidity = Turbidity + [backend.Turbidity_Function(Beta,Lambda[i],Alpha)]
  1179.         M = 1.8
  1180.         TO =  TO + [backend.Transmission_Ozone(a_o[i],O_3,M_o)]
  1181.         TW = TW + [backend.Transmission_Water_Vapor(a_w[i],W,M)]
  1182.         TAA = TAA + [backend.TransmissionAA(Omega[i],Turbidity[i],M)]
  1183.         M1 = backend.Pressure_Corrected_Mass(M,P,P_o)
  1184.         TR = TR + [backend.Transmission_Rayleigh(Lambda[i],M1)]
  1185.         TAS = TAS + [backend.TransmissionAS(Omega[i],Turbidity[i],M)]
  1186.         rs = rs + [backend.rs_function(TO[i],TW[i],TAA[i],TR[i],F_Dash,TAS[i])]
  1187.  
  1188.     #Set Blank lists and re-define M
  1189.     M = backend.Air_Mass(Z)
  1190.     M1 = backend.Pressure_Corrected_Mass(M,P,P_o)
  1191.     TR = []
  1192.     TA = []
  1193.     TO = []
  1194.     TU = []
  1195.     TAA = []
  1196.     TAS = []
  1197.     Irr_d = []
  1198.     Irr_r = []
  1199.     Irr_a = []
  1200.     Irr_g = []
  1201.     Irr_s = []
  1202.     #Run through values for rest of values and populate lists
  1203.     for i in range(Number):
  1204.         TR = TR + [backend.Transmission_Rayleigh(Lambda[i],M1)]
  1205.         TA = TA + [backend.Transmission_Aerosol(Beta,Lambda[i],Alpha,M)]
  1206.         TW = TW + [backend.Transmission_Water_Vapor(a_w[i],W,M)]
  1207.         TO = TO + [backend.Transmission_Ozone(a_o[i],O_3,M_o)]
  1208.         TU = TU + [backend.Transmission_Uniform(a_u[i],M1)]
  1209.         TAA = TAA + [backend.TransmissionAA(Omega[i],Turbidity[i],M)]
  1210.         TAS = TAS + [backend.TransmissionAS(Omega[i],Turbidity[i],M)]
  1211.         Irr_d = Irr_d + [backend.Irradiance_Normal(ETS[i],D,TR[i],TA[i],TW[i],TO[i],TU[i],Z,TG[i])]
  1212.         Irr_r = Irr_r + [backend.Irradiance_Rayleigh(ETS[i],D,Z,TO[i],TU[i],TW[i],TAA[i],TR[i],TG[i])]
  1213.         Irr_a = Irr_a + [backend.Irradiance_Aerosol(ETS[i],D,Z,TO[i],TU[i],TW[i],TAA[i],TAS[i],Fs,TR[i])]
  1214.         Irr_g = Irr_g + [backend.Irradiance_Ground(Irr_d[i],Z,Irr_r[i],Irr_a[i],rs[i],rg)]
  1215.         Irr_s = Irr_s + [backend.Irradiance_Scattering(Irr_r[i],Irr_a[i],Irr_g[i],Lambda[i])]
  1216.         Irr_t = Irr_t + [backend.Irradiance_Global(Irr_d[i],theta,Irr_s[i],ETS[i],D,Z,t,rg)]
  1217.     return Irr_t
  1218.  
  1219. def plot_current():
  1220.     plt.title("Irradiance vs Wavelength")
  1221.     plt.xlabel("Wavelength (µm)")
  1222.     plt.ylabel("Irradiance (W/ m^2 µm)")
  1223.     plt.plot(Lambda,Irr_t)
  1224.     plt.show()
  1225.  
  1226. def plot_current_elements():
  1227.     plt.title("Irradiance vs Wavelength")
  1228.     plt.xlabel("Wavelength (µm)")
  1229.     plt.ylabel("Irradiance (W/ m^2 µm)")
  1230.     blue_patch = mpatches.Patch(color='blue', label='Total Irradiance')
  1231.     red_patch = mpatches.Patch(color='red', label='Direct Irradiance')
  1232.     green_patch = mpatches.Patch(color='green', label='Scattering Irradiance')
  1233.     plt.legend(handles=[blue_patch,red_patch,green_patch])
  1234.     plt.plot(Lambda,Irr_t, 'b',Lambda, Irr_d,'r',Lambda,Irr_s, 'g')
  1235.     plt.show()
  1236.  
  1237. def plot_gas_normal():
  1238.     plt.title("Irradiance vs Wavelength")
  1239.     plt.xlabel("Wavelength (µm)")
  1240.     plt.ylabel("Irradiance (W/ m^2 µm)")
  1241.     blue_patch = mpatches.Patch(color='blue', label='Irradiance with gases')
  1242.     red_patch = mpatches.Patch(color='red', label='Normal Irradiance')
  1243.     Irr_t_n =Irr_t
  1244.     global TG
  1245.     TG = [1]*Number
  1246.     compute()
  1247.     plt.legend(handles=[blue_patch,red_patch,])
  1248.     plt.plot(Lambda,Irr_t_n, 'b',Lambda, Irr_t,'r')
  1249.     plt.show()
  1250.  
  1251. def energy_produced(Area,Eff,Per,Irr):
  1252.     E = Area*Eff*Per*Irr
  1253.     return E
  1254.  
  1255. def gas_constant(Mass,Path,SAC):
  1256.     TG = math.exp(-1*Mass*Path*SAC)
  1257.     return TG
  1258.        
  1259. if __name__ == '__main__':
  1260.     app = QApplication(sys.argv)
  1261.     ex = App()
  1262.     sys.exit(app.exec_())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top