def pv_timeseries(lon, lat, solar_data, pv_panel, weather_dir, inverter_type, scale=True): """Generate PV power feedin timeseries.""" # pv system parameters system_data = { 'module_name': pv_panel, 'inverter_name': inverter_type, 'azimuth': 180, 'tilt': 30, 'albedo': 0.2 } pv_system = Photovoltaic(**system_data) if scale: feedin_pv = pv_system.feedin(weather=solar_data, location=(lat, lon), scaling="peak_power") else: feedin_pv = pv_system.feedin(weather=solar_data, location=(lat, lon)) peak_power_pv = pv_system.peak_power module_area = pv_system.area where_nan = isnan(feedin_pv) feedin_pv[where_nan] = 0 feedin_pv[feedin_pv < 0] = 0 pv_parameter = [peak_power_pv, module_area] pvpower = feedin_pv.to_frame().rename(columns={0: "pv"}) pvpower.to_csv(weather_dir + "pv_power.csv") logging.info("PV feedin timeseries generated.") return pv_parameter
def test_powerplant_requirements(self, pvlib_pv_system, pvlib_weather): """ Test that attribute error is not raised in case a valid model is specified when calling feedin method. """ test_module = Photovoltaic(**pvlib_pv_system) feedin = test_module.feedin(weather=pvlib_weather, model=Pvlib, location=(52, 13)) assert 143.28844 == pytest.approx(feedin.values[0], 1e-5)
def test_pvlib_feedin_with_surface_type(self, pvlib_pv_system, pvlib_weather): """ Test basic feedin calculation using pvlib and providing surface type instead of albedo. """ del pvlib_pv_system['albedo'] pvlib_pv_system['surface_type'] = 'grass' test_module = Photovoltaic(**pvlib_pv_system) feedin = test_module.feedin(weather=pvlib_weather, location=(52, 13)) assert 143.28844 == pytest.approx(feedin.values[0], 1e-5)
def test_pvlib_feedin(self, pvlib_pv_system, pvlib_weather): """ Test basic feedin calculation using pvlib. It is also tested if dictionary with PV system parameters remains the same to make sure it could be further used to calculate feed-in with a different model. """ test_copy = deepcopy(pvlib_pv_system) test_module = Photovoltaic(**pvlib_pv_system) feedin = test_module.feedin(weather=pvlib_weather, location=(52, 13)) assert 143.28844 == pytest.approx(feedin.values[0], 1e-5) assert test_copy == pvlib_pv_system
def test_powerplant_requirements_2(self, pvlib_pv_system, pvlib_weather): """ Test that attribute error is raised in case required power plant parameters are missing when feedin is called with a different model than initially specified. """ test_module = Photovoltaic(**pvlib_pv_system) msg = "The specified model 'windpowerlib_single_turbine' requires" with pytest.raises(AttributeError, match=msg): test_module.feedin(weather=pvlib_weather, model=WindpowerlibTurbine, location=(52, 13))
def test_pvlib_feedin_with_optional_pp_parameter(self, pvlib_pv_system, pvlib_weather): """ Test basic feedin calculation using pvlib and providing an optional PV system parameter. """ pvlib_pv_system['strings_per_inverter'] = 2 test_module = Photovoltaic(**pvlib_pv_system) feedin = test_module.feedin(weather=pvlib_weather, location=(52, 13)) # power output is in this case limited by the inverter, which is why # power output with 2 strings is not twice as high as power output of # one string assert 250.0 == pytest.approx(feedin.values[0], 1e-5)
def test_pv_feedin_scaling(self, pvlib_pv_system, pvlib_weather): """ Test that PV feedin timeseries are scaled correctly. """ test_module = Photovoltaic(**pvlib_pv_system) feedin = test_module.feedin(weather=pvlib_weather, location=(52, 13), scaling='peak_power') assert 0.67462 == pytest.approx(feedin.values[0], 1e-5) feedin = test_module.feedin(weather=pvlib_weather, location=(52, 13), scaling='area') assert 84.28732 == pytest.approx(feedin.values[0], 1e-5)
def test_pvlib_missing_powerplant_parameter(self, pvlib_pv_system): """ Test if initialization of powerplant fails in case of missing power plant parameter. """ del (pvlib_pv_system['albedo']) msg = "The specified model 'pvlib' requires" with pytest.raises(AttributeError, match=msg): Photovoltaic(**pvlib_pv_system)
weather_df_pv['ghi'] = weather_df_pv.dirhi + weather_df_pv.dhi weather_df_pv.rename(columns={'v_wind': 'wind_speed'}, inplace=True) # ######## Pvlib model ######### # specify pv system yingli210 = { 'module_name': 'Yingli_YL210__2008__E__', 'inverter_name': 'ABB__PVI_3_0_OUTD_S_US_Z__277V__277V__CEC_2018_', 'azimuth': 180, 'tilt': 30, 'albedo': 0.2, 'modules_per_string': 4} # instantiate feedinlib Photovoltaic object yingli_module = Photovoltaic(**yingli210) # calculate feedin feedin = yingli_module.feedin( weather=weather_df_pv[['wind_speed', 'temp_air', 'dhi', 'ghi']], location=(52, 13), scaling='peak_power', scaling_value=10) # plot feedin.fillna(0).plot(title='PV feedin') plt.xlabel('Time') plt.ylabel('Power in W') plt.show() # ######## WindpowerlibTurbine model ######### # specify wind turbine