def test_infer_dc_model(system, cec_dc_snl_ac_system, pvsyst_dc_snl_ac_system, pvwatts_dc_pvwatts_ac_system, location, dc_model, weather, mocker): dc_systems = {'sapm': system, 'cec': cec_dc_snl_ac_system, 'desoto': cec_dc_snl_ac_system, 'pvsyst': pvsyst_dc_snl_ac_system, 'singlediode': cec_dc_snl_ac_system, 'pvwatts_dc': pvwatts_dc_pvwatts_ac_system} dc_model_function = {'sapm': 'sapm', 'cec': 'calcparams_cec', 'desoto': 'calcparams_desoto', 'pvsyst': 'calcparams_pvsyst', 'singlediode': 'calcparams_desoto', 'pvwatts_dc': 'pvwatts_dc'} system = dc_systems[dc_model] # remove Adjust from model parameters for desoto, singlediode if dc_model in ['desoto', 'singlediode']: system.module_parameters.pop('Adjust') m = mocker.spy(system, dc_model_function[dc_model]) mc = ModelChain(system, location, aoi_model='no_loss', spectral_model='no_loss') mc.run_model(weather.index, weather=weather) assert m.call_count == 1 assert isinstance(mc.dc, (pd.Series, pd.DataFrame))
def test_aoi_model_no_loss(system, location, weather): mc = ModelChain(system, location, dc_model='sapm', aoi_model='no_loss', spectral_model='no_loss') mc.run_model(weather.index, weather=weather) assert mc.aoi_modifier == 1.0 assert not mc.ac.empty assert mc.ac[0] > 150 and mc.ac[0] < 200 assert mc.ac[1] < 1
def test_ac_model_user_func(pvwatts_dc_pvwatts_ac_system, location, weather, mocker): m = mocker.spy(sys.modules[__name__], 'acdc') mc = ModelChain(pvwatts_dc_pvwatts_ac_system, location, ac_model=acdc, aoi_model='no_loss', spectral_model='no_loss') mc.run_model(weather.index, weather=weather) assert m.call_count == 1 assert_series_equal(mc.ac, mc.dc) assert not mc.ac.empty
def test_dc_model_user_func(pvwatts_dc_pvwatts_ac_system, location, weather, mocker): m = mocker.spy(sys.modules[__name__], 'poadc') mc = ModelChain(pvwatts_dc_pvwatts_ac_system, location, dc_model=poadc, aoi_model='no_loss', spectral_model='no_loss') mc.run_model(weather.index, weather=weather) assert m.call_count == 1 assert isinstance(mc.ac, (pd.Series, pd.DataFrame)) assert not mc.ac.empty
def test_aoi_models(system, location, aoi_model, method, weather, mocker): mc = ModelChain(system, location, dc_model='sapm', aoi_model=aoi_model, spectral_model='no_loss') m = mocker.spy(system, method) mc.run_model(weather.index, weather=weather) assert m.call_count == 1 assert isinstance(mc.ac, pd.Series) assert not mc.ac.empty assert mc.ac[0] > 150 and mc.ac[0] < 200 assert mc.ac[1] < 1
def test_losses_models_no_loss(pvwatts_dc_pvwatts_ac_system, location, weather, mocker): m = mocker.spy(pvsystem, 'pvwatts_losses') mc = ModelChain(pvwatts_dc_pvwatts_ac_system, location, dc_model='pvwatts', aoi_model='no_loss', spectral_model='no_loss', losses_model='no_loss') assert mc.losses_model == mc.no_extra_losses mc.run_model(weather.index, weather=weather) assert m.call_count == 0 assert mc.losses == 1
def test_aoi_model_user_func(system, location, weather, mocker): m = mocker.spy(sys.modules[__name__], 'constant_aoi_loss') mc = ModelChain(system, location, dc_model='sapm', aoi_model=constant_aoi_loss, spectral_model='no_loss') mc.run_model(weather.index, weather=weather) assert m.call_count == 1 assert mc.aoi_modifier == 0.9 assert not mc.ac.empty assert mc.ac[0] > 140 and mc.ac[0] < 200 assert mc.ac[1] < 1
def test_losses_models_ext_def(pvwatts_dc_pvwatts_ac_system, location, weather, mocker): m = mocker.spy(sys.modules[__name__], 'constant_losses') mc = ModelChain(pvwatts_dc_pvwatts_ac_system, location, dc_model='pvwatts', aoi_model='no_loss', spectral_model='no_loss', losses_model=constant_losses) mc.run_model(weather.index, weather=weather) assert m.call_count == 1 assert isinstance(mc.ac, (pd.Series, pd.DataFrame)) assert mc.losses == 0.9 assert not mc.ac.empty
def test_run_model_tracker(system, location, weather, mocker): system = SingleAxisTracker(module_parameters=system.module_parameters, inverter_parameters=system.inverter_parameters) mocker.spy(system, 'singleaxis') mc = ModelChain(system, location) mc.run_model(weather.index, weather=weather) assert system.singleaxis.call_count == 1 assert (mc.tracking.columns == ['tracker_theta', 'aoi', 'surface_azimuth', 'surface_tilt']).all() assert mc.ac[0] > 0 assert np.isnan(mc.ac[1])
def test_run_model_times(system, location): mc = ModelChain(system, location) times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') irradiance = pd.DataFrame({ 'dni': 900, 'ghi': 600, 'dhi': 150 }, index=times) with pytest.warns(pvlibDeprecationWarning): mc.run_model(irradiance, times=times)
def test_run_model_with_weather(system, location, weather, mocker): mc = ModelChain(system, location) m = mocker.spy(system, 'sapm_celltemp') weather['wind_speed'] = 5 weather['temp_air'] = 10 mc.run_model(weather.index, weather=weather) assert m.call_count == 1 # assert_called_once_with cannot be used with series, so need to use # assert_series_equal on call_args assert_series_equal(m.call_args[0][1], weather['wind_speed']) # wind assert_series_equal(m.call_args[0][2], weather['temp_air']) # temp assert not mc.ac.empty
def test_weather_irradiance_input(system, location): """Test will raise a warning and should be removed in future versions.""" mc = ModelChain(system, location) times = pd.date_range('2012-06-01 12:00:00', periods=2, freq='H') i = pd.DataFrame({'dni': [2, 3], 'dhi': [4, 6], 'ghi': [9, 5]}, index=times) w = pd.DataFrame({'wind_speed': [11, 5], 'temp_air': [30, 32]}, index=times) mc.run_model(times, irradiance=i, weather=w) assert_series_equal(mc.weather['dni'], pd.Series([2, 3], index=times, name='dni')) assert_series_equal(mc.weather['wind_speed'], pd.Series([11, 5], index=times, name='wind_speed'))
def download_forecasts(request): modules_per_string = request.session['modules_per_string'] strings_per_inverter = request.session['strings_per_inverter'] module = request.session['module'] inverter = request.session['inverter'] latitude = request.session['latitude'] longitude = request.session['longitude'] tz = request.session['timezone'] sandia_modules = retrieve_sam('SandiaMod') cec_inverters = retrieve_sam('SandiaInverter') # Parametros de la granja solar surface_tilt = 30 surface_azimuth = 180 # pvlib uses 0=North, 90=East, 180=South, 270=West convention albedo = 0.2 # Rango de tiempo start = pd.Timestamp(date.today(), tz=tz) # Pronostico a 3 días en adelante end = start + pd.Timedelta(days=3) module = pd.Series(sandia_modules[module]) inverter = cec_inverters[inverter] # model a big tracker for more fun system = SingleAxisTracker(module_parameters=module, inverter_parameters=inverter, modules_per_string=modules_per_string, strings_per_inverter=strings_per_inverter) # fx is a common abbreviation for forecast fx_model = GFS() fx_data = fx_model.get_processed_data(latitude, longitude, start, end) # use a ModelChain object to calculate modeling intermediates mc = ModelChain(system, fx_model.location) # extract relevant data for model chain mc.run_model(fx_data.index, weather=fx_data) AC = mc.ac.fillna(0) response = HttpResponse(content_type='text/csv') response[ 'Content-Disposition'] = 'attachment; filename=AC_5days_forecasts.csv' AC.to_csv(path_or_buf=response, sep=';', float_format='%.2f', index=True, decimal=",") return response
def test_infer_dc_model(system, cec_dc_snl_ac_system, pvsyst_dc_snl_ac_system, pvwatts_dc_pvwatts_ac_system, location, dc_model, weather, mocker): dc_systems = { 'sapm': system, 'cec': cec_dc_snl_ac_system, 'desoto': cec_dc_snl_ac_system, 'pvsyst': pvsyst_dc_snl_ac_system, 'singlediode': cec_dc_snl_ac_system, 'pvwatts_dc': pvwatts_dc_pvwatts_ac_system } dc_model_function = { 'sapm': 'sapm', 'cec': 'calcparams_cec', 'desoto': 'calcparams_desoto', 'pvsyst': 'calcparams_pvsyst', 'singlediode': 'calcparams_desoto', 'pvwatts_dc': 'pvwatts_dc' } temp_model_function = { 'sapm': 'sapm', 'cec': 'sapm', 'desoto': 'sapm', 'pvsyst': 'pvsyst', 'singlediode': 'sapm', 'pvwatts_dc': 'sapm' } temp_model_params = { 'sapm': { 'a': -3.40641, 'b': -0.0842075, 'deltaT': 3 }, 'pvsyst': { 'u_c': 29.0, 'u_v': 0 } } system = dc_systems[dc_model] system.temperature_model_parameters = temp_model_params[ temp_model_function[dc_model]] # remove Adjust from model parameters for desoto, singlediode if dc_model in ['desoto', 'singlediode']: system.module_parameters.pop('Adjust') m = mocker.spy(system, dc_model_function[dc_model]) mc = ModelChain(system, location, aoi_model='no_loss', spectral_model='no_loss', temperature_model=temp_model_function[dc_model]) mc.run_model(weather) assert m.call_count == 1 assert isinstance(mc.dc, (pd.Series, pd.DataFrame))
def test_dc_model_user_func(pvwatts_dc_pvwatts_ac_system, location, weather, mocker): m = mocker.spy(sys.modules[__name__], 'poadc') mc = ModelChain(pvwatts_dc_pvwatts_ac_system, location, dc_model=poadc, aoi_model='no_loss', spectral_model='no_loss') mc.run_model(weather) assert m.call_count == 1 assert isinstance(mc.ac, (pd.Series, pd.DataFrame)) assert not mc.ac.empty
def test_ac_model_user_func(pvwatts_dc_pvwatts_ac_system, location, weather, mocker): m = mocker.spy(sys.modules[__name__], 'acdc') mc = ModelChain(pvwatts_dc_pvwatts_ac_system, location, ac_model=acdc, aoi_model='no_loss', spectral_model='no_loss') mc.run_model(weather) assert m.call_count == 1 assert_series_equal(mc.ac, mc.dc) assert not mc.ac.empty
def test_infer_dc_model(system, cec_dc_snl_ac_system, pvwatts_dc_pvwatts_ac_system, location, dc_model, mocker): dc_systems = {'sapm': system, 'singlediode': cec_dc_snl_ac_system, 'pvwatts_dc': pvwatts_dc_pvwatts_ac_system} system = dc_systems[dc_model] m = mocker.spy(system, dc_model) mc = ModelChain(system, location, aoi_model='no_loss', spectral_model='no_loss') times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') mc.run_model(times) assert m.call_count == 1 assert isinstance(mc.dc, (pd.Series, pd.DataFrame))
def test_aoi_models(system, location, aoi_model, weather, mocker): mc = ModelChain(system, location, dc_model='sapm', aoi_model=aoi_model, spectral_model='no_loss') m = mocker.spy(system, 'get_iam') mc.run_model(weather=weather) assert m.call_count == 1 assert isinstance(mc.ac, pd.Series) assert not mc.ac.empty assert mc.ac[0] > 150 and mc.ac[0] < 200 assert mc.ac[1] < 1
def test_losses_models_pvwatts(pvwatts_dc_pvwatts_ac_system, location, weather, mocker): age = 1 pvwatts_dc_pvwatts_ac_system.losses_parameters = dict(age=age) m = mocker.spy(pvsystem, 'pvwatts_losses') mc = ModelChain(pvwatts_dc_pvwatts_ac_system, location, dc_model='pvwatts', aoi_model='no_loss', spectral_model='no_loss', losses_model='pvwatts') mc.run_model(weather.index, weather=weather) assert m.call_count == 1 m.assert_called_with(age=age) assert isinstance(mc.ac, (pd.Series, pd.DataFrame)) assert not mc.ac.empty
def test_run_model_with_weather_fuentes_temp(sapm_dc_snl_ac_system, location, weather, mocker): weather['wind_speed'] = 5 weather['temp_air'] = 10 sapm_dc_snl_ac_system.temperature_model_parameters = {'noct_installed': 45} mc = ModelChain(sapm_dc_snl_ac_system, location) mc.temperature_model = 'fuentes' m_fuentes = mocker.spy(sapm_dc_snl_ac_system, 'fuentes_celltemp') mc.run_model(weather) assert m_fuentes.call_count == 1 assert_series_equal(m_fuentes.call_args[0][1], weather['temp_air']) assert_series_equal(m_fuentes.call_args[0][2], weather['wind_speed']) assert not mc.ac.empty
def test_losses_models_no_loss(pvwatts_dc_pvwatts_ac_system, location, weather, mocker): m = mocker.spy(pvsystem, 'pvwatts_losses') mc = ModelChain(pvwatts_dc_pvwatts_ac_system, location, dc_model='pvwatts', aoi_model='no_loss', spectral_model='no_loss', losses_model='no_loss') assert mc.losses_model == mc.no_extra_losses mc.run_model(weather) assert m.call_count == 0 assert mc.losses == 1
def test_aoi_model_user_func(system, location, weather, mocker): m = mocker.spy(sys.modules[__name__], 'constant_aoi_loss') mc = ModelChain(system, location, dc_model='sapm', aoi_model=constant_aoi_loss, spectral_model='no_loss') mc.run_model(weather) assert m.call_count == 1 assert mc.aoi_modifier == 0.9 assert not mc.ac.empty assert mc.ac[0] > 140 and mc.ac[0] < 200 assert mc.ac[1] < 1
def test_run_model_with_weather_sapm_temp(sapm_dc_snl_ac_system, location, weather, mocker): # test with sapm cell temperature model weather['wind_speed'] = 5 weather['temp_air'] = 10 mc = ModelChain(sapm_dc_snl_ac_system, location) mc.temperature_model = 'sapm' m_sapm = mocker.spy(sapm_dc_snl_ac_system, 'sapm_celltemp') mc.run_model(weather) assert m_sapm.call_count == 1 # assert_called_once_with cannot be used with series, so need to use # assert_series_equal on call_args assert_series_equal(m_sapm.call_args[0][1], weather['temp_air']) # temp assert_series_equal(m_sapm.call_args[0][2], weather['wind_speed']) # wind assert not mc.ac.empty
def test_ac_models(system, cec_dc_adr_ac_system, pvwatts_dc_pvwatts_ac_system, location, ac_model, weather, mocker): ac_systems = {'snlinverter': system, 'adrinverter': cec_dc_adr_ac_system, 'pvwatts': pvwatts_dc_pvwatts_ac_system} system = ac_systems[ac_model] mc = ModelChain(system, location, ac_model=ac_model, aoi_model='no_loss', spectral_model='no_loss') if ac_model == 'pvwatts': ac_model += '_ac' m = mocker.spy(system, ac_model) mc.run_model(weather.index, weather=weather) assert m.call_count == 1 assert isinstance(mc.ac, pd.Series) assert not mc.ac.empty assert mc.ac[1] < 1
def test_run_model_with_weather_faiman_temp(sapm_dc_snl_ac_system, location, weather, mocker): # test with faiman cell temperature model weather['wind_speed'] = 5 weather['temp_air'] = 10 sapm_dc_snl_ac_system.temperature_model_parameters = { 'u0': 25.0, 'u1': 6.84 } mc = ModelChain(sapm_dc_snl_ac_system, location) mc.temperature_model = 'faiman' m_faiman = mocker.spy(sapm_dc_snl_ac_system, 'faiman_celltemp') mc.run_model(weather) assert m_faiman.call_count == 1 assert_series_equal(m_faiman.call_args[0][1], weather['temp_air']) assert_series_equal(m_faiman.call_args[0][2], weather['wind_speed']) assert not mc.ac.empty
def test_run_model_with_weather_pvsyst_temp(sapm_dc_snl_ac_system, location, weather, mocker): # test with pvsyst cell temperature model weather['wind_speed'] = 5 weather['temp_air'] = 10 sapm_dc_snl_ac_system.racking_model = 'freestanding' sapm_dc_snl_ac_system.temperature_model_parameters = \ temperature._temperature_model_params('pvsyst', 'freestanding') mc = ModelChain(sapm_dc_snl_ac_system, location) mc.temperature_model = 'pvsyst' m_pvsyst = mocker.spy(sapm_dc_snl_ac_system, 'pvsyst_celltemp') mc.run_model(weather) assert m_pvsyst.call_count == 1 assert_series_equal(m_pvsyst.call_args[0][1], weather['temp_air']) assert_series_equal(m_pvsyst.call_args[0][2], weather['wind_speed']) assert not mc.ac.empty
def test_spectral_models(system, location, spectral_model, weather): # add pw to weather dataframe weather['precipitable_water'] = [0.3, 0.5] mc = ModelChain(system, location, dc_model='sapm', aoi_model='no_loss', spectral_model=spectral_model) spectral_modifier = mc.run_model(weather).spectral_modifier assert isinstance(spectral_modifier, (pd.Series, float, int))
def test_ac_models(system, cec_dc_adr_ac_system, pvwatts_dc_pvwatts_ac_system, location, ac_model, weather, mocker): ac_systems = {'snlinverter': system, 'adrinverter': cec_dc_adr_ac_system, 'pvwatts': pvwatts_dc_pvwatts_ac_system} system = ac_systems[ac_model] mc = ModelChain(system, location, ac_model=ac_model, aoi_model='no_loss', spectral_model='no_loss') if ac_model == 'pvwatts': ac_model += '_ac' m = mocker.spy(system, ac_model) mc.run_model(weather) assert m.call_count == 1 assert isinstance(mc.ac, pd.Series) assert not mc.ac.empty assert mc.ac[1] < 1
def test_spectral_models(system, location, spectral_model, expected): mc = ModelChain(system, location, dc_model='sapm', aoi_model='no_loss', spectral_model=spectral_model) times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') ac = mc.run_model(times).ac expected = pd.Series(np.array(expected), index=times) assert_series_equal(ac, expected, check_less_precise=2)
def test_aoi_models(system, location, aoi_model, expected): mc = ModelChain(system, location, dc_model='sapm', aoi_model=aoi_model, spectral_model='no_loss') times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') ac = mc.run_model(times).ac expected = pd.Series(np.array(expected), index=times) assert_series_equal(ac, expected, check_less_precise=2)
def test_run_model(system, location): mc = ModelChain(system, location) times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') ac = mc.run_model(times).ac expected = pd.Series(np.array([183.522449305, -2.00000000e-02]), index=times) assert_series_equal(ac, expected, check_less_precise=2)
def test_infer_dc_model(system, cec_dc_snl_ac_system, pvwatts_dc_pvwatts_ac_system, location, dc_model, weather, mocker): dc_systems = { 'sapm': system, 'singlediode': cec_dc_snl_ac_system, 'pvwatts_dc': pvwatts_dc_pvwatts_ac_system } system = dc_systems[dc_model] m = mocker.spy(system, dc_model) mc = ModelChain(system, location, aoi_model='no_loss', spectral_model='no_loss') mc.run_model(weather.index, weather=weather) assert m.call_count == 1 assert isinstance(mc.dc, (pd.Series, pd.DataFrame))
def test_run_model(system, location): mc = ModelChain(system, location) times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') ac = mc.run_model(times).ac expected = pd.Series(np.array([ 1.82033564e+02, -2.00000000e-02]), index=times) assert_series_equal(ac, expected, check_less_precise=2)
def test_run_model_with_weather(system, location): mc = ModelChain(system, location) times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') weather = pd.DataFrame({'wind_speed': 5, 'temp_air': 10}, index=times) ac = mc.run_model(times, weather=weather).ac expected = pd.Series(np.array([201.691634921, -2.00000000e-02]), index=times) assert_series_equal(ac, expected, check_less_precise=2)
def test_run_model(): system, location = mc_setup() mc = ModelChain(system, location) times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') ac = mc.run_model(times).ac expected = pd.Series(np.array([ 1.82033564e+02, -2.00000000e-02]), index=times) assert_series_equal(ac, expected)
def test_run_model_with_weather(system, location): mc = ModelChain(system, location) times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') weather = pd.DataFrame({'wind_speed':5, 'temp_air':10}, index=times) ac = mc.run_model(times, weather=weather).ac expected = pd.Series(np.array([ 1.99952400e+02, -2.00000000e-02]), index=times) assert_series_equal(ac, expected, check_less_precise=2)
def test_run_model_with_weather(): system, location = mc_setup() mc = ModelChain(system, location) times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') weather = pd.DataFrame({'wind_speed':5, 'temp_air':10}, index=times) ac = mc.run_model(times, weather=weather).ac expected = pd.Series(np.array([ 1.99952400e+02, -2.00000000e-02]), index=times) assert_series_equal(ac, expected)
def test_run_model_perez(system, location): mc = ModelChain(system, location, transposition_model='perez') times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') irradiance = pd.DataFrame({'dni': 900, 'ghi': 600, 'dhi': 150}, index=times) ac = mc.run_model(irradiance).ac expected = pd.Series(np.array([187.94295642, -2.00000000e-02]), index=times) assert_series_equal(ac, expected)
def test_run_model_with_irradiance(system, location): mc = ModelChain(system, location) times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') irradiance = pd.DataFrame({'dni': 900, 'ghi': 600, 'dhi': 150}, index=times) ac = mc.run_model(irradiance).ac expected = pd.Series(np.array([187.80746494643176, -0.02]), index=times) assert_series_equal(ac, expected)
def test_spectral_models(system, location, spectral_model): times = pd.date_range('20160101 1200-0700', periods=3, freq='6H') weather = pd.DataFrame(data=[0.3, 0.5, 1.0], index=times, columns=['precipitable_water']) mc = ModelChain(system, location, dc_model='sapm', aoi_model='no_loss', spectral_model=spectral_model) spectral_modifier = mc.run_model(times=times, weather=weather).spectral_modifier assert isinstance(spectral_modifier, (pd.Series, float, int))
def test_run_model_with_irradiance(system, location): mc = ModelChain(system, location) times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') irradiance = pd.DataFrame({'dni':900, 'ghi':600, 'dhi':150}, index=times) ac = mc.run_model(times, irradiance=irradiance).ac expected = pd.Series(np.array([ 1.90054749e+02, -2.00000000e-02]), index=times) assert_series_equal(ac, expected)
def test_run_model_perez(system, location): mc = ModelChain(system, location, transposition_model='perez') times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') irradiance = pd.DataFrame({'dni':900, 'ghi':600, 'dhi':150}, index=times) ac = mc.run_model(times, irradiance=irradiance).ac expected = pd.Series(np.array([ 190.194545796, -2.00000000e-02]), index=times) assert_series_equal(ac, expected)
def test_ac_models(system, cec_dc_adr_ac_system, pvwatts_dc_pvwatts_ac_system, location, ac_model, expected): ac_systems = {'snlinverter': system, 'adrinverter': cec_dc_adr_ac_system, 'pvwatts': pvwatts_dc_pvwatts_ac_system, acdc: pvwatts_dc_pvwatts_ac_system} system = ac_systems[ac_model] mc = ModelChain(system, location, ac_model=ac_model, aoi_model='no_loss', spectral_model='no_loss') times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') ac = mc.run_model(times).ac expected = pd.Series(np.array(expected), index=times) assert_series_equal(ac, expected, check_less_precise=2)
def test_run_model_tracker(system, location): system = SingleAxisTracker(module_parameters=system.module_parameters, inverter_parameters=system.inverter_parameters) mc = ModelChain(system, location) times = pd.date_range('20160101 1200-0700', periods=2, freq='6H') ac = mc.run_model(times).ac expected = pd.Series(np.array([ 121.421719, -2.00000000e-02]), index=times) assert_series_equal(ac, expected, check_less_precise=2) expected = pd.DataFrame(np. array([[ 54.82513187, 90. , 11.0039221 , 11.0039221 ], [ nan, 0. , 0. , nan]]), columns=['aoi', 'surface_azimuth', 'surface_tilt', 'tracker_theta'], index=times) assert_frame_equal(mc.tracking, expected, check_less_precise=2)
} # own location parameter wittenberg = { 'altitude': 34, 'name': 'Wittenberg', 'latitude': my_weather.latitude, 'longitude': my_weather.longitude, } # the following has been implemented in the pvlib ModelChain in the # complete_irradiance method (pvlib version > v0.4.5) if w.get('dni') is None: w['dni'] = (w.ghi - w.dhi) / cosd( Location(**wittenberg).get_solarposition(times).zenith) # pvlib's ModelChain mc = ModelChain(PVSystem(**yingli210), Location(**wittenberg), orientation_strategy='south_at_latitude_tilt') mc.run_model(times, weather=w) if plt: mc.dc.p_mp.fillna(0).plot() plt.show() else: logging.warning("No plots shown. Install matplotlib to see the plots.") logging.info('Done!')