Error while plotting a modelchain

81 views
Skip to first unread message

Luis Enrique Orozco Villanueva

unread,
Apr 25, 2024, 3:17:55 AM4/25/24
to pvlib-python
I´m doing an school project with the pvlib library for a real PV installation, but when I tried to plot the modelchain for the AC generation I got the error as shown below in the code. I hope someone can help me with this. Thanks a lot.

import pvlib
from pvlib import clearsky, atmosphere, solarposition
from pvlib.modelchain import ModelChain
from pvlib.location import Location
from pvlib.pvsystem import PVSystem, Array, SingleAxisTrackerMount, AbstractMount, FixedMount
from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS

location = Location(latitude = 40.30117520975112, longitude = -3.6973221576701967, tz = "Europe/Madrid", altitude = 660, name = 'Ormazabal Getafe')
modules = pvlib.pvsystem.retrieve_sam('CECMod')
inverters = pvlib.pvsystem.retrieve_sam('CECInverter')
module = modules['JA_Solar_JAP72S01_330_SC']
inverter = inverters['SMA_America__STP_33_US_41__480V_']
temp_par = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_glass']
system = PVSystem(surface_tilt = 19, surface_azimuth = 170, module_parameters = module, inverter_parameters = inverter,
                  temperature_model_parameters = temp_par, modules_per_string = 17, strings_per_inverter = 6)
modelchain = ModelChain(system, location, aoi_model = 'physical')

times = pd.date_range(start = '2023-06-01', end = '2023-12-15', freq = 'h', tz = location.tz)
solar_position = location.get_solarposition(times)
clearsky = location.get_clearsky(times)
clearsky.plot(figsize = (20, 8))
plt.ylabel('Irradiance $W/m^2$')
plt.title('Irradiance in the location')
plt.show()

modelchain.run_model(clearsky)
modelchain.results.ac.plot(figsize = (20, 8))
plt.show()

----> 26 modelchain.run_model(clearsky)
KeyError: 'precipitable_water'

cwh...@sandia.gov

unread,
Apr 25, 2024, 9:44:16 AM4/25/24
to pvlib-python
That looks like unintended behavior, that should be addressed with a change to pvlib.

Because modelchain.spectral_model is not set, modelchain attempts to infer a model from the module parameters, and decides to use the First Solar model, which expects precipitable water to be in the weather data.

You can set spectral_model='no_loss' to get past this error.

Cliff

cwh...@sandia.gov

unread,
Apr 25, 2024, 9:53:18 AM4/25/24
to pvlib-python
Reply all
Reply to author
Forward
0 new messages