-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathapp.py
More file actions
99 lines (73 loc) · 4.21 KB
/
app.py
File metadata and controls
99 lines (73 loc) · 4.21 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#Importing libraries: Flask, pvlib and pandas
from flask import Flask, request, render_template
app = Flask(__name__)
import pvlib
from pvlib.modelchain import ModelChain
from pvlib.location import Location
from pvlib.pvsystem import PVSystem
from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS
import pandas as pd
import numpy
#Function that returns content
# and use Flask's app.route decorator to map the URL route / to that function:
# Index.html is rendered
@app.route("/")
def index():
return render_template('index.html')
@app.route('/home', methods=['GET'])
def home():
return render_template('index.html')
@app.route('/about', methods=['GET'])
def about():
return render_template('about.html')
#Processing input data from index.html
@app.route('/process', methods=['POST'])
def process():
# Hier verarbeiten Sie die Daten aus dem Formular
latitude_input = float(request.form['latitude_input'])
longitude_input = float(request.form['longitude_input'])
surface_tilt_input = float(request.form['surface_tilt_input'])
surface_azimuth_input = float(request.form['surface_azimuth_input'])
quantity = float(request.form['quantity'])
# Führen Sie Ihr Python-Skript aus und erhalten Sie das Ergebnis
# Geben Sie das Ergebnis an die Ergebnisseite weiter
#Create an instance of Location Class
location = Location(latitude = latitude_input, longitude = longitude_input, tz='Europe/Berlin', altitude = 80, name = 'Cologne Cathedral')
# Set PV modules and inverters databases
sandia_modules = pvlib.pvsystem.retrieve_sam('SandiaMod')
cec_inverters = pvlib.pvsystem.retrieve_sam('CECInverter')
# Set modules and inverters
module = sandia_modules['Canadian_Solar_CS5P_220M___2009_']
inverter = cec_inverters['ABB__PVI_3_0_OUTD_S_US__208V_']
# Set temperature parameters by temperature data provided by pvlib
temperature_parameters = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass']
#Gettig irradiation data from PVGIS
poa_data_2020, meta, inputs = pvlib.iotools.get_pvgis_hourly(latitude=latitude_input, longitude=longitude_input, start=2020, end=2020, raddatabase="PVGIS-SARAH2", components=True,
surface_tilt=surface_tilt_input, surface_azimuth=0,
outputformat='json', usehorizon=True, userhorizon=None,
pvcalculation=False, peakpower=None, pvtechchoice='crystSi',
mountingplace='free', loss=0, trackingtype=0,
optimal_surface_tilt=False, optimalangles=False,
url='https://re.jrc.ec.europa.eu/api/v5_2/', map_variables=True,
timeout=30)
poa_data_2020['poa_diffuse'] = poa_data_2020['poa_sky_diffuse'] + poa_data_2020['poa_ground_diffuse']
poa_data_2020['poa_global'] = poa_data_2020['poa_diffuse'] + poa_data_2020['poa_direct']
#poa_data_2020.to_csv("poa_data_2020.csv")
# Create an instance of PVSystem Class
# Additionally add modules per string = wie viel Module sind in Reihe geschaltet
# Addiotionally add strings per inverter = wie viel viele Module sind an einem Wechselumrichter?
system = PVSystem(surface_tilt = surface_tilt_input, surface_azimuth = surface_azimuth_input, module_parameters = module,
inverter_parameters = inverter, temperature_model_parameters = temperature_parameters,
modules_per_string = 1, strings_per_inverter = 1)
# Create an Instance of ModelChain Class
modelchain = ModelChain(system, location)
#print(modelchain)
#Combine irradiance data with modelchain to see AC output of pv system.
# AC = energy yield in watts behind inverter.
# So to say the end of your PV system which will be connected to rest of a house system
modelchain.run_model_from_poa(poa_data_2020)
# Summe erzeugter Strom in Watt
result = int((sum(modelchain.results.ac)/1000))*quantity
return render_template('result.html', result=result)
if __name__ == '__main__':
app.run(debug=True)