Issue with model=perez when running the "get_total_irradiance" function

56 views
Skip to first unread message

Brian Custodio

unread,
Apr 2, 2020, 4:17:39 PM4/2/20
to pvlib-python
Hello all,

I've been experimenting with pvlib for a bit now and have a particular question regarding the get_total_irradiance function. I've been able to get it to run using the following models:

isotropic (default)
klucher
haydavies
reindl
king

The only model I've not been able to use is perez, which is actually the one I want to use so I can compare it to POA generated by PVSyst Perez transposition. I understand that using model="perez" triggers an auto-response with  model_perez='allsitescomposite1990', but I'm not exactly sure what this means. I've tried a few of the other perez coefficient options (e.g. 'allsitescomposite1988', '1990', 'albany1988') to no avail. The error being thrown is a TypeError:

TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'

and it appears to be occurring at this line in irradiance.py:

   1128     # delta is the sky's "brightness"
-> 1129     delta = dhi * airmass / dni_extra

I've checked my input GHI, DNI, and DHI and can confirm that all of the datatypes are floats. Any feedback on why this is happening is very welcome.

Thank you,
Brian

cwh...@sandia.gov

unread,
Apr 2, 2020, 4:21:11 PM4/2/20
to pvlib-python
Maybe the problem lies upstream in the input to the solar position or air mass calculation?

There are several parameter sets published for the Perez transposition model. 'allsitescomposite1990' is the most commonly used, to my understanding.

Cliff

Brian Custodio

unread,
Apr 2, 2020, 4:41:25 PM4/2/20
to cwh...@sandia.gov, pvlib-python
I'm actually not including anything for airmass, which by default is set to 'None'. Here is my call:

tot_irrad = pvlib.irradiance.get_total_irradiance(tilt_or_max_angle,
                                                          azimuth,
                                                          solpos['zenith'],
                                                          solpos['azimuth'],
                                                          df[DNI], df[GHI], df[DHI],
                                                          dni_extra = dni_extra,
                                                          model='perez',
                                                          model_perez='allsitescomposite1990'
                                                         )

solpos is calculated as follows:

solpos = pvlib.solarposition.get_solarposition(ts, latitude=lat, longitude=lon, method='ephemeris')

where ts = datetimeindex with timezone set to 'America/Los_Angeles'.

--
You received this message because you are subscribed to the Google Groups "pvlib-python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pvlib-python...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pvlib-python/21048bb3-68dd-485f-a284-7571bfcf14db%40googlegroups.com.


--

Brian Custodio

Senior Manager - Data Science & Consulting, Enertis Solar

M.S. Mechanical Engineering, SJSU

B.S. Mechanical Engineering, U.C. Berkeley


Debayan Paul

unread,
Apr 2, 2020, 5:03:41 PM4/2/20
to pvlib-python
Hi Brian,

I would suggest checking if any of the argument is by mistake a NaN value, individually. Else I would suggest installing PVLIB older version 0.6.3 in your environment, this could be a version issue maybe.

Thanks,
Debayan
To unsubscribe from this group and stop receiving emails from it, send an email to pvlib-...@googlegroups.com.

Kevin Anderson

unread,
Apr 2, 2020, 5:27:19 PM4/2/20
to pvlib-python
Hi Brian,

From the error message TypeError: unsupported operand type(s) for *: 'float' and 'NoneType'
and the traceback line you highlighted:

   1128     # delta is the sky's "brightness"
-> 1129     delta = dhi * airmass / dni_extra

the problem is that airmass is None but an actual value is required.  Like you said, get_total_irradiance defaults to airmass=None, presumably because perez is the only model that requires it:


So to get your code working, you'll need to calculate airmass and pass it into get_total_irradiance so that the perez model gets all of its necessary parameters.  Probably get_total_irradiance should raise a more helpful error message in this case, perhaps by validating that all necessary inputs are provided before running the underlying model function.  Or at least we could document that airmass is required when model='perez'.

Cheers,
Kevin

Brian Custodio

unread,
Apr 2, 2020, 6:40:25 PM4/2/20
to Kevin Anderson, pvlib-python
Hello Kevin, Paul,

Thank you so much for the prompt responses. Kevin, you raise a very good point. I will try that out and let you know what I find. I think it would be very helpful to see a note saying that "airmass" is required only when model=perez.

Best,
Brian

To unsubscribe from this group and stop receiving emails from it, send an email to pvlib-python...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pvlib-python/c3a97cfa-145d-429d-83a3-32cc887daf31%40googlegroups.com.

Brian Custodio

unread,
Apr 2, 2020, 6:56:39 PM4/2/20
to Kevin Anderson, pvlib-python
Hello again,

It worked! I defined airmass using the following call:

airmass_df = location.get_airmass(df.index, solar_position=solpos)
get_total_irradiance works with either of the columns within the airmass_df. Do you have a recommendation one way or the other (airmass_relative, airmass_absolute)?

Thanks again for your help,
Brian

Kevin Anderson

unread,
Apr 2, 2020, 8:10:27 PM4/2/20
to pvlib-python
Glad to hear it!  The perez function docs specify relative airmass is to be used: https://pvlib-python.readthedocs.io/en/stable/generated/pvlib.irradiance.perez.html

If you're interested in details, see reference [2], section 2.2.4.a: https://www.sciencedirect.com/science/article/pii/S0038092X87800312

Perhaps that's another docs improvement to make for get_total_irradiance.  Any other documentation suggestions?  :)

Kevin


--

Brian Custodio

Senior Manager - Data Science & Consulting, Enertis Solar

M.S. Mechanical Engineering, SJSU

B.S. Mechanical Engineering, U.C. Berkeley


Brian Custodio

unread,
Apr 3, 2020, 1:47:25 AM4/3/20
to Kevin Anderson, pvlib-python
Ah relative it is! Yes, maybe it would be good to have a note suggesting to use the airmass_relative column.

Thanks again!
Brian
Reply all
Reply to author
Forward
0 new messages