Skip to content

Photovoltaic power

Using the API, or indeed the CLI interface in a programmatic way, however, we can generate photovoltaic power series.

To do so, we need to define the location and time of interest, import some PVGIS-native data classes and naturally the corresponding API or CLI functions.

Following is a how-to example, using however an interactive i/python session. So, it's recommended to launch an ipython interpreter :

ipython

and follow along.

Rich output

rich is installed by default along with PVGIS. In case, however, it isn't installed, you may want to install it for a great visual experience when printing out Python objects.

pip install rich

Tip

You, can import the print function from the rich library. This will prettify the output !

>>> from rich import print

Where ?

Define the geographic location and the positioning of our solar surface

>>> latitude = 1
>>> longitude = 1
>>> elevation = 214
>>> surface_orientation = 1
>>> surface_tilt = 1

When ?

Prepate a series of timestamps as a Pandas DatetimeIndex, using our helper function generate_datetime_series

>>> from pvgis.api.datetime.datetimeindex import generate_datetime_series
>>> timestamps = generate_datetime_series(start_time="2010-01-27 08:00:00", end_time="2010-01-27 18:00:00", frequency="h")

and the default UTC timezone as a ZoneInfo object

>>> from zoneinfo import ZoneInfo
>>> utc_zone = ZoneInfo("UTC")

Let's confirm the generation of the timestamps and the timezone :

>>> print(f'{timestamps=}')
>>> print(f'\n{utc_zone=}')

timestamps=DatetimeIndex(['2010-01-27 08:00:00', '2010-01-27 09:00:00', '2010-01-27 10:00:00', '2010-01-27 11:00:00', '2010-01-27 12:00:00', '2010-01-27 13:00:00', '2010-01-27 14:00:00', '2010-01-27 15:00:00', '2010-01-27 16:00:00', '2010-01-27 17:00:00', '2010-01-27 18:00:00'], dtype='datetime64[us]', freq='h')

utc_zone=zoneinfo.ZoneInfo(key='UTC')

Important parameters

First, import required modules and custom data classes

Linke turbidity

>>> from pvgis import LinkeTurbidityFactor
>>> linke_turbidity_factor_series = LinkeTurbidityFactor(value=1)

Type of the photovoltaic module

>>> from pvgis.api.power.photovoltaic_module import PhotovoltaicModuleModel
>>> photovoltaic_module = PhotovoltaicModuleModel.CIS_FREE_STANDING

Temperature and Wind Speed

>>> from pvgis import TemperatureSeries, WindSpeedSeries
>>> temperature_series = TemperatureSeries(value=14)
>>> wind_speed_series = WindSpeedSeries(value=0)

Spectral factor series

>>> from pvgis import SpectralFactorSeries
>>> spectral_factor_series=SpectralFactorSeries(value=1)

Power

Now we can use the API function calculate_photovoltaic_power_output_series :

>>> from pvgis.api.power.broadband import (calculate_photovoltaic_power_output_series)
>>> power = calculate_photovoltaic_power_output_series(
>>>     longitude=longitude,
>>>     latitude=latitude,
>>>     elevation=elevation,
>>>     surface_orientation=surface_orientation,
>>>     surface_tilt=surface_tilt,
>>>     timestamps=timestamps,
>>>     timezone=utc_zone,
>>>     linke_turbidity_factor_series=linke_turbidity_factor_series,
>>>     photovoltaic_module=photovoltaic_module,
>>>     spectral_factor_series=spectral_factor_series,
>>>     temperature_series=temperature_series,
>>>     wind_speed_series=wind_speed_series,
>>> )

Inspect the power output

>>> print(f'{power=}')

power=PhotovoltaicPower(value=array([7.7283497, 7.577199 , 6.130275 , 3.6685097, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), unit='W', symbol=None, desription=None, location='(0.0, 0.0)', elevation=214.0, surface_orientation=1.0, optimal=False, optimiser=None, surface_tilt=1.0, solar_positioning_algorithm=None, solar_timing_algorithm=None, irradiance=array([15.537415, 15.311956, 13.118238, 9.180876, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), irradiance_data_source=None, pv_technology='Crystalline silicon', system_loss=None, components={'title': 'PV Power', 'power': array([7.7283497, 7.577199 , 6.130275 , 3.6685097, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), 'module_type': 'Mono-Facial', 'technology': 'CIS:Free standing', 'peak_power': 1, 'peak_power_unit': 'kWp', 'power_model': 'Huld 2011', 'surface_orientation': 1, 'surface_tilt': 1, 'shading': 'Not performed', 'shading_states': [], 'unit': 'radians', 'incidence_algorithm': 'Iqbal', 'incidence_definition': 'Sun-Vector-to-Surface-Plane', 'sun_horizon_positions': [, , ], 'azimuth_origin': 'North', 'position_algorithm': 'NOAA', 'time_algorithm': 'NOAA', 'solar_constant': 1360.8, 'perigee': 0.048869, 'eccentricity': 0.03344, 'frequency': 'h'})

or indeed, some of the inner components

>>> print(f'Photovoltaic power series : {power.value}')

Photovoltaic power series : [7.7283497 7.577199 6.130275 3.6685097 0. 0. 0. 0. 0. 0. 0. ]

>>> print(f'Photovoltaic power components : {power.components}')

Photovoltaic power components : {'title': 'PV Power', 'power': array([7.7283497, 7.577199 , 6.130275 , 3.6685097, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), 'module_type': 'Mono-Facial', 'technology': 'CIS:Free standing', 'peak_power': 1, 'peak_power_unit': 'kWp', 'power_model': 'Huld 2011', 'surface_orientation': 1, 'surface_tilt': 1, 'shading': 'Not performed', 'shading_states': [], 'unit': 'radians', 'incidence_algorithm': 'Iqbal', 'incidence_definition': 'Sun-Vector-to-Surface-Plane', 'sun_horizon_positions': [, , ], 'azimuth_origin': 'North', 'position_algorithm': 'NOAA', 'time_algorithm': 'NOAA', 'solar_constant': 1360.8, 'perigee': 0.048869, 'eccentricity': 0.03344, 'frequency': 'h'}

Verbosity

With extra verbosity, which means more details

Level 1

Set verbosity=1

>>> power = calculate_photovoltaic_power_output_series(
>>>     longitude=longitude,
>>>     latitude=latitude,
>>>     elevation=elevation,
>>>     surface_orientation=surface_orientation,
>>>     surface_tilt=surface_tilt,
>>>     timestamps=timestamps,
>>>     timezone=utc_zone,
>>>     linke_turbidity_factor_series=linke_turbidity_factor_series,
>>>     photovoltaic_module=photovoltaic_module,
>>>     spectral_factor_series=spectral_factor_series,
>>>     temperature_series=temperature_series,
>>>     wind_speed_series=wind_speed_series,
>>>     verbose=1,  # or 2 or 3 and so on...
>>> )

and again inspect the power output

>>> print(f'{power=}')

power=PhotovoltaicPower(value=array([7.7283497, 7.577199 , 6.130275 , 3.6685097, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), unit='W', symbol=None, desription=None, location='(0.0, 0.0)', elevation=214.0, surface_orientation=1.0, optimal=False, optimiser=None, surface_tilt=1.0, solar_positioning_algorithm=None, solar_timing_algorithm=None, irradiance=array([15.537415, 15.311956, 13.118238, 9.180876, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), irradiance_data_source=None, pv_technology='Crystalline silicon', system_loss=None, components={'title': 'PV Power', 'power': array([7.7283497, 7.577199 , 6.130275 , 3.6685097, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), 'module_type': 'Mono-Facial', 'technology': 'CIS:Free standing', 'peak_power': 1, 'peak_power_unit': 'kWp', 'power_model': 'Huld 2011', 'surface_orientation': 1, 'surface_tilt': 1, 'shading': 'Not performed', 'shading_states': [], 'unit': 'radians', 'incidence_algorithm': 'Iqbal', 'incidence_definition': 'Sun-Vector-to-Surface-Plane', 'sun_horizon_positions': [, , ], 'azimuth_origin': 'North', 'position_algorithm': 'NOAA', 'time_algorithm': 'NOAA', 'solar_constant': 1360.8, 'perigee': 0.048869, 'eccentricity': 0.03344, 'frequency': 'h'})

Level 2 and 3

>>> power_2 = calculate_photovoltaic_power_output_series(
>>>     longitude=longitude,
>>>     latitude=latitude,
>>>     elevation=elevation,
>>>     surface_orientation=surface_orientation,
>>>     surface_tilt=surface_tilt,
>>>     timestamps=timestamps,
>>>     timezone=utc_zone,
>>>     linke_turbidity_factor_series=linke_turbidity_factor_series,
>>>     photovoltaic_module=photovoltaic_module,
>>>     spectral_factor_series=spectral_factor_series,
>>>     temperature_series=temperature_series,
>>>     wind_speed_series=wind_speed_series,
>>>     verbose=2,  # or 2 or 3 and so on...
>>> )
>>> power_3 = calculate_photovoltaic_power_output_series(
>>>     longitude=longitude,
>>>     latitude=latitude,
>>>     elevation=elevation,
>>>     surface_orientation=surface_orientation,
>>>     surface_tilt=surface_tilt,
>>>     timestamps=timestamps,
>>>     timezone=utc_zone,
>>>     linke_turbidity_factor_series=linke_turbidity_factor_series,
>>>     photovoltaic_module=photovoltaic_module,
>>>     spectral_factor_series=spectral_factor_series,
>>>     temperature_series=temperature_series,
>>>     wind_speed_series=wind_speed_series,
>>>     verbose=2,  # or 2 or 3 and so on...
>>> )
>>> print(f'{power_2=}')
>>> print(f'{power_3=}')

power_2=PhotovoltaicPower(value=array([7.7283497, 7.577199 , 6.130275 , 3.6685097, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), unit='W', symbol=None, desription=None, location='(0.0, 0.0)', elevation=214.0, surface_orientation=1.0, optimal=False, optimiser=None, surface_tilt=1.0, solar_positioning_algorithm=None, solar_timing_algorithm=None, irradiance=array([15.537415, 15.311956, 13.118238, 9.180876, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), irradiance_data_source=None, pv_technology='Crystalline silicon', system_loss=None, components={'title': 'PV Power', 'power': array([7.7283497, 7.577199 , 6.130275 , 3.6685097, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), 'module_type': 'Mono-Facial', 'technology': 'CIS:Free standing', 'peak_power': 1, 'peak_power_unit': 'kWp', 'power_model': 'Huld 2011', 'power_without_loss': array([8.986453 , 8.810697 , 7.1282263, 4.265709 , 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), 'surface_orientation': 1, 'surface_tilt': 1, 'shading': 'Not performed', 'shading_states': [], 'in_shade': array([False, False, False, False, False, True, True, True, True, True, True]), 'sun_horizon_position': ['Above', 'Above', 'Above', 'Above', 'Low angle', 'Below', 'Below', 'Below', 'Below', 'Below', 'Below'], 'unit': 'radians', 'incidence_algorithm': 'Iqbal', 'incidence_definition': 'Sun-Vector-to-Surface-Plane', 'sun_horizon_positions': [, , ], 'azimuth_origin': 'North', 'position_algorithm': 'NOAA', 'time_algorithm': 'NOAA', 'solar_constant': 1360.8, 'perigee': 0.048869, 'eccentricity': 0.03344, 'frequency': 'h'}) power_3=PhotovoltaicPower(value=array([7.7283497, 7.577199 , 6.130275 , 3.6685097, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), unit='W', symbol=None, desription=None, location='(0.0, 0.0)', elevation=214.0, surface_orientation=1.0, optimal=False, optimiser=None, surface_tilt=1.0, solar_positioning_algorithm=None, solar_timing_algorithm=None, irradiance=array([15.537415, 15.311956, 13.118238, 9.180876, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), irradiance_data_source=None, pv_technology='Crystalline silicon', system_loss=None, components={'title': 'PV Power', 'power': array([7.7283497, 7.577199 , 6.130275 , 3.6685097, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), 'module_type': 'Mono-Facial', 'technology': 'CIS:Free standing', 'peak_power': 1, 'peak_power_unit': 'kWp', 'power_model': 'Huld 2011', 'power_without_loss': array([8.986453 , 8.810697 , 7.1282263, 4.265709 , 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), 'surface_orientation': 1, 'surface_tilt': 1, 'shading': 'Not performed', 'shading_states': [], 'in_shade': array([False, False, False, False, False, True, True, True, True, True, True]), 'sun_horizon_position': ['Above', 'Above', 'Above', 'Above', 'Low angle', 'Below', 'Below', 'Below', 'Below', 'Below', 'Below'], 'unit': 'radians', 'incidence_algorithm': 'Iqbal', 'incidence_definition': 'Sun-Vector-to-Surface-Plane', 'sun_horizon_positions': [, , ], 'azimuth_origin': 'North', 'position_algorithm': 'NOAA', 'time_algorithm': 'NOAA', 'solar_constant': 1360.8, 'perigee': 0.048869, 'eccentricity': 0.03344, 'frequency': 'h'})

Verbosity

Verbosity

All in one

The easier way to replicate the above examples is an all-in-one code-block :

>>> from pvgis.api.datetime.datetimeindex import generate_datetime_series
>>> from zoneinfo import ZoneInfo
>>> from pvgis import LinkeTurbidityFactor
>>> from pvgis import TemperatureSeries, WindSpeedSeries
>>> from pvgis import SpectralFactorSeries
>>> from pvgis.api.power.photovoltaic_module import PhotovoltaicModuleModel
>>> from pvgis.api.power.broadband import calculate_photovoltaic_power_output_series
>>> latitude = 1
>>> longitude = 1
>>> elevation = 214
>>> surface_orientation = 1
>>> surface_tilt = 1
>>> timestamps = generate_datetime_series(start_time="2010-01-27 08:00:00", end_time="2010-01-27 18:00:00", frequency="h")
>>> utc_zone = ZoneInfo("UTC")
>>> linke_turbidity_factor_series = LinkeTurbidityFactor(value=1)
>>> photovoltaic_module = PhotovoltaicModuleModel.CIS_FREE_STANDING
>>> temperature_series = TemperatureSeries(value=14)
>>> wind_speed_series = WindSpeedSeries(value=0)
>>> spectral_factor_series=SpectralFactorSeries(value=1)
>>> power = calculate_photovoltaic_power_output_series(
>>>     longitude=longitude,
>>>     latitude=latitude,
>>>     elevation=elevation,
>>>     surface_orientation=surface_orientation,
>>>     surface_tilt=surface_tilt,
>>>     timestamps=timestamps,
>>>     timezone=utc_zone,
>>>     linke_turbidity_factor_series=linke_turbidity_factor_series,
>>>     photovoltaic_module=photovoltaic_module,
>>>     spectral_factor_series=spectral_factor_series,
>>>     temperature_series=temperature_series,
>>>     wind_speed_series=wind_speed_series,
>>> )
>>> print(f'{power=}')

power=PhotovoltaicPower(value=array([7.7283497, 7.577199 , 6.130275 , 3.6685097, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), unit='W', symbol=None, desription=None, location='(0.0, 0.0)', elevation=214.0, surface_orientation=1.0, optimal=False, optimiser=None, surface_tilt=1.0, solar_positioning_algorithm=None, solar_timing_algorithm=None, irradiance=array([15.537415, 15.311956, 13.118238, 9.180876, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), irradiance_data_source=None, pv_technology='Crystalline silicon', system_loss=None, components={'title': 'PV Power', 'power': array([7.7283497, 7.577199 , 6.130275 , 3.6685097, 0. , 0. , 0. , 0. , 0. , 0. , 0. ], dtype=float32), 'module_type': 'Mono-Facial', 'technology': 'CIS:Free standing', 'peak_power': 1, 'peak_power_unit': 'kWp', 'power_model': 'Huld 2011', 'surface_orientation': 1, 'surface_tilt': 1, 'shading': 'Not performed', 'shading_states': [], 'unit': 'radians', 'incidence_algorithm': 'Iqbal', 'incidence_definition': 'Sun-Vector-to-Surface-Plane', 'sun_horizon_positions': [, , ], 'azimuth_origin': 'North', 'position_algorithm': 'NOAA', 'time_algorithm': 'NOAA', 'solar_constant': 1360.8, 'perigee': 0.048869, 'eccentricity': 0.03344, 'frequency': 'h'})