Skip to content

Error with using PVGIS weather data (zenith conversion in airmass?) #2399

Open
@expeon07

Description

Describe the bug
Hi, I'm trying to run a ModelChain model using a weather file obtained through get_pvgis_tmy() function. However I am getting an error with the weather data

To Reproduce
Steps to reproduce the behavior:

weather, months, inputs, metadata = pvlib.iotools.get_pvgis_tmy(latitude, longitude, outputformat='epw', coerce_year=2023)

system_loss = 0.1
times = weather.index
solar_position = pvlib.solarposition.get_solarposition(times, latitude, longitude)

system = pvlib.pvsystem.PVSystem(
    surface_tilt=30,
    surface_azimuth=150,
    module_parameters=sandia_modules["Canadian_Solar_CS6X_300M__2013_"],
    inverter_parameters=cec_inverters["ABB__MICRO_0_25_I_OUTD_US_208__208V_"],
    temperature_model_parameters=pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS["sapm"]["open_rack_glass_glass"],

)

mc = pvlib.modelchain.ModelChain(system, location=location)
mc.prepare_inputs(weather)

Error

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
AttributeError: 'float' object has no attribute 'radians'

The above exception was the direct cause of the following exception:

TypeError                                 Traceback (most recent call last)
Cell In[6], line 23
     21 mc = pvlib.modelchain.ModelChain(system, location=location)
     22 print(mc)
---> 23 mc.prepare_inputs(weather)
     24 # # mc.run_model(weather)
     25 
     26 # ac_power = mc.ac * (1 - system_loss)
     27 # dc_power = mc.dc['p_mp']  # Maximum power point (Pmp)
     28 
     29 # print(dc_power)

File ~/.local/share/virtualenvs/Lowfield-Green-CSxyL99o/lib/python3.10/site-packages/pvlib/modelchain.py:1424, in ModelChain.prepare_inputs(self, weather)
   1421 self._assign_weather(weather)
   1423 self._prep_inputs_solar_pos(weather)
-> 1424 self._prep_inputs_airmass()
   1425 self._prep_inputs_albedo(weather)
   1426 self._prep_inputs_fixed()

File ~/.local/share/virtualenvs/Lowfield-Green-CSxyL99o/lib/python3.10/site-packages/pvlib/modelchain.py:1255, in ModelChain._prep_inputs_airmass(self)
   1251 def _prep_inputs_airmass(self):
   1252     """
   1253     Assign airmass
   1254     """
-> 1255     self.results.airmass = self.location.get_airmass(
   1256         solar_position=self.results.solar_position,
   1257         model=self.airmass_model)
   1258     return self

File ~/.local/share/virtualenvs/Lowfield-Green-CSxyL99o/lib/python3.10/site-packages/pvlib/location.py:319, in Location.get_airmass(self, times, solar_position, model)
    316 else:
    317     raise ValueError(f'{model} is not a valid airmass model')
--> 319 airmass_relative = atmosphere.get_relative_airmass(zenith, model)
    321 pressure = atmosphere.alt2pres(self.altitude)
    322 airmass_absolute = atmosphere.get_absolute_airmass(airmass_relative,
    323                                                    pressure)

File ~/.local/share/virtualenvs/Lowfield-Green-CSxyL99o/lib/python3.10/site-packages/pvlib/atmosphere.py:219, in get_relative_airmass(zenith, model)
    217 # set zenith values greater than 90 to nans
    218 z = np.where(zenith > 90, np.nan, zenith)
--> 219 zenith_rad = np.radians(z)
    221 model = model.lower()
    223 if 'kastenyoung1989' == model:

TypeError: loop of ufunc does not support argument 0 of type float which has no callable radians method

Would anyone know if there's something wrong with the code or if it's a bug? Thank you!!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions