You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow arbitrary IAM function in pvlib.iam.marion_diffuse, and possibly improve horizon integral computation. #1980
Is your feature request related to a problem? Please describe.
I am working on an application using pvlib.iam.marion_diffuse, and I would like to inject my own IAM function as a parameter to this pvlib.iam.marion_diffuse.
Describe the solution you'd like
I would like to define the common interface for the existing IAM function choices fo pvlib.iam.marion_diffuse, then allow any function meeting this interface (or Protocol, in Python speak) to be passable to pvlib.iam.marion_diffuse.
Describe alternatives you've considered
Do this on my own and not try to port it back to pvlib-python.
Additional context
If my understanding is correct, there is also a potential simplification to the Marion integral for the horizon component, which for models like Perez is considered to be concentrated in the 2D horizon ring.
Note that marion_diffuse is a simple wrapper around marion_integrate, which takes an arbitrary function f(aoi) and integrates it across a region. So it is already possible to use custom IAM functions, although it's somewhat cumbersome. Some brief discussion of this idea is in the original PR: #984 (comment)
I think it would be a straightforward modification to allow marion_diffuse to take functions as well as the current model names.
@kandersolar Thanks for the background. I see in the history that your first inclination was apparently to make marion_diffuse simply take any callable IAM function :). Given the way pvlib-python tends to prefer ease-of-use over extensibility, I think relying on the lower level marion_integrate is probably sufficient for this repo. I'm going to close this.
For posterity (using pvlib 0.10.4), here is a computational comparison of the three correction factors from the Marion model using the physical setting in pvlib.iam.marion_diffuse vs. using pvlib.iam.marion_integrate with the "custom" IAM model derived from a PCHIP interpolation to IEC 61853-2 data (see graph).
pvlib.iam.marion_diffuse using physical model
{'ground': 0.7998463278034974,
'horizon': 0.8975832800966072,
'sky': 0.9587871231479588}
pvlib.iam.marion_integrate using interpolated data IEC 61853-2:
{'ground': 0.8312793473238048,
'horizon': 0.9199299978256542,
'sky': 0.9691309027924638}
Thanks again @kandersolar for suggesting the workaround :).
Activity
kandersolar commentedon Feb 24, 2024
Note that
marion_diffuseis a simple wrapper around marion_integrate, which takes an arbitrary functionf(aoi)and integrates it across a region. So it is already possible to use custom IAM functions, although it's somewhat cumbersome. Some brief discussion of this idea is in the original PR: #984 (comment)I think it would be a straightforward modification to allow
marion_diffuseto take functions as well as the current model names.markcampanelli commentedon Feb 25, 2024
@kandersolar Thanks for the background. I see in the history that your first inclination was apparently to make
marion_diffusesimply take any callable IAM function :). Given the waypvlib-pythontends to prefer ease-of-use over extensibility, I think relying on the lower levelmarion_integrateis probably sufficient for this repo. I'm going to close this.markcampanelli commentedon Apr 15, 2024
For posterity (using
pvlib0.10.4), here is a computational comparison of the three correction factors from the Marion model using thephysicalsetting inpvlib.iam.marion_diffusevs. usingpvlib.iam.marion_integratewith the "custom" IAM model derived from a PCHIP interpolation to IEC 61853-2 data (see graph).pvlib.iam.marion_diffuseusingphysicalmodel{'ground': 0.7998463278034974,
'horizon': 0.8975832800966072,
'sky': 0.9587871231479588}
pvlib.iam.marion_integrateusing interpolated data IEC 61853-2:{'ground': 0.8312793473238048,
'horizon': 0.9199299978256542,
'sky': 0.9691309027924638}
Thanks again @kandersolar for suggesting the workaround :).