-
Notifications
You must be signed in to change notification settings - Fork 37
Description
I was wondering if functions to fit data would be within the scope of pvanalytics, perhaps in a new data fitting
module. Brief chat with @cdeline suggests there is a chance they might be, so I wanted to open an issue.
In the case of performance modeling at least, these could be linked to pvlib-python functions so that users could derive their own model coefficients for use in those functions. Functionality may need to be added to the respective pvlib-python functions to allow user-specified coefficients as input.
Why not just do this in pvlib-python? I think sometimes it is not always clear what fitting method(s) the original author(s) of a performance model used, so it may not always be possible to stick with the original method of the author(s), which is what we try to do in pvlib-python. (For example, see previous discussions pvlib-python #1979 and pvlib-python #2242
Implementation in pvanalytics might offer sufficient separation from the original model, allowing some flexibility, while still providing supporting tools to users of pvlib-python.
A simple example for a function z(x,y):
from scipy.optimize import curve_fit
import numpy as np
def fit_an_example_model(x, y, z):
def example_model(X, a, b, c):
x, y = X
return a * x**b + y**c
X = np.vstack((x, y))
fitted_coeffs, _ = curve_fit(example_model, X, z)
a, b, c = fitted_coeffs
return fitted_coeffs
An optional argument, perhaps, could also allow the user to choose whether they want to generate some basic fitting statistics for their fit. The user could also specify the fitting method they want to use.
The alternative would be to publish a gallery example in pvlib-python as suggested here.
Thoughts @cwhanse @kperrynrel?