-
-
Save jurand71/7693f526e5f933864268d49ee1e704ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import pvlib | |
from pvlib import pvsystem | |
from pvlib.iotools import pvgis | |
from pvlib.location import Location | |
# dane pogodowe dla Częstochowy TMY | |
COERCE_YEAR = 2020 | |
weather, months, input_data, metadata = pvgis.read_pvgis_tmy('CZ_tmy_2005_2020.csv', map_variables=True) | |
weather.index = weather.index.map(lambda weather: weather.replace(year = COERCE_YEAR)) | |
# wybieramy moduł i inwerter z bazy danych CEC | |
CECMODS = pvsystem.retrieve_sam('CECMod') | |
INVERTERS = pvsystem.retrieve_sam('CECInverter') | |
CECMOD = CECMODS['Trina_Solar_TSM_375DE14H_II_'] | |
INVERTER_60K = INVERTERS['SMA_America__STP_60_US_10__480V_'] | |
# lokalizacja i polozenie słonca | |
times = weather.index - pd.Timedelta('30min') | |
loc = Location(latitude=input_data['latitude'], | |
longitude=input_data['longitude'], tz='Europe/Warsaw') | |
solar_position = loc.get_solarposition(times) | |
solar_position.index += pd.Timedelta('30min') | |
solar_zenith = solar_position['apparent_zenith'] | |
solar_azimuth = solar_position['azimuth'] | |
#pozycja trakera | |
tracker = pvlib.tracking.singleaxis(apparent_zenith = solar_zenith, | |
apparent_azimuth = solar_azimuth, | |
axis_azimuth=180 | |
) | |
# w godzinach nocnych ustawiamy polozenie trakera horyzontalnie | |
surface_tilt = tracker['surface_tilt'].fillna(0) | |
surface_azimuth = tracker['surface_azimuth'].fillna(0) | |
aoi = tracker['aoi'] | |
# składowe natezenia promieniowania | |
dni=weather['dni'] | |
ghi=weather['ghi'] | |
dhi=weather['dhi'] | |
surface_albedo = 0.25 | |
temp_air = weather['temp_air'] | |
dni_extra = pvlib.irradiance.get_extra_radiation(weather.index).values | |
# wyznaczamy składowe poa | |
poa_sky_diffuse = pvlib.irradiance.get_sky_diffuse( | |
surface_tilt, surface_azimuth, solar_zenith, solar_azimuth, | |
dni, ghi, dhi, dni_extra=dni_extra, model='haydavies') | |
poa_ground_diffuse = pvlib.irradiance.get_ground_diffuse( | |
surface_tilt, ghi, albedo=surface_albedo) | |
poa = pvlib.irradiance.poa_components( | |
aoi, dni, poa_sky_diffuse, poa_ground_diffuse) | |
poa_direct = poa['poa_direct'] | |
poa_diffuse = poa['poa_diffuse'] | |
poa_global = poa['poa_global'] | |
# wyznaczamy kat padania światła | |
iam = pvlib.iam.ashrae(aoi) | |
# efektywne poa | |
effective_irradiance = poa_direct*iam + poa_diffuse | |
# wyznaczenie temperatury modułu | |
temp_cell = pvlib.temperature.pvsyst_cell(poa_global, temp_air) | |
# wyznaczenie 5 parametrów modelu SDM | |
cec_params = pvlib.pvsystem.calcparams_cec(effective_irradiance, temp_cell, | |
CECMOD.alpha_sc, | |
CECMOD.a_ref, | |
CECMOD.I_L_ref, | |
CECMOD.I_o_ref, | |
CECMOD.R_sh_ref, | |
CECMOD.R_s, | |
CECMOD.Adjust) | |
mpp = pvlib.pvsystem.max_power_point(*cec_params, method='newton') | |
# zamiana wartości nan na 0 (godziny nocne) | |
mpp['i_mp'] = mpp['i_mp'].fillna(0) | |
mpp['v_mp'] = mpp['v_mp'].fillna(0) | |
mpp['p_mp'] = mpp['p_mp'].fillna(0) | |
# graficzne przedstawienie wyników | |
mpp.p_mp.resample('D').sum().plot(title='Dzienna ilość energii', figsize=(18,8)) | |
plt.ylabel('Produkcja [Wh]'); | |
plt.xlabel('Miesiące') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment