Skip to content

Conversation

wfvining
Copy link
Collaborator

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.

wfvining added 2 commits July 16, 2020 13:58
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.
@wfvining wfvining requested a review from cwhanse July 16, 2020 20:19
wfvining added 5 commits July 21, 2020 11:42
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.
@wfvining wfvining requested a review from cwhanse July 21, 2020 20:36
----------
data : Series
power or irradiance data.
x : Series
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
x : Series
x : array or Series

Copy link
Member

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

Copy link
Member

@cwhanse cwhanse Jul 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK with me

wfvining and others added 3 commits July 23, 2020 08:10
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).
@wfvining wfvining merged commit 3da4fe3 into master Jul 24, 2020
@wfvining wfvining deleted the refactor/fit-x-values branch July 24, 2020 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants