Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

GHI to POA Transposition

47 views
Skip to first unread message

Lorenzo Petrini

unread,
May 7, 2024, 6:32:14 AM5/7/24
to pvlib-python
Dear pvlib community,

I'm trying to convert a GHI into POA using the code in the link:


But I don't want to use GHI from a database, I want to use the GHI I measured in the site. But when I try to substitute the part of the code where it is defined the ghi variable:

ghi=clearsky['ghi']      with a vector (or list, I don't know yet the terms of phyton, I apologize for that) containing the values of GHI measured (each 1 min, for 24 hour) and I run the code, I got the following error:

TypeError: can't multiply sequence by non-int of type 'float'

Someone has already done this succesfully?

Thank you in advance for helping,

Kind Regards
Lorenzo Petrini

PS: the whole output is 


runfile('C:/Users/A474229/OneDrive - Enel Spa/Desktop/Sedeis V.py', wdir='C:/Users/A474229/OneDrive - Enel Spa/Desktop')
Traceback (most recent call last):

  File ~\AppData\Local\anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File c:\users\a474229\onedrive - enel spa\desktop\sedeis v.py:1484
    summer_irradiance = get_irradiance(site, '04-21-2024', 30, 180)

  File c:\users\a474229\onedrive - enel spa\desktop\sedeis v.py:1469 in get_irradiance
    POA_irradiance = irradiance.get_total_irradiance(

  File ~\AppData\Local\anaconda3\Lib\site-packages\pvlib\irradiance.py:380 in get_total_irradiance
    poa_ground_diffuse = get_ground_diffuse(surface_tilt, ghi, albedo,

  File ~\AppData\Local\anaconda3\Lib\site-packages\pvlib\irradiance.py:597 in get_ground_diffuse
    diffuse_irrad = ghi * albedo * (1 - np.cos(np.radians(surface_tilt))) * 0.5

TypeError: can't multiply sequence by non-int of type 'float'

Abed W Ayyad

unread,
May 7, 2024, 3:19:16 PM5/7/24
to Lorenzo Petrini, pvlib-python

--
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/4f3f68b0-4c3d-4624-9c20-55c72b39d9f6n%40googlegroups.com.

Echedey Luis Álvarez

unread,
May 7, 2024, 3:19:21 PM5/7/24
to pvlib-...@googlegroups.com

Hi Lorenzo,

Everything in Python is an object, and it is up to each of them how to implement arithmetic operations.

If you run [1, 2, 3] * 1.5 you will get the same error. This is because a list (the first item) doesn't implement multiplication by non ints (the second item is a float). If you multiply by an int you will get another type of result: you can try running [1,2,3]*2 on the python console and checking the output.

Now, what you have to do is exactly what you expect: you need an object that defines the element-wise multiplication. For this kind of use, we usually either use numpy.ndarray or pandas.Series objects (there are other alternatives too).

Possibilities to convert a Python list into an array are:

I heavily recommend you check out their docs, reading documentation in Python is a key part in the development.

I don't really know where are you getting the data from, but pandas has an extensive API of readers: CSV files, JSON, ... Just in case it can help you.


/Echedey.

Reply all
Reply to author
Forward
Message has been deleted
0 new messages