-
Notifications
You must be signed in to change notification settings - Fork 37
Refactor curve fitting functions #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Since these functions used in a pandas.GroupBy.apply() call, manipulating the index to calculate minute of the day can significantly reduce performance. Here we remove the _get_minute_of_day function and instead pass in the x values as a paramter. In addition to improving performance this makes the curve fitting code cleaner and substantially more general.
Shows how to calculate numeric x-values for curve fitting to a time series.
These were old comments that are no longer necessary and don't quite match the current function.
Bring the comment up to date and provide a description of all parameters. This function has gotten complex enough that it needs a docstring-like comment to describe it.
Previously parameters for y-values (`day`) and x-values (`minutes`) were separated by the `fitfunc` parameter. It makes more sense for these two parameters to be adjacent.
pvanalytics/util/_fit.py
Outdated
---------- | ||
data : Series | ||
power or irradiance data. | ||
x : Series |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
x : Series | |
x : array or Series |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...unless you think this would require testing with array input type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would feel better if we added tests with array input. Probably worth having some tests separate from the tests of orientation/tracker tests anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the best description for this type is numpy's 'array_like'. I'll change the type for x
, but leave y
as a Series.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK with me
Co-authored-by: Cliff Hansen <cwhanse@sandia.gov>
Change the description of the `x` parameter to curve fitting functions. This can be any array-like type, it doesn't have to be a Series. In fact we already pass non-series input (Int64Index).
Since these functions are used in a
pandas.GroupBy.apply()
call, manipulating the index to calculate minute of the day can significantly reduce performance. Here we remove the_get_minute_of_day()
function and instead pass in the x values as a parameter. In addition to improving performance this makes the curve fitting code cleaner and substantially more general.